<UserControl x:Class="MeterVision.UC.UCImage"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:MeterVision.UC"
             mc:Ignorable="d" 
             Background="White"
             BorderBrush="#D3D3D3"
             BorderThickness="1"
             Padding="0"
             Margin="2"
             d:DesignHeight="400" d:DesignWidth="400">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <!--<Border VerticalAlignment="Center" Background="WhiteSmoke" BorderBrush="#D3D3D3" BorderThickness="0 0 0 1">
            
            --><!--<TextBlock x:Name="txtImgName" Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=ImageName}" FontSize="14px" FontWeight="Bold" Margin="5"/>-->
            <!--<StackPanel>
                <TextBlock x:Name="txtImgName" Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=ImageName}" FontSize="14px" FontWeight="Bold" Margin="5"/>
                <TextBlock Text="{Binding}" FontSize="12px" Margin="5"/>
                --><!-- 显示 DataContext --><!--
            </StackPanel>--><!--
            
        </Border>-->

        <Border VerticalAlignment="Center" Background="WhiteSmoke" BorderBrush="#D3D3D3" BorderThickness="0 0 0 1">
            <TextBlock x:Name="txtImgName" Text="{Binding ImageName, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" FontSize="14px" FontWeight="Bold" Margin="5"/>
        </Border>

        <!--<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" 
                      CanContentScroll="False" ClipToBounds="True" Margin="2">
            <Image Source="C:\test_image\result\20241127_161419.jpg" Name="ImageControl" Stretch="Uniform">
                <Image.RenderTransform>
                    <TransformGroup>
                        <ScaleTransform ScaleX="1" ScaleY="1" />
                        <RotateTransform Angle="0" />
                    </TransformGroup>
                </Image.RenderTransform>
            </Image>
        </ScrollViewer>-->

        <!-- ScrollViewer for zooming and panning -->
        <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"
                   Source="{Binding ImageSource3}"
                   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>-->

            <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>

        <!-- 控制按钮 -->
        <!--<StackPanel Grid.Row="2" Height="30" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,0,0">
            <Button Click="RotateLeft_Click" Margin="0 0 20 0" Background="Transparent" BorderThickness="0">
                <Image Source="/Assest/left_rote.png" Stretch="Uniform"/>
            </Button>
            <Button Click="RotateRight_Click" Margin="0" Background="Transparent" BorderThickness="0">
                <Image Source="/Assest/right_roat.png" Stretch="Uniform"/>
            </Button>
        </StackPanel>-->
        <StackPanel x:Name="pnlImageCtl" 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="ImageSave_Click" Margin="0 5 10 5" Padding="0" Foreground="White" Background="#333333" />
        </StackPanel>

    </Grid>
</UserControl>