FocusAnalyzerControl.xaml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <UserControl x:Class="TeamAAS_VP.Controls.FocusAnalyzerControl"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:local="clr-namespace:TeamAAS_VP.Controls"
  7. xmlns:oxy="http://oxyplot.org/wpf"
  8. mc:Ignorable="d"
  9. d:DesignHeight="600"
  10. d:DesignWidth="800">
  11. <UserControl.Resources>
  12. <Style x:Key="CardStyle"
  13. TargetType="Border">
  14. <Setter Property="Background"
  15. Value="#FFFFFF" />
  16. <Setter Property="CornerRadius"
  17. Value="4" />
  18. <Setter Property="BorderBrush"
  19. Value="#E0E0E0" />
  20. <Setter Property="BorderThickness"
  21. Value="1" />
  22. <Setter Property="Padding"
  23. Value="8" />
  24. <Setter Property="Margin"
  25. Value="4" />
  26. </Style>
  27. <Style x:Key="ValueTextStyle"
  28. TargetType="TextBlock">
  29. <Setter Property="FontSize"
  30. Value="14" />
  31. <Setter Property="FontWeight"
  32. Value="SemiBold" />
  33. <Setter Property="Margin"
  34. Value="0,2,0,4" />
  35. </Style>
  36. </UserControl.Resources>
  37. <Grid>
  38. <Grid.ColumnDefinitions>
  39. <ColumnDefinition Width="*" />
  40. <ColumnDefinition Width="300" />
  41. </Grid.ColumnDefinitions>
  42. <!-- 左侧:图像显示和图表 -->
  43. <Grid Grid.Column="0">
  44. <Grid.RowDefinitions>
  45. <RowDefinition Height="Auto" />
  46. <RowDefinition Height="*" />
  47. <RowDefinition Height="200" />
  48. </Grid.RowDefinitions>
  49. <!-- 状态栏 -->
  50. <Border Grid.Row="0"
  51. Style="{StaticResource CardStyle}">
  52. <StackPanel Orientation="Horizontal">
  53. <TextBlock Text="状态: "
  54. FontWeight="Bold" />
  55. <TextBlock x:Name="StatusText"
  56. Text="就绪"
  57. Margin="5,0,0,0" />
  58. <TextBlock x:Name="FrameCountText"
  59. Text="帧数: 0"
  60. Margin="20,0,0,0" />
  61. <TextBlock x:Name="BestSharpnessText"
  62. Text="最佳: 0.00"
  63. Margin="20,0,0,0" />
  64. <Button x:Name="StartButton"
  65. Content="开始分析"
  66. Command="{Binding StartCommand}"
  67. Margin="20,0,5,0"
  68. Padding="10,4" />
  69. <Button x:Name="StopButton"
  70. Content="停止分析"
  71. Command="{Binding StopCommand}"
  72. Margin="5,0,0,0"
  73. Padding="10,4" />
  74. </StackPanel>
  75. </Border>
  76. <!-- 图像显示 -->
  77. <Border Grid.Row="1"
  78. Style="{StaticResource CardStyle}"
  79. Margin="0,4,0,4">
  80. <Grid>
  81. <Image x:Name="ImageDisplay"
  82. Source="{Binding CurrentImage}"
  83. Stretch="Uniform" />
  84. <!-- ROI绘制层 -->
  85. <Canvas x:Name="RoiCanvas"
  86. IsHitTestVisible="False">
  87. <Rectangle x:Name="RoiRectangle"
  88. Stroke="Red"
  89. StrokeThickness="2"
  90. StrokeDashArray="4,4"
  91. Visibility="Collapsed" />
  92. </Canvas>
  93. </Grid>
  94. </Border>
  95. <!-- 曲线图表 -->
  96. <Border Grid.Row="2"
  97. Style="{StaticResource CardStyle}">
  98. <oxy:PlotView x:Name="SharpnessPlot"
  99. Model="{Binding PlotModel}" />
  100. </Border>
  101. </Grid>
  102. <!-- 右侧:参数和结果显示 -->
  103. <Grid Grid.Column="1"
  104. Margin="4,0,0,0">
  105. <Grid.RowDefinitions>
  106. <RowDefinition Height="Auto" />
  107. <RowDefinition Height="Auto" />
  108. <RowDefinition Height="Auto" />
  109. <RowDefinition Height="*" />
  110. </Grid.RowDefinitions>
  111. <!-- 参数设置 -->
  112. <Border Grid.Row="0"
  113. Style="{StaticResource CardStyle}">
  114. <StackPanel>
  115. <TextBlock Text="分析参数"
  116. FontWeight="Bold"
  117. Margin="0,0,0,8" />
  118. <Grid>
  119. <Grid.RowDefinitions>
  120. <RowDefinition Height="Auto" />
  121. <RowDefinition Height="Auto" />
  122. <RowDefinition Height="Auto" />
  123. <RowDefinition Height="Auto" />
  124. </Grid.RowDefinitions>
  125. <Grid.ColumnDefinitions>
  126. <ColumnDefinition Width="80" />
  127. <ColumnDefinition Width="*" />
  128. </Grid.ColumnDefinitions>
  129. <TextBlock Grid.Row="0"
  130. Grid.Column="0"
  131. Text="算法:"
  132. VerticalAlignment="Center" />
  133. <ComboBox Grid.Row="0"
  134. Grid.Column="1"
  135. ItemsSource="{Binding FocusMethods}"
  136. SelectedItem="{Binding Parameters.FocusMethod}"
  137. Margin="0,0,0,4" />
  138. <TextBlock Grid.Row="1"
  139. Grid.Column="0"
  140. Text="模式:"
  141. VerticalAlignment="Center" />
  142. <ComboBox Grid.Row="1"
  143. Grid.Column="1"
  144. ItemsSource="{Binding AnalysisModes}"
  145. SelectedItem="{Binding Parameters.AnalysisMode}"
  146. Margin="0,0,0,4" />
  147. <TextBlock Grid.Row="2"
  148. Grid.Column="0"
  149. Text="亮度:"
  150. VerticalAlignment="Center" />
  151. <Slider Grid.Row="2"
  152. Grid.Column="1"
  153. Minimum="0"
  154. Maximum="255"
  155. Value="{Binding Parameters.TargetBrightness}"
  156. Margin="0,0,0,4" />
  157. <CheckBox Grid.Row="3"
  158. Grid.Column="0"
  159. Grid.ColumnSpan="2"
  160. Content="实时分析"
  161. IsChecked="{Binding Parameters.EnableRealtimeAnalysis}"
  162. Margin="0,4,0,0" />
  163. </Grid>
  164. <Button Content="恢复默认"
  165. Command="{Binding ResetCommand}"
  166. Margin="0,8,0,0"
  167. Padding="8,4" />
  168. </StackPanel>
  169. </Border>
  170. <!-- 清晰度结果 -->
  171. <Border Grid.Row="1"
  172. Style="{StaticResource CardStyle}"
  173. Margin="0,4,0,0">
  174. <Grid>
  175. <Grid.ColumnDefinitions>
  176. <ColumnDefinition Width="*" />
  177. <ColumnDefinition Width="*" />
  178. </Grid.ColumnDefinitions>
  179. <StackPanel Grid.Column="0">
  180. <TextBlock Text="当前清晰度"
  181. FontSize="11"
  182. Foreground="#666" />
  183. <TextBlock Text="{Binding CurrentResult.Sharpness, StringFormat=F2}"
  184. Style="{StaticResource ValueTextStyle}"
  185. Foreground="#007ACC" />
  186. <ProgressBar Value="{Binding CurrentResult.Sharpness}"
  187. Maximum="50"
  188. Height="6"
  189. Margin="0,2,4,0" />
  190. </StackPanel>
  191. <StackPanel Grid.Column="1">
  192. <TextBlock Text="质量评分"
  193. FontSize="11"
  194. Foreground="#666" />
  195. <TextBlock Text="{Binding CurrentResult.QualityScore, StringFormat=F1}"
  196. Style="{StaticResource ValueTextStyle}"
  197. FontSize="18" />
  198. <TextBlock Text="/100"
  199. FontSize="11"
  200. Foreground="#999" />
  201. </StackPanel>
  202. </Grid>
  203. </Border>
  204. <!-- 棋盘格分析 -->
  205. <Border Grid.Row="2"
  206. Style="{StaticResource CardStyle}"
  207. Margin="0,4,0,0">
  208. <StackPanel>
  209. <TextBlock Text="棋盘格分析"
  210. FontWeight="Bold"
  211. Margin="0,0,0,8" />
  212. <Grid>
  213. <Grid.RowDefinitions>
  214. <RowDefinition Height="Auto" />
  215. <RowDefinition Height="Auto" />
  216. </Grid.RowDefinitions>
  217. <Grid.ColumnDefinitions>
  218. <ColumnDefinition Width="*" />
  219. <ColumnDefinition Width="*" />
  220. </Grid.ColumnDefinitions>
  221. <TextBlock Grid.Row="0"
  222. Grid.Column="0"
  223. Text="状态:"
  224. FontSize="11"
  225. Foreground="#666" />
  226. <TextBlock Grid.Row="0"
  227. Grid.Column="1"
  228. Text="黑色均值:"
  229. FontSize="11"
  230. Foreground="#666" />
  231. <TextBlock Grid.Row="1"
  232. Grid.Column="0"
  233. Text="{Binding CurrentResult.Checkerboard.Detected,
  234. Converter={StaticResource BoolToTextConverter},
  235. ConverterParameter='已检测|未检测'}"
  236. Style="{StaticResource ValueTextStyle}" />
  237. <TextBlock Grid.Row="1"
  238. Grid.Column="1"
  239. Text="{Binding CurrentResult.Checkerboard.BlackMean, StringFormat=F1}"
  240. Style="{StaticResource ValueTextStyle}" />
  241. <TextBlock Grid.Row="2"
  242. Grid.Column="0"
  243. Text="对比度:"
  244. FontSize="11"
  245. Foreground="#666" />
  246. <TextBlock Grid.Row="2"
  247. Grid.Column="1"
  248. Text="白色均值:"
  249. FontSize="11"
  250. Foreground="#666" />
  251. <TextBlock Grid.Row="3"
  252. Grid.Column="0"
  253. Text="{Binding CurrentResult.Checkerboard.Contrast, StringFormat=F1}"
  254. Style="{StaticResource ValueTextStyle}" />
  255. <TextBlock Grid.Row="3"
  256. Grid.Column="1"
  257. Text="{Binding CurrentResult.Checkerboard.WhiteMean, StringFormat=F1}"
  258. Style="{StaticResource ValueTextStyle}" />
  259. </Grid>
  260. <TextBlock Text="建议亮度:"
  261. FontSize="11"
  262. Foreground="#666"
  263. Margin="0,8,0,0" />
  264. <TextBlock Text="{Binding CurrentResult.Checkerboard.OptimalBrightness}"
  265. Style="{StaticResource ValueTextStyle}"
  266. Foreground="#4CAF50" />
  267. </StackPanel>
  268. </Border>
  269. <!-- 建议列表 -->
  270. <Border Grid.Row="3"
  271. Style="{StaticResource CardStyle}"
  272. Margin="0,4,0,0">
  273. <StackPanel>
  274. <TextBlock Text="调整建议"
  275. FontWeight="Bold"
  276. Margin="0,0,0,8" />
  277. <ScrollViewer VerticalScrollBarVisibility="Auto"
  278. MaxHeight="200">
  279. <ItemsControl ItemsSource="{Binding CurrentResult.Suggestions}">
  280. <ItemsControl.ItemTemplate>
  281. <DataTemplate>
  282. <Border Background="#F5F5F5"
  283. CornerRadius="3"
  284. Padding="6"
  285. Margin="0,0,0,4">
  286. <TextBlock Text="{Binding}"
  287. TextWrapping="Wrap"
  288. FontSize="11" />
  289. </Border>
  290. </DataTemplate>
  291. </ItemsControl.ItemTemplate>
  292. </ItemsControl>
  293. </ScrollViewer>
  294. <Button Content="导出报告"
  295. Command="{Binding ExportCommand}"
  296. Margin="0,8,0,0"
  297. Padding="8,4" />
  298. </StackPanel>
  299. </Border>
  300. </Grid>
  301. </Grid>
  302. </UserControl>