Skip to content

Commit

Permalink
Optimize image flip logic
Browse files Browse the repository at this point in the history
  • Loading branch information
tinohager committed Oct 25, 2022
1 parent a5455bd commit a150a05
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,29 @@
xmlns:local="clr-namespace:Portalum.TrwPrinter.EasyPrinterS3.ControlPanel"
mc:Ignorable="d"
Title="ImagePositionWindow"
Height="229"
Width="296"
Height="566"
Width="514"
Background="{StaticResource SecondaryColor}" WindowStartupLocation="CenterOwner">
<Grid>
<Button Style="{StaticResource BaseButtonStyle}" x:Name="ButtonFullSize" Content="Full Size 960x70" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="127" Height="30" Click="ButtonFullSize_Click"/>
<Button Style="{StaticResource BaseButtonStyle}" x:Name="ButtonLeftBottom" Content="Bottom Left 200x20" HorizontalAlignment="Left" Margin="10,79,0,0" VerticalAlignment="Top" Click="ButtonLeftBottom200x20_Click" Width="127" Height="29"/>
<Button Style="{StaticResource BaseButtonStyle}" x:Name="ButtonBottomRight200_20" Content="Bottom Right 200x20" HorizontalAlignment="Left" Margin="10,113,0,0" VerticalAlignment="Top" Width="127" Height="29" Click="ButtonBottomRight200x20_Click"/>
<Button Style="{StaticResource BaseButtonStyle}" x:Name="ButtonHalfSize" Content="Half Size 450x35" HorizontalAlignment="Left" Margin="11,45,0,0" VerticalAlignment="Top" Width="126" Height="29" Click="ButtonHalfSize_Click"/>
<Button Style="{StaticResource BaseButtonStyle}" x:Name="ButtonTopRight200_20" Content="Top Right 200x20" HorizontalAlignment="Left" Margin="10,147,0,0" VerticalAlignment="Top" Width="127" Height="29" Click="ButtonTopRight200_20_Click" />
<Grid Margin="0,0,0,-6">
<Button Style="{StaticResource BaseButtonStyle}" x:Name="ButtonFullSize" Content="Full Size 960x70" HorizontalAlignment="Left" Margin="5,145,0,0" VerticalAlignment="Top" Width="239" Height="30" Click="ButtonFullSize_Click" Grid.Column="1"/>
<Button Style="{StaticResource BaseButtonStyle}" x:Name="ButtonLeftBottom" Content="Bottom Left 200x20" HorizontalAlignment="Left" Margin="5,317,0,0" VerticalAlignment="Top" Click="ButtonLeftBottom200x20_Click" Width="239" Height="29"/>
<Button Style="{StaticResource BaseButtonStyle}" x:Name="ButtonBottomRight200_20" Content="Bottom Right 200x20" HorizontalAlignment="Left" Margin="256,317,0,0" VerticalAlignment="Top" Width="239" Height="29" Click="ButtonBottomRight200x20_Click"/>
<Button Style="{StaticResource BaseButtonStyle}" x:Name="ButtonHalfSize" Content="Half Size 450x35" HorizontalAlignment="Left" Margin="253,146,0,0" VerticalAlignment="Top" Width="239" Height="29" Click="ButtonHalfSize_Click" Grid.Column="1"/>
<Button Style="{StaticResource BaseButtonStyle}" x:Name="ButtonTopRight200_20" Content="Top Right 200x20" HorizontalAlignment="Left" Margin="5,484,0,0" VerticalAlignment="Top" Width="240" Height="29" Click="ButtonTopRight200_20_Click" />
<Canvas Margin="5,12,0,0" Background="WhiteSmoke" HorizontalAlignment="Left" Width="239" Height="128" VerticalAlignment="Top">
<Rectangle Canvas.Left="10" Canvas.Top="10" Height="108" Width="219" Stroke="Black" StrokeThickness="1" Fill="White" />
</Canvas>
<Canvas Margin="253,12,0,0" Background="WhiteSmoke" Grid.Column="1" HorizontalAlignment="Left" Width="239" Height="128" VerticalAlignment="Top">
<Rectangle Canvas.Left="10" Canvas.Top="58" Height="60" Width="108" Stroke="Black" StrokeThickness="1" Fill="White" HorizontalAlignment="Left" VerticalAlignment="Center" />
</Canvas>
<Canvas Margin="4,184,0,0" Background="WhiteSmoke" Grid.Column="1" Grid.RowSpan="2" HorizontalAlignment="Left" Width="240" Height="128" VerticalAlignment="Top">
<Rectangle Canvas.Left="10" Canvas.Top="80" Height="38" Width="58" Stroke="Black" StrokeThickness="1" Fill="White" HorizontalAlignment="Left" VerticalAlignment="Center" />
</Canvas>
<Canvas Background="WhiteSmoke" Height="128" Canvas.Left="-2" Canvas.Top="172" Width="239" Grid.Column="1" Margin="253,184,16,0" Grid.RowSpan="2" VerticalAlignment="Top">
<Rectangle Canvas.Left="171" Canvas.Top="80" Height="38" Width="58" Stroke="Black" StrokeThickness="1" Fill="White" HorizontalAlignment="Left" VerticalAlignment="Center" />
</Canvas>
<Canvas Margin="5,351,0,0" Background="WhiteSmoke" HorizontalAlignment="Left" Width="240" Height="128" VerticalAlignment="Top">
<Rectangle Canvas.Left="172" Canvas.Top="10" Height="38" Width="58" Stroke="Black" StrokeThickness="1" Fill="White" HorizontalAlignment="Left" VerticalAlignment="Top" />
</Canvas>
</Grid>
</Window>
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ private async void ButtonPrintImageDemo_Click(object sender, RoutedEventArgs e)

var printDocument = new PrintDocument();
printDocument.AddElement(new ImagePrintElement(filePath, imageConfigDialog.X1, imageConfigDialog.X2, imageConfigDialog.Y1, imageConfigDialog.Y2));
printDocument.AddElement(new TextPrintElement("imagedemo", 0, 60));
await this._printerClient.PrintDocumentAsync(printDocument);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0</TargetFrameworks>

<Version>1.0.11</Version>
<Version>1.0.12</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private async Task<byte[]> PreparePrintImageAsync(CancellationToken cancellation
.BackgroundColor(Color.White)
.DrawImage(image, new Point(0, (int)offsetY), 1f)
.Rotate(rotate)
.Flip(FlipMode.Vertical)
);

using var memoryStreamPrintImage = new MemoryStream();
Expand Down

0 comments on commit a150a05

Please sign in to comment.