ImageViewerWindow.xaml 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <Window x:Class="MeterVision.ImageViewerWindow"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6. mc:Ignorable="d"
  7. Title="图片查看" Height="400" Width="400"
  8. WindowStartupLocation="CenterOwner">
  9. <Window.Resources>
  10. <!-- Define styles for the buttons -->
  11. <Style x:Key="ImageButtonStyle" TargetType="Button">
  12. <Setter Property="Background" Value="#444444"/>
  13. <Setter Property="BorderThickness" Value="0"/>
  14. <Setter Property="Padding" Value="10"/>
  15. <Setter Property="Margin" Value="5"/>
  16. <Setter Property="Foreground" Value="White"/>
  17. <Setter Property="Template">
  18. <Setter.Value>
  19. <ControlTemplate TargetType="Button">
  20. <Grid>
  21. <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
  22. </Grid>
  23. </ControlTemplate>
  24. </Setter.Value>
  25. </Setter>
  26. </Style>
  27. </Window.Resources>
  28. <Grid>
  29. <!-- Row definitions to control layout -->
  30. <Grid.RowDefinitions>
  31. <RowDefinition Height="*" />
  32. <!-- Image row -->
  33. <RowDefinition Height="Auto" />
  34. <!-- Toolbar row -->
  35. </Grid.RowDefinitions>
  36. <!--Image with ScrollViewer for zooming-->
  37. <!--<ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">-->
  38. <ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled"
  39. PreviewMouseWheel="ScrollViewer_PreviewMouseWheel" PreviewMouseDown="ScrollViewer_PreviewMouseDown"
  40. PreviewMouseMove="ScrollViewer_PreviewMouseMove" PreviewMouseUp="ScrollViewer_PreviewMouseUp">
  41. <Image x:Name="imgViewer" Stretch="Uniform" RenderTransformOrigin="0.5,0.5"
  42. PreviewMouseLeftButtonDown="ImgViewer_PreviewMouseLeftButtonDown"
  43. VerticalAlignment="Center" HorizontalAlignment="Center" />
  44. </ScrollViewer>
  45. <!--<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
  46. <Image x:Name="imgViewer" Stretch="None" RenderTransformOrigin="0.5, 0.5">
  47. <Image.LayoutTransform>
  48. <TransformGroup>
  49. <ScaleTransform ScaleX="{Binding ZoomFactor}" ScaleY="{Binding ZoomFactor}" />
  50. <RotateTransform Angle="{Binding RotationAngle}" />
  51. </TransformGroup>
  52. </Image.LayoutTransform>
  53. </Image>
  54. </ScrollViewer>-->
  55. <!--<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
  56. <Viewbox>
  57. <Image x:Name="imgViewer" Stretch="None" RenderTransformOrigin="0.5, 0.5" />
  58. </Viewbox>
  59. </ScrollViewer>-->
  60. <!-- Toolbar with material design icons -->
  61. <StackPanel Grid.Row="1" Orientation="Horizontal" Background="#666666" Margin="5" HorizontalAlignment="Center">
  62. <!--<Button Style="{StaticResource ImageButtonStyle}" Click="ZoomIn_Click">
  63. <materialDesign:PackIcon Background="Transparent" Kind="MagnifyPlus" Width="32" Height="32" Margin="10 0 10 0" />
  64. </Button>
  65. <Button Style="{StaticResource ImageButtonStyle}" Click="ZoomOut_Click">
  66. <materialDesign:PackIcon Background="Transparent" Kind="MagnifyMinus" Width="32" Height="32" Margin="0 0 10 0"/>
  67. </Button>
  68. <Button Style="{StaticResource ImageButtonStyle}" Click="Reset_Click">
  69. <materialDesign:PackIcon Background="Transparent" Kind="Reload" Width="32" Height="32" Margin="0 0 10 0"/>
  70. </Button>
  71. <Button Style="{StaticResource ImageButtonStyle}" Click="RotateLeft_Click">
  72. <materialDesign:PackIcon Background="Transparent" Kind="RotateLeftVariant" Width="32" Height="32" Margin="0 0 10 0" />
  73. </Button>
  74. <Button Style="{StaticResource ImageButtonStyle}" Click="RotateRight_Click">
  75. <materialDesign:PackIcon Background="Transparent" Kind="RotateRightVariant" Width="32" Height="32" Margin="0 0 10 0"/>
  76. </Button>-->
  77. </StackPanel>
  78. </Grid>
  79. </Window>