12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <Window x:Class="MeterVision.imgWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:local="clr-namespace:MeterVision"
- mc:Ignorable="d"
- SizeChanged="Window_SizeChanged"
- Closed="Window_Closed"
- Title="图片查看[滑动鼠标滚轴进行缩放]" Height="450" Width="600"
- WindowStartupLocation="CenterOwner"
- PreviewMouseWheel="Window_PreviewMouseWheel"
- ShowInTaskbar="False"
- Loaded="Window_Loaded">
- <Grid>
- <!-- Row definitions to control layout -->
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition Height="*" />
- <!-- Image row -->
- <RowDefinition Height="Auto" />
- <!-- Toolbar row -->
- </Grid.RowDefinitions>
- <!-- ScrollViewer for zooming and panning -->
- <TextBox IsReadOnly="True" BorderThickness="0" Text="{Binding ImageSourcePath,Mode=OneWay}" Grid.Row="0" Margin="10 5 10 5" VerticalAlignment="Center" FontSize="14px" TextWrapping="Wrap"/>
- <ScrollViewer x:Name="scrollViewer" Grid.Row="1"
- HorizontalScrollBarVisibility="Auto"
- VerticalScrollBarVisibility="Auto"
- PanningMode="Both"
- PanningRatio="1">
- <Image x:Name="imgViewer" Stretch="None" RenderTransformOrigin="0.5, 0.5"
- PreviewMouseLeftButtonDown="Image_PreviewMouseLeftButtonDown"
- PreviewMouseMove="Image_PreviewMouseMove"
- PreviewMouseLeftButtonUp="Image_PreviewMouseLeftButtonUp">
- <!--<Image.LayoutTransform>
- <TransformGroup>
- <ScaleTransform ScaleX="{Binding ZoomFactor}" ScaleY="{Binding ZoomFactor}" />
- <RotateTransform Angle="{Binding RotationAngle}" />
- </TransformGroup>
- </Image.LayoutTransform>-->
- </Image>
- </ScrollViewer>
- <!-- Toolbar with buttons for zooming and rotating -->
- <StackPanel Grid.Row="2" Orientation="Horizontal" Background="#666666" Margin="5" HorizontalAlignment="Center">
- <Button Content="+" FontSize="20px" Width="30" Height="30" Click="ZoomIn_Click" Margin="10 5 10 5" Padding="0" Foreground="White" Background="#333333" />
- <Button Content="-" FontSize="20px" Width="30" Height="30" Click="ZoomOut_Click" Margin="0 5 10 5" Padding="0" Foreground="White" Background="#333333" />
- <Button Content="↔️" FontSize="20px" Width="30" Height="30" Click="ZoomFit_Click" Margin="0 5 10 5" Padding="0" Foreground="White" Background="#333333" />
- <Button Content="↺" FontSize="20px" Width="30" Height="30" Click="RotateLeft_Click" Margin="0 5 10 5" Padding="0" Foreground="White" Background="#333333" />
- <Button Content="↻" FontSize="20px" Width="30" Height="30" Click="RotateRight_Click" Margin="0 5 10 5" Padding="0" Foreground="White" Background="#333333" />
- <Button Content="📥" FontSize="20px" Width="30" Height="30" Click="ImageSave_Click" Margin="0 5 10 5" Padding="0" Foreground="White" Background="#333333" />
- <!--<Button Content="💾" FontSize="20px" Width="30" Height="30" Click="Save_Click" Foreground="Green" Background="#333333"/>-->
- </StackPanel>
- </Grid>
- </Window>
|