VisionStaticAccuracyAnalyzer.xaml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <UserControl x:Class="TeamAAS_VP.Views.Product.VisionStaticAccuracyAnalyzer"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:prism="http://prismlibrary.com/"
  5. xmlns:wf="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
  6. xmlns:vp="clr-namespace:Cognex.VisionPro;assembly=Cognex.VisionPro.Controls"
  7. xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
  8. xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
  9. xmlns:sys="clr-namespace:System;assembly=mscorlib"
  10. xmlns:uControl="clr-namespace:TeamAAS_VP.Controls"
  11. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  12. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  13. xmlns:vm="clr-namespace:TeamAAS_VP.ViewModels.Product"
  14. xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
  15. xmlns:lex="http://wpflocalizeextension.codeplex.com"
  16. lex:LocalizeDictionary.DesignCulture="zh-CN"
  17. lex:ResxLocalizationProvider.DefaultAssembly="TeamAAS-VP"
  18. lex:ResxLocalizationProvider.DefaultDictionary="Lang"
  19. prism:ViewModelLocator.AutoWireViewModel="True"
  20. mc:Ignorable="d"
  21. d:DataContext="{d:DesignInstance Type=vm:VisionStaticAccuracyAnalyzerViewModel}"
  22. d:Height="600"
  23. d:Width="1024"
  24. MinHeight="700"
  25. MinWidth="900"
  26. d:Background="White"
  27. HorizontalAlignment="Stretch"
  28. VerticalAlignment="Stretch"
  29. FontFamily="{DynamicResource DefaultFont}">
  30. <prism:Dialog.WindowStyle>
  31. <Style TargetType="Window">
  32. <Setter Property="prism:Dialog.WindowStartupLocation"
  33. Value="CenterScreen" />
  34. <Setter Property="AllowDrop"
  35. Value="True" />
  36. <Setter Property="ShowInTaskbar"
  37. Value="True" />
  38. <!--<Setter Property="SizeToContent"
  39. Value="WidthAndHeight" />-->
  40. <Setter Property="WindowState"
  41. Value="Maximized" />
  42. <Setter Property="Topmost"
  43. Value="True" />
  44. </Style>
  45. </prism:Dialog.WindowStyle>
  46. <UserControl.Resources>
  47. <!-- 样式定义 -->
  48. <Style TargetType="Button"
  49. BasedOn="{StaticResource MaterialDesignFlatDarkBgButton}">
  50. <Setter Property="Padding"
  51. Value="10 5" />
  52. <Setter Property="Margin"
  53. Value="5" />
  54. <Setter Property="FontSize"
  55. Value="14" />
  56. <Setter Property="BorderThickness"
  57. Value="0" />
  58. </Style>
  59. <Style TargetType="TextBlock">
  60. <Setter Property="VerticalAlignment"
  61. Value="Center" />
  62. <Setter Property="Margin"
  63. Value="5" />
  64. </Style>
  65. <Style TargetType="TextBox"
  66. BasedOn="{StaticResource MaterialDesignTextBox}">
  67. <Setter Property="Margin"
  68. Value="5" />
  69. <Setter Property="VerticalContentAlignment"
  70. Value="Center" />
  71. </Style>
  72. <Style x:Key="DataGridStyle"
  73. TargetType="DataGrid"
  74. BasedOn="{StaticResource MaterialDesignDataGrid}">
  75. <Setter Property="Margin"
  76. Value="5" />
  77. <Setter Property="AutoGenerateColumns"
  78. Value="False" />
  79. <Setter Property="CanUserAddRows"
  80. Value="False" />
  81. <Setter Property="CanUserDeleteRows"
  82. Value="False" />
  83. <Setter Property="IsReadOnly"
  84. Value="True" />
  85. <Setter Property="AlternatingRowBackground"
  86. Value="#F5F5F5" />
  87. </Style>
  88. <Style x:Key="TitleStyle"
  89. TargetType="TextBlock">
  90. <Setter Property="FontSize"
  91. Value="16" />
  92. <Setter Property="FontWeight"
  93. Value="Bold" />
  94. <Setter Property="Margin"
  95. Value="0 10 0 5" />
  96. <Setter Property="Foreground"
  97. Value="#2C3E50" />
  98. </Style>
  99. </UserControl.Resources>
  100. <Grid>
  101. <Grid.ColumnDefinitions>
  102. <ColumnDefinition Width="2*" />
  103. <ColumnDefinition Width="3*" />
  104. </Grid.ColumnDefinitions>
  105. <!-- 左侧控制面板 -->
  106. <Border Grid.Column="0"
  107. BorderBrush="#BDC3C7"
  108. BorderThickness="0 0 1 0">
  109. <Grid>
  110. <Grid.RowDefinitions>
  111. <RowDefinition Height="Auto" />
  112. <RowDefinition Height="Auto" />
  113. <RowDefinition Height="*" />
  114. <RowDefinition Height="Auto" />
  115. </Grid.RowDefinitions>
  116. <!-- 测试设置区域 -->
  117. <Border Grid.Row="0"
  118. Background="#ECF0F1"
  119. Padding="10">
  120. <StackPanel>
  121. <TextBlock Style="{StaticResource TitleStyle}"
  122. Text="测试设置" />
  123. <Grid Margin="0 10 0 0">
  124. <Grid.ColumnDefinitions>
  125. <ColumnDefinition Width="Auto" />
  126. <ColumnDefinition Width="*" />
  127. <ColumnDefinition Width="Auto" />
  128. </Grid.ColumnDefinitions>
  129. <TextBlock Text="重复次数:"
  130. Grid.Column="0" />
  131. <mah:NumericUpDown Grid.Column="1"
  132. Value="{Binding RepeatCount, Mode=TwoWay}"
  133. Minimum="1"
  134. d:Value="10"
  135. TextAlignment="Center"
  136. HorizontalContentAlignment="Center"
  137. HorizontalAlignment="Stretch"
  138. IsEnabled="{Binding IsRunning,Converter={StaticResource InvertBooleanConverter}}" />
  139. <!--<Button x:Name="btnSetCount"
  140. Grid.Column="2"
  141. Content="设置"
  142. Width="60" />-->
  143. </Grid>
  144. <Separator Margin="0 15 0 10" />
  145. <!-- 控制按钮 -->
  146. <WrapPanel HorizontalAlignment="Center">
  147. <Button x:Name="btnStart"
  148. Content="开始测试"
  149. Background="#27AE60"
  150. Foreground="White"
  151. MinWidth="100"
  152. Height="35"
  153. FontWeight="Bold"
  154. Command="{Binding StartTestCommand}" />
  155. <Button x:Name="btnStop"
  156. Content="停止"
  157. Background="#E74C3C"
  158. Foreground="White"
  159. MinWidth="100"
  160. Height="35"
  161. d:IsEnabled="False"
  162. Command="{Binding StopTestCommand}" />
  163. <Button x:Name="btnPause"
  164. Content="暂停"
  165. Background="#F39C12"
  166. Foreground="White"
  167. MinWidth="100"
  168. Height="35"
  169. d:IsEnabled="False"
  170. Command="{Binding PauseTestCommand}" />
  171. </WrapPanel>
  172. </StackPanel>
  173. </Border>
  174. <!-- 进度显示 -->
  175. <Border Grid.Row="1"
  176. Background="#F8F9FA"
  177. Padding="10">
  178. <StackPanel>
  179. <TextBlock Style="{StaticResource TitleStyle}"
  180. Text="测试进度" />
  181. <Grid Margin="0 10 0 0">
  182. <Grid.RowDefinitions>
  183. <RowDefinition Height="Auto" />
  184. <RowDefinition Height="Auto" />
  185. </Grid.RowDefinitions>
  186. <ProgressBar Grid.Row="0"
  187. Height="25"
  188. Margin="5"
  189. Minimum="0"
  190. Maximum="{Binding RepeatCount,Mode=TwoWay}"
  191. Value="{Binding CurrentProgress,Mode=TwoWay}"
  192. IsEnabled="False"
  193. d:Maximum="100"
  194. d:Value="50" />
  195. <TextBlock Grid.Row="1"
  196. HorizontalAlignment="Center"
  197. FontSize="12"
  198. Foreground="#7F8C8D"
  199. d:Text="等待开始..."
  200. Text="{Binding Message}" />
  201. </Grid>
  202. <!-- 统计信息 -->
  203. <WrapPanel Margin="0 15 0 0"
  204. HorizontalAlignment="Center">
  205. <Border Background="#3498DB"
  206. Padding="10 5"
  207. Margin="5"
  208. CornerRadius="3">
  209. <StackPanel>
  210. <TextBlock Text="已完成"
  211. Foreground="White"
  212. FontSize="11" />
  213. <TextBlock x:Name="txtCompleted"
  214. Text="{Binding CurrentProgress}"
  215. d:Text="0"
  216. Foreground="White"
  217. FontSize="16"
  218. FontWeight="Bold"
  219. HorizontalAlignment="Center" />
  220. </StackPanel>
  221. </Border>
  222. <Border Background="#2ECC71"
  223. Padding="10 5"
  224. Margin="5"
  225. CornerRadius="3">
  226. <StackPanel>
  227. <TextBlock Text="成功率"
  228. Foreground="White"
  229. FontSize="11" />
  230. <TextBlock x:Name="txtSuccessRate"
  231. d:Text="0%"
  232. Text="{Binding SuccessRate, StringFormat={}{0:F2}%}"
  233. Foreground="White"
  234. FontSize="16"
  235. FontWeight="Bold"
  236. HorizontalAlignment="Center" />
  237. </StackPanel>
  238. </Border>
  239. <Border Background="#E74C3C"
  240. Padding="10 5"
  241. Margin="5"
  242. CornerRadius="3">
  243. <StackPanel>
  244. <TextBlock Text="失败数"
  245. Foreground="White"
  246. FontSize="11" />
  247. <TextBlock x:Name="txtFailedCount"
  248. d:Text="0"
  249. Text="{Binding FailCount}"
  250. Foreground="White"
  251. FontSize="16"
  252. FontWeight="Bold"
  253. HorizontalAlignment="Center" />
  254. </StackPanel>
  255. </Border>
  256. </WrapPanel>
  257. </StackPanel>
  258. </Border>
  259. <!-- 测试结果列表 -->
  260. <Border Grid.Row="2"
  261. Background="White"
  262. Padding="10">
  263. <Grid>
  264. <Grid.RowDefinitions>
  265. <RowDefinition Height="Auto" />
  266. <RowDefinition Height="*" />
  267. </Grid.RowDefinitions>
  268. <TextBlock Style="{StaticResource TitleStyle}"
  269. Text="测试结果列表" />
  270. <DataGrid x:Name="dgResults"
  271. Grid.Row="1"
  272. Style="{StaticResource DataGridStyle}"
  273. MaxHeight="300"
  274. AutoGenerateColumns="True"
  275. CanUserAddRows="False"
  276. IsReadOnly="True"
  277. ItemsSource="{Binding TestResult.DefaultView}"
  278. AutoGeneratingColumn="DataGrid_AutoGeneratingColumn" />
  279. </Grid>
  280. </Border>
  281. <!-- 导出按钮 -->
  282. <Border Grid.Row="3"
  283. Background="#ECF0F1"
  284. Padding="10">
  285. <StackPanel>
  286. <WrapPanel HorizontalAlignment="Right">
  287. <Button x:Name="btnExportCSV"
  288. Content="导出CSV"
  289. Background="#3498DB"
  290. Foreground="White"
  291. MinWidth="100"
  292. Command="{Binding ExportCSVCommand}" />
  293. <Button x:Name="btnExportReport"
  294. Content="生成报告"
  295. Background="#9B59B6"
  296. Foreground="White"
  297. MinWidth="100"
  298. Command="{Binding ExportReportCommand}" />
  299. <Button x:Name="btnClearData"
  300. Content="清空数据"
  301. Background="#95A5A6"
  302. Foreground="White"
  303. MinWidth="100"
  304. Command="{Binding ClearDataCommand}" />
  305. </WrapPanel>
  306. <!-- 精度统计 -->
  307. <Border Margin="0 10 0 0"
  308. Background="#F8F9FA"
  309. Padding="10"
  310. CornerRadius="5">
  311. <StackPanel>
  312. <StackPanel Orientation="Horizontal"
  313. Margin="0 0 0 5">
  314. <TextBlock Text="精度统计"
  315. FontWeight="Bold" />
  316. <ComboBox ItemsSource="{Binding ResultDataColumns}"
  317. SelectedItem="{Binding SelectedDataColumn, Mode=TwoWay}"
  318. Margin="5,0">
  319. <ComboBox.ItemTemplate>
  320. <DataTemplate>
  321. <TextBlock Text="{Binding ColumnName}" />
  322. </DataTemplate>
  323. </ComboBox.ItemTemplate>
  324. <b:Interaction.Triggers>
  325. <b:EventTrigger EventName="SelectionChanged">
  326. <b:InvokeCommandAction Command="{Binding SelectColumnCommand}"/>
  327. </b:EventTrigger>
  328. </b:Interaction.Triggers>
  329. </ComboBox>
  330. </StackPanel>
  331. <Grid>
  332. <Grid.ColumnDefinitions>
  333. <ColumnDefinition Width="*" />
  334. <ColumnDefinition Width="*" />
  335. </Grid.ColumnDefinitions>
  336. <StackPanel Grid.Column="0">
  337. <TextBlock Text="标准差:">
  338. <Run x:Name="runStdX"
  339. d:Text="0.000"
  340. Text="{Binding StabilityMetrics.StdDeviation,StringFormat={}{0:F3}}"
  341. Foreground="#2C3E50"
  342. FontWeight="Bold" />
  343. </TextBlock>
  344. <TextBlock Text="3σ范围:">
  345. <Run x:Name="runStdY"
  346. d:Text="±0.000"
  347. Text="{Binding StabilityMetrics.ThreeSigmaRange,StringFormat={}±{0:F3}}"
  348. Foreground="#2C3E50"
  349. FontWeight="Bold" />
  350. </TextBlock>
  351. </StackPanel>
  352. <StackPanel Grid.Column="1">
  353. <TextBlock Text="峰度:">
  354. <Run x:Name="runAvgDeviation"
  355. d:Text="0.000"
  356. Text="{Binding StabilityMetrics.Kurtosis,StringFormat={}{0:F3}}"
  357. Foreground="#2C3E50"
  358. FontWeight="Bold" />
  359. </TextBlock>
  360. <TextBlock Text="极差:">
  361. <Run x:Name="runMaxDeviation"
  362. d:Text="0.000"
  363. Text="{Binding StabilityMetrics.Range,StringFormat={}{0:F3}}"
  364. Foreground="#2C3E50"
  365. FontWeight="Bold" />
  366. </TextBlock>
  367. </StackPanel>
  368. </Grid>
  369. </StackPanel>
  370. </Border>
  371. </StackPanel>
  372. </Border>
  373. </Grid>
  374. </Border>
  375. <Grid Grid.Column="1">
  376. <Grid.RowDefinitions>
  377. <RowDefinition Height="*" />
  378. <RowDefinition Height="Auto" />
  379. </Grid.RowDefinitions>
  380. <!-- 右侧图像显示区域 -->
  381. <Border Grid.Column="1"
  382. Background="#2C3E50">
  383. <!-- 图像显示画布 -->
  384. <wf:WindowsFormsHost>
  385. <vp:CogRecordDisplay x:Name="display" />
  386. </wf:WindowsFormsHost>
  387. </Border>
  388. <StackPanel Grid.Row="3"
  389. Orientation="Horizontal"
  390. VerticalAlignment="Center"
  391. HorizontalAlignment="Right">
  392. <Button Height="30"
  393. MinWidth="100"
  394. Content="{lex:Loc 确定}"
  395. materialDesign:ButtonAssist.CornerRadius="10"
  396. ToolTip="{lex:Loc 确定}"
  397. Command="{Binding ConfirmCommand}" />
  398. <Button Height="30"
  399. Margin="10,0"
  400. MinWidth="100"
  401. materialDesign:ButtonAssist.CornerRadius="10"
  402. ToolTip="{lex:Loc 取消}"
  403. Content="{lex:Loc 取消}"
  404. Command="{Binding CancelCommand}" />
  405. </StackPanel>
  406. </Grid>
  407. <materialDesign:Snackbar Grid.ColumnSpan="2"
  408. Opacity="0.8"
  409. HorizontalContentAlignment="Center"
  410. FontSize="14"
  411. MessageQueue="{Binding MessageQueue}"
  412. VerticalAlignment="Bottom" />
  413. </Grid>
  414. </UserControl>