| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528 |
- <UserControl x:Class="TeamAAS_VP.Views.DebugMod.FocusAnalyzer"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:local="clr-namespace:TeamAAS_VP.Views.DebugMod"
- xmlns:oxy="http://oxyplot.org/wpf"
- xmlns:prism="http://prismlibrary.com/"
- xmlns:c="clr-namespace:TeamAAS_VP.ValueConverter"
- xmlns:enums="clr-namespace:TeamAAS_VP.Enums"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:vm="clr-namespace:TeamAAS_VP.ViewModels.DebugMod"
- xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
- xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
- xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
- xmlns:sys="clr-namespace:System;assembly=mscorlib"
- xmlns:uControl="clr-namespace:TeamAAS_VP.Controls"
- xmlns:convert="clr-namespace:TeamAAS_VP.ValueConverter"
- xmlns:localbehaviors="clr-namespace:TeamAAS_VP.Behaviors"
- xmlns:lex="http://wpflocalizeextension.codeplex.com"
- lex:LocalizeDictionary.DesignCulture="zh-CN"
- lex:ResxLocalizationProvider.DefaultAssembly="TeamAAS-VP"
- lex:ResxLocalizationProvider.DefaultDictionary="Lang"
- prism:ViewModelLocator.AutoWireViewModel="True"
- mc:Ignorable="d"
- d:Width="1024"
- d:Height="768"
- d:Background="White"
- d:DataContext="{d:DesignInstance Type=vm:FocusAnalyzerViewModel}"
- FontFamily="{DynamicResource DefaultFont}">
- <UserControl.Resources>
- <!-- 转换器 -->
- <c:ObjectToVisibilityConverter x:Key="NullToVisibilityConverter" />
- <c:ObjectToVisibilityConverter x:Key="InvertNullToVisibilityConverter"
- Invert="True" />
- <c:EnumToBooleanConverter x:Key="EnumToBooleanConverter" />
- <c:RoiToTextConverter x:Key="RoiToTextConverter" />
- <!-- 样式 -->
- <Style x:Key="CardStyle"
- TargetType="Border">
- <Setter Property="Background"
- Value="#FFFFFF" />
- <Setter Property="CornerRadius"
- Value="4" />
- <Setter Property="BorderBrush"
- Value="#E0E0E0" />
- <Setter Property="BorderThickness"
- Value="1" />
- <Setter Property="Padding"
- Value="8" />
- <Setter Property="Margin"
- Value="4" />
- </Style>
- <Style x:Key="ToolButtonStyle"
- TargetType="RadioButton">
- <Setter Property="Width"
- Value="30" />
- <Setter Property="Height"
- Value="30" />
- <Setter Property="Margin"
- Value="2" />
- <Setter Property="Cursor"
- Value="Hand" />
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="RadioButton">
- <Border Background="{TemplateBinding Background}"
- BorderBrush="{TemplateBinding BorderBrush}"
- BorderThickness="1"
- CornerRadius="4">
- <ContentPresenter HorizontalAlignment="Center"
- VerticalAlignment="Center" />
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsChecked"
- Value="True">
- <Setter Property="Background"
- Value="#007ACC" />
- <Setter Property="Foreground"
- Value="White" />
- </Trigger>
- <Trigger Property="IsMouseOver"
- Value="True">
- <Setter Property="Background"
- Value="#F0F0F0" />
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <!-- ROI控制点样式 -->
- <Style x:Key="RoiHandleStyle"
- TargetType="Ellipse">
- <Setter Property="Width"
- Value="8" />
- <Setter Property="Height"
- Value="8" />
- <Setter Property="Fill"
- Value="White" />
- <Setter Property="Stroke"
- Value="Red" />
- <Setter Property="StrokeThickness"
- Value="1" />
- <Setter Property="Cursor"
- Value="SizeAll" />
- </Style>
- <!-- 旋转控制点样式 -->
- <Style x:Key="RotateHandleStyle"
- TargetType="Path">
- <Setter Property="Fill"
- Value="Red" />
- <Setter Property="Stroke"
- Value="White" />
- <Setter Property="StrokeThickness"
- Value="1" />
- <Setter Property="Cursor"
- Value="SizeAll" />
- <Setter Property="Data"
- Value="M 0,0 L 5,0 L 2.5,5 Z" />
- </Style>
- </UserControl.Resources>
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition Height="*" />
- </Grid.RowDefinitions>
- <!-- 工具栏 -->
- <Border Grid.Row="0"
- Background="#F5F5F5"
- BorderBrush="#E0E0E0"
- BorderThickness="0,0,0,1"
- Padding="10,8">
- <StackPanel Orientation="Horizontal">
- <Button Content="打开图像"
- Command="{Binding LoadImageCommand}"
- Padding="15,5"
- Margin="0,0,8,0" />
- <Button Content="检测棋盘格"
- Command="{Binding DetectChessboardCommand}"
- Padding="15,5"
- Margin="0,0,8,0" />
- <Separator Style="{StaticResource {x:Static ToolBar.SeparatorStyleKey}}"
- Margin="8,0" />
- <TextBlock Text="{Binding StatusText}"
- VerticalAlignment="Center"
- Foreground="#666"
- Margin="8,0,0,0" />
- </StackPanel>
- </Border>
- <!-- 主内容区 -->
- <Grid Grid.Row="1">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*" />
- <ColumnDefinition Width="280" />
- </Grid.ColumnDefinitions>
- <!-- 左侧:图像显示区 -->
- <Border Grid.Column="0"
- Style="{StaticResource CardStyle}"
- Margin="10">
- <Grid>
- <!-- 图像容器 -->
- <Grid x:Name="ImageContainer">
- <!-- 图像显示 -->
- <Image x:Name="ImageDisplay"
- Source="{Binding CurrentImage}"
- Stretch="Uniform">
- </Image>
- <!-- ROI绘制层 -->
- <Canvas x:Name="RoiCanvas"
- Background="Transparent"
- IsHitTestVisible="True">
- <!-- ROI矩形(带旋转) -->
- <Rectangle x:Name="RoiRectangle"
- Fill="Transparent">
- <Rectangle.Style>
- <Style TargetType="Rectangle">
- <Setter Property="Stroke"
- Value="Red" />
- <Setter Property="StrokeThickness"
- Value="2" />
- <Setter Property="StrokeDashArray"
- Value="4,4" />
- <Setter Property="RenderTransformOrigin"
- Value="0.5,0.5" />
- <Style.Triggers>
- <DataTrigger Binding="{Binding RoiMode}"
- Value="Draw">
- <Setter Property="StrokeDashArray"
- Value="2,2" />
- </DataTrigger>
- </Style.Triggers>
- </Style>
- </Rectangle.Style>
- <Rectangle.RenderTransform>
- <RotateTransform Angle="{Binding CurrentRoi.Angle}" />
- </Rectangle.RenderTransform>
- </Rectangle>
- <!-- 角点控制点 -->
- <Ellipse x:Name="TopLeftHandle"
- Style="{StaticResource RoiHandleStyle}" />
- <Ellipse x:Name="TopRightHandle"
- Style="{StaticResource RoiHandleStyle}" />
- <Ellipse x:Name="BottomLeftHandle"
- Style="{StaticResource RoiHandleStyle}" />
- <Ellipse x:Name="BottomRightHandle"
- Style="{StaticResource RoiHandleStyle}" />
- <!-- 边中点控制点 -->
- <Ellipse x:Name="TopHandle"
- Style="{StaticResource RoiHandleStyle}" />
- <Ellipse x:Name="RightHandle"
- Style="{StaticResource RoiHandleStyle}" />
- <Ellipse x:Name="BottomHandle"
- Style="{StaticResource RoiHandleStyle}" />
- <Ellipse x:Name="LeftHandle"
- Style="{StaticResource RoiHandleStyle}" />
- <!-- 旋转控制点 -->
- <Path x:Name="RotateHandle"
- Style="{StaticResource RotateHandleStyle}" />
- </Canvas>
- <!-- 无图像提示 -->
- <Border Background="#F9F9F9"
- BorderBrush="#E0E0E0"
- BorderThickness="2"
- CornerRadius="8"
- Visibility="{Binding CurrentImage, Converter={StaticResource InvertNullToVisibilityConverter}}">
- <StackPanel HorizontalAlignment="Center"
- VerticalAlignment="Center">
- <TextBlock Text="📷"
- FontSize="48"
- HorizontalAlignment="Center"
- Foreground="#CCC"
- Margin="0,0,0,16" />
- <TextBlock Text="点击【打开图像】加载棋盘格图片"
- FontSize="14"
- Foreground="#999"
- HorizontalAlignment="Center" />
- <Button Content="打开图像"
- Command="{Binding LoadImageCommand}"
- Margin="0,16,0,0"
- Padding="20,8" />
- </StackPanel>
- </Border>
- <!-- 操作提示 -->
- <Border Background="#80000000"
- CornerRadius="4"
- Padding="8"
- VerticalAlignment="Bottom"
- HorizontalAlignment="Center"
- Margin="0,0,0,10"
- Visibility="{Binding CurrentImage, Converter={StaticResource NullToVisibilityConverter}}">
- <StackPanel>
- <TextBlock Text="ROI操作提示"
- Foreground="White"
- FontWeight="Bold"
- Margin="0,0,0,4" />
- <TextBlock Text="拖动: 移动ROI"
- Foreground="White"
- FontSize="11" />
- <TextBlock Text="角点拖动: 调整大小"
- Foreground="White"
- FontSize="11" />
- <TextBlock Text="旋转点拖动: 旋转"
- Foreground="White"
- FontSize="11" />
- </StackPanel>
- </Border>
- </Grid>
- </Grid>
- </Border>
- <!-- 右侧:控制面板 -->
- <Grid Grid.Column="1"
- Margin="0,10,10,10">
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- <RowDefinition Height="*" />
- </Grid.RowDefinitions>
- <!-- ROI工具栏 -->
- <Border Grid.Row="0"
- Style="{StaticResource CardStyle}">
- <StackPanel>
- <TextBlock Text="ROI工具"
- FontWeight="Bold"
- Margin="0,0,0,8" />
- <StackPanel Orientation="Horizontal"
- HorizontalAlignment="Center">
- <!-- 绘制模式 -->
- <RadioButton Content="📐"
- Style="{StaticResource ToolButtonStyle}"
- ToolTip="绘制ROI"
- IsChecked="{Binding RoiMode, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter={x:Static enums:RoiOperationMode.Draw}}" />
- <!-- 移动模式 -->
- <RadioButton Content="↔"
- Style="{StaticResource ToolButtonStyle}"
- ToolTip="移动ROI"
- IsChecked="{Binding RoiMode, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter={x:Static enums:RoiOperationMode.Move}}" />
- <!-- 调整大小模式 -->
- <RadioButton Content="⤢"
- Style="{StaticResource ToolButtonStyle}"
- ToolTip="调整大小"
- IsChecked="{Binding RoiMode, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter={x:Static enums:RoiOperationMode.Resize}}" />
- <!-- 旋转模式 -->
- <RadioButton Content="↻"
- Style="{StaticResource ToolButtonStyle}"
- ToolTip="旋转ROI"
- IsChecked="{Binding RoiMode, Converter={StaticResource EnumToBooleanConverter}, ConverterParameter={x:Static enums:RoiOperationMode.Rotate}}" />
- <!-- 清除ROI -->
- <Button Width="30"
- Height="30"
- Margin="10,0,0,0"
- Padding="0"
- Content=""
- ToolTip="清除ROI"
- Command="{Binding ClearRoiCommand}">
- </Button>
- </StackPanel>
- <!-- ROI信息 -->
- <Border Background="#F5F5F5"
- CornerRadius="3"
- Padding="6"
- Margin="0,8,0,0">
- <StackPanel>
- <TextBlock Text="ROI信息"
- FontWeight="SemiBold"
- FontSize="11" />
- <TextBlock>
- <TextBlock.Text>
- <MultiBinding Converter="{StaticResource RoiToTextConverter}">
- <Binding Path="CurrentRoi.X" />
- <Binding Path="CurrentRoi.Y" />
- <Binding Path="CurrentRoi.Width" />
- <Binding Path="CurrentRoi.Height" />
- <Binding Path="CurrentRoi.Angle" />
- </MultiBinding>
- </TextBlock.Text>
- </TextBlock>
- </StackPanel>
- </Border>
- </StackPanel>
- </Border>
- <!-- 参数设置 -->
- <Border Grid.Row="1"
- Style="{StaticResource CardStyle}"
- Margin="0,8,0,0">
- <StackPanel>
- <TextBlock Text="分析参数"
- FontWeight="Bold"
- Margin="0,0,0,8" />
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- <RowDefinition Height="Auto" />
- </Grid.RowDefinitions>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="80" />
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
- <TextBlock Grid.Row="0"
- Grid.Column="0"
- Text="算法:"
- VerticalAlignment="Center" />
- <ComboBox Grid.Row="0"
- Grid.Column="1"
- ItemsSource="{Binding FocusMethods}"
- SelectedValue="{Binding Parameters.FocusMethod}"
- Margin="0,0,0,4" />
- <TextBlock Grid.Row="1"
- Grid.Column="0"
- Text="模式:"
- VerticalAlignment="Center" />
- <ComboBox Grid.Row="1"
- Grid.Column="1"
- ItemsSource="{Binding AnalysisModes}"
- SelectedValue="{Binding Parameters.AnalysisMode}"
- Margin="0,0,0,4" />
- <TextBlock Grid.Row="2"
- Grid.Column="0"
- Text="实时分析:"
- VerticalAlignment="Center" />
- <CheckBox Grid.Row="2"
- Grid.Column="1"
- IsChecked="{Binding Parameters.EnableRealtimeAnalysis}"
- VerticalAlignment="Center" />
- </Grid>
- </StackPanel>
- </Border>
- <!-- 控制按钮 -->
- <Border Grid.Row="2"
- Style="{StaticResource CardStyle}"
- Margin="0,8,0,0">
- <StackPanel>
- <StackPanel Orientation="Horizontal"
- HorizontalAlignment="Center">
- <Button Content="开始分析"
- Command="{Binding StartAnalysisCommand}"
- Padding="20,8"
- Margin="0,0,8,0" />
- <Button Content="停止分析"
- Command="{Binding StopAnalysisCommand}"
- Padding="20,8" />
- </StackPanel>
- <StackPanel Orientation="Horizontal"
- HorizontalAlignment="Center"
- Margin="0,8,0,0">
- <Button Content="重置"
- Command="{Binding ResetCommand}"
- Padding="15,4"
- Margin="0,0,8,0" />
- <Button Content="导出报告"
- Command="{Binding ExportCommand}"
- Padding="15,4" />
- </StackPanel>
- </StackPanel>
- </Border>
- <!-- 实时结果 -->
- <Border Grid.Row="3"
- Style="{StaticResource CardStyle}"
- Margin="0,8,0,0">
- <StackPanel>
- <TextBlock Text="实时结果"
- FontWeight="Bold"
- Margin="0,0,0,8" />
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*" />
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
- <StackPanel Grid.Column="0">
- <TextBlock Text="清晰度"
- FontSize="11"
- Foreground="#666" />
- <TextBlock Text="{Binding CurrentResult.Sharpness, StringFormat=F2}"
- FontSize="18"
- FontWeight="Bold"
- Foreground="#007ACC" />
- <TextBlock Text="{Binding StatusText}"
- FontSize="10"
- Foreground="#666"
- Margin="0,2,0,0" />
- </StackPanel>
- <StackPanel Grid.Column="1">
- <TextBlock Text="质量评分"
- FontSize="11"
- Foreground="#666" />
- <TextBlock Text="{Binding CurrentResult.QualityScore, StringFormat=F1}"
- FontSize="18"
- FontWeight="Bold"
- Foreground="#4CAF50" />
- <TextBlock Text="/100"
- FontSize="11"
- Foreground="#999" />
- </StackPanel>
- </Grid>
- <ProgressBar Value="{Binding CurrentResult.Sharpness}"
- Maximum="50"
- Height="6"
- Margin="0,8,0,0" />
- <!-- 最佳值显示 -->
- <Border Background="#F8F9FA"
- CornerRadius="3"
- Padding="6"
- Margin="0,8,0,0">
- <StackPanel Orientation="Horizontal">
- <TextBlock Text="最佳清晰度:"
- FontSize="10"
- Foreground="#666" />
- <TextBlock Text="{Binding BestSharpnessText}"
- FontSize="10"
- FontWeight="Bold"
- Margin="5,0,0,0" />
- <TextBlock Text="{Binding FrameCountText}"
- FontSize="10"
- Foreground="#666"
- Margin="10,0,0,0" />
- </StackPanel>
- </Border>
- </StackPanel>
- </Border>
- <!-- 图表 -->
- <Border Grid.Row="4"
- Style="{StaticResource CardStyle}"
- Margin="0,8,0,0">
- <oxy:PlotView Model="{Binding PlotModel}"
- Height="200" />
- </Border>
- </Grid>
- </Grid>
- </Grid>
- </UserControl>
|