image_text.xaml 4.8 KB
<UserControl x:Class="SmartScan.SetControl.WPF.image_text"
             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:SmartScan.SetControl.WPF"  
             xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
             xmlns:wfh="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800" BorderThickness="0">
    <UserControl.Resources>
        <!-- 按钮样式 -->
        <Style x:Key="ImageViewerButtonStyle" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
            <Setter Property="Background" Value="#3E3E3E"/>
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Padding" Value="10,5"/>
            <Setter Property="Height" Value="30"/>
            <Setter Property="Cursor" Value="Hand"/>
        </Style>
    </UserControl.Resources>
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Grid Grid.Row="0" Background="#1E1E1E" >
            <wfh:WindowsFormsHost Name="imageViewer"   Background="Aqua"></wfh:WindowsFormsHost>

            <!-- 叠加在ImageViewer上的Canvas用于绘制中心点 -->
            <Canvas x:Name="centerPointsCanvas" 
                    IsHitTestVisible="False" 
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch"
                    Background="Transparent"
                    />
        </Grid>
        <!-- 控制按钮区域 -->
        <Border Grid.Row="1" Background="#2D2D30">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,8,0,8">
                <!-- 放大按钮 -->
                <Button x:Name="zoomInButton" 
                        Style="{StaticResource ImageViewerButtonStyle}"
                        Width="40" 
                        Margin="5,0" 
                        Click="ZoomInButton_Click"
                        ToolTip="放大">
                    <TextBlock Text="+" FontSize="16" FontWeight="Bold"/>
                </Button>
                <!-- 缩小按钮 -->
                <Button x:Name="zoomOutButton" 
                        Style="{StaticResource ImageViewerButtonStyle}"
                        Width="40" 
                        Margin="5,0" 
                        Click="ZoomOutButton_Click"
                        ToolTip="缩小">
                    <TextBlock Text="-" FontSize="16" FontWeight="Bold"/>
                </Button>
                <!-- 适应屏幕按钮 -->
                <Button x:Name="fitToScreenButton" 
                        Style="{StaticResource ImageViewerButtonStyle}"
                        Width="40" 
                        Margin="5,0" 
                        Click="FitToScreenButton_Click"
                        ToolTip="适应屏幕">
                    <Viewbox Width="16" Height="16">
                        <Path Data="M21,15H23V17H21V15M21,11H23V13H21V11M23,19H21V21C22.1,21 23,20.1 23,19M13,3H15V5H13V3M21,7H23V9H21V7M21,3V5H23C23,3.9 22.1,3 21,3M1,7H3V9H1V7M17,3H19V5H17V3M17,19H19V21H17V19M3,3C1.9,3 1,3.9 1,5H3V3M9,3H11V5H9V3M5,3H7V5H5V3M1,11H3V13H1V11M3,21V19H1C1,20.1 1.9,21 3,21M3,15H1V17H3V15M9,19H11V21H9V19M13,19H15V21H13V19M5,19H7V21H5V19Z" 
                              Fill="White" 
                              Stretch="Uniform" />
                    </Viewbox>
                </Button>

                <!-- 旋转按钮 -->
                <Button x:Name="rotateButton" 
                        Style="{StaticResource ImageViewerButtonStyle}"
                        Width="40" 
                        Margin="5,0" 
                        Click="RotateButton_Click"
                        ToolTip="旋转90度">
                    <Viewbox Width="16" Height="16">
                        <Path Data="M16.89,15.5L18.31,16.89C19.21,15.73 19.76,14.39 19.93,13H17.91C17.77,13.87 17.43,14.72 16.89,15.5M13,17.9V19.92C14.39,19.75 15.74,19.21 16.9,18.31L15.46,16.87C14.71,17.41 13.87,17.76 13,17.9M19.93,11C19.76,9.61 19.21,8.27 18.31,7.11L16.89,8.53C17.43,9.28 17.77,10.13 17.91,11M15.55,5.55L11,1V4.07C7.06,4.56 4,7.92 4,12C4,16.08 7.05,19.44 11,19.93V17.91C8.16,17.43 6,14.97 6,12C6,9.03 8.16,6.57 11,6.09V10L15.55,5.55Z" 
                              Fill="White" 
                              Stretch="Uniform" />
                    </Viewbox>
                </Button>
            </StackPanel>
        </Border>
    </Grid>
</UserControl>