VisionStaticAccuracyAnalyzer.xaml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  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="False" />
  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. <ColumnDefinition Width="*" />
  129. </Grid.ColumnDefinitions>
  130. <TextBlock Text="重复次数:"
  131. Grid.Column="0" />
  132. <mah:NumericUpDown Grid.Column="1"
  133. Value="{Binding RepeatCount, Mode=TwoWay}"
  134. Minimum="1"
  135. d:Value="10"
  136. TextAlignment="Center"
  137. HorizontalContentAlignment="Center"
  138. HorizontalAlignment="Stretch"
  139. IsEnabled="{Binding IsRunning,Converter={StaticResource InvertBooleanConverter}}" />
  140. <TextBlock Text="延时时间(ms):"
  141. Grid.Column="2" />
  142. <mah:NumericUpDown Grid.Column="3"
  143. Value="{Binding DelayTime, Mode=TwoWay}"
  144. Minimum="50"
  145. d:Value="200"
  146. TextAlignment="Center"
  147. HorizontalContentAlignment="Center"
  148. HorizontalAlignment="Stretch"
  149. IsEnabled="{Binding IsRunning,Converter={StaticResource InvertBooleanConverter}}" />
  150. <!--<Button x:Name="btnSetCount"
  151. Grid.Column="2"
  152. Content="设置"
  153. Width="60" />-->
  154. </Grid>
  155. <Separator Margin="0 15 0 10" />
  156. <!-- 控制按钮 -->
  157. <WrapPanel HorizontalAlignment="Center">
  158. <Button x:Name="btnStart"
  159. Content="开始测试"
  160. Background="#27AE60"
  161. Foreground="White"
  162. MinWidth="100"
  163. Height="35"
  164. FontWeight="Bold"
  165. Command="{Binding StartTestCommand}" />
  166. <Button x:Name="btnStop"
  167. Content="停止"
  168. Background="#E74C3C"
  169. Foreground="White"
  170. MinWidth="100"
  171. Height="35"
  172. d:IsEnabled="False"
  173. Command="{Binding StopTestCommand}" />
  174. <Button x:Name="btnPause"
  175. Content="暂停"
  176. Background="#F39C12"
  177. Foreground="White"
  178. MinWidth="100"
  179. Height="35"
  180. d:IsEnabled="False"
  181. Command="{Binding PauseTestCommand}" />
  182. </WrapPanel>
  183. </StackPanel>
  184. </Border>
  185. <!-- 进度显示 -->
  186. <Border Grid.Row="1"
  187. Background="#F8F9FA"
  188. Padding="10">
  189. <StackPanel>
  190. <TextBlock Style="{StaticResource TitleStyle}"
  191. Text="测试进度" />
  192. <Grid Margin="0 10 0 0">
  193. <Grid.RowDefinitions>
  194. <RowDefinition Height="Auto" />
  195. <RowDefinition Height="Auto" />
  196. </Grid.RowDefinitions>
  197. <ProgressBar Grid.Row="0"
  198. Height="25"
  199. Margin="5"
  200. Minimum="0"
  201. Maximum="{Binding RepeatCount,Mode=TwoWay}"
  202. Value="{Binding CurrentProgress,Mode=TwoWay}"
  203. IsEnabled="False"
  204. d:Maximum="100"
  205. d:Value="50" />
  206. <TextBlock Grid.Row="1"
  207. HorizontalAlignment="Center"
  208. FontSize="12"
  209. Foreground="#7F8C8D"
  210. d:Text="等待开始..."
  211. Text="{Binding Message}" />
  212. </Grid>
  213. <!-- 统计信息 -->
  214. <WrapPanel Margin="0 15 0 0"
  215. HorizontalAlignment="Center">
  216. <Border Background="#3498DB"
  217. Padding="10 5"
  218. Margin="5"
  219. CornerRadius="3">
  220. <StackPanel>
  221. <TextBlock Text="已完成"
  222. Foreground="White"
  223. FontSize="11" />
  224. <TextBlock x:Name="txtCompleted"
  225. Text="{Binding CurrentProgress}"
  226. d:Text="0"
  227. Foreground="White"
  228. FontSize="16"
  229. FontWeight="Bold"
  230. HorizontalAlignment="Center" />
  231. </StackPanel>
  232. </Border>
  233. <Border Background="#2ECC71"
  234. Padding="10 5"
  235. Margin="5"
  236. CornerRadius="3">
  237. <StackPanel>
  238. <TextBlock Text="成功率"
  239. Foreground="White"
  240. FontSize="11" />
  241. <TextBlock x:Name="txtSuccessRate"
  242. d:Text="0%"
  243. Text="{Binding SuccessRate, StringFormat={}{0:F2}%}"
  244. Foreground="White"
  245. FontSize="16"
  246. FontWeight="Bold"
  247. HorizontalAlignment="Center" />
  248. </StackPanel>
  249. </Border>
  250. <Border Background="#E74C3C"
  251. Padding="10 5"
  252. Margin="5"
  253. CornerRadius="3">
  254. <StackPanel>
  255. <TextBlock Text="失败数"
  256. Foreground="White"
  257. FontSize="11" />
  258. <TextBlock x:Name="txtFailedCount"
  259. d:Text="0"
  260. Text="{Binding FailCount}"
  261. Foreground="White"
  262. FontSize="16"
  263. FontWeight="Bold"
  264. HorizontalAlignment="Center" />
  265. </StackPanel>
  266. </Border>
  267. </WrapPanel>
  268. </StackPanel>
  269. </Border>
  270. <!-- 测试结果列表 -->
  271. <Border Grid.Row="2"
  272. Background="White"
  273. Padding="10">
  274. <Grid>
  275. <Grid.RowDefinitions>
  276. <RowDefinition Height="Auto" />
  277. <RowDefinition Height="*" />
  278. </Grid.RowDefinitions>
  279. <TextBlock Style="{StaticResource TitleStyle}"
  280. Text="测试结果列表" />
  281. <DataGrid x:Name="dgResults"
  282. Grid.Row="1"
  283. Style="{StaticResource DataGridStyle}"
  284. MaxHeight="300"
  285. AutoGenerateColumns="True"
  286. CanUserAddRows="False"
  287. IsReadOnly="True"
  288. ItemsSource="{Binding TestResult.DefaultView}"
  289. AutoGeneratingColumn="DataGrid_AutoGeneratingColumn" />
  290. </Grid>
  291. </Border>
  292. <!-- 导出按钮 -->
  293. <Border Grid.Row="3"
  294. Background="#ECF0F1"
  295. Padding="10">
  296. <StackPanel>
  297. <WrapPanel HorizontalAlignment="Right">
  298. <Button x:Name="btnExportCSV"
  299. Content="导出CSV"
  300. Background="#3498DB"
  301. Foreground="White"
  302. MinWidth="100"
  303. Command="{Binding ExportCSVCommand}" />
  304. <Button x:Name="btnExportReport"
  305. Content="生成报告"
  306. Background="#9B59B6"
  307. Foreground="White"
  308. MinWidth="100"
  309. Command="{Binding ExportReportCommand}" />
  310. <Button x:Name="btnClearData"
  311. Content="清空数据"
  312. Background="#95A5A6"
  313. Foreground="White"
  314. MinWidth="100"
  315. Command="{Binding ClearDataCommand}" />
  316. </WrapPanel>
  317. <!-- 精度统计 -->
  318. <Border Margin="0 10 0 0"
  319. Background="#F8F9FA"
  320. Padding="10"
  321. CornerRadius="5">
  322. <StackPanel>
  323. <StackPanel Orientation="Horizontal"
  324. Margin="0 0 0 5">
  325. <TextBlock Text="精度统计"
  326. FontWeight="Bold" />
  327. <ComboBox ItemsSource="{Binding ResultDataColumns}"
  328. SelectedItem="{Binding SelectedDataColumn, Mode=TwoWay}"
  329. Margin="5,0">
  330. <ComboBox.ItemTemplate>
  331. <DataTemplate>
  332. <TextBlock Text="{Binding ColumnName}" />
  333. </DataTemplate>
  334. </ComboBox.ItemTemplate>
  335. <b:Interaction.Triggers>
  336. <b:EventTrigger EventName="SelectionChanged">
  337. <b:InvokeCommandAction Command="{Binding SelectColumnCommand}"/>
  338. </b:EventTrigger>
  339. </b:Interaction.Triggers>
  340. </ComboBox>
  341. </StackPanel>
  342. <Grid>
  343. <Grid.ColumnDefinitions>
  344. <ColumnDefinition Width="*" />
  345. <ColumnDefinition Width="*" />
  346. </Grid.ColumnDefinitions>
  347. <StackPanel Grid.Column="0">
  348. <TextBlock Text="标准差:">
  349. <Run x:Name="runStdX"
  350. d:Text="0.000"
  351. Text="{Binding StabilityMetrics.StdDeviation,StringFormat={}{0:F3}}"
  352. Foreground="#2C3E50"
  353. FontWeight="Bold" />
  354. </TextBlock>
  355. <TextBlock Text="3σ范围:">
  356. <Run x:Name="runStdY"
  357. d:Text="±0.000"
  358. Text="{Binding StabilityMetrics.ThreeSigmaRange,StringFormat={}±{0:F3}}"
  359. Foreground="#2C3E50"
  360. FontWeight="Bold" />
  361. </TextBlock>
  362. </StackPanel>
  363. <StackPanel Grid.Column="1">
  364. <TextBlock Text="峰度:">
  365. <Run x:Name="runAvgDeviation"
  366. d:Text="0.000"
  367. Text="{Binding StabilityMetrics.Kurtosis,StringFormat={}{0:F3}}"
  368. Foreground="#2C3E50"
  369. FontWeight="Bold" />
  370. </TextBlock>
  371. <TextBlock Text="极差:">
  372. <Run x:Name="runMaxDeviation"
  373. d:Text="0.000"
  374. Text="{Binding StabilityMetrics.Range,StringFormat={}{0:F3}}"
  375. Foreground="#2C3E50"
  376. FontWeight="Bold" />
  377. </TextBlock>
  378. </StackPanel>
  379. </Grid>
  380. </StackPanel>
  381. </Border>
  382. </StackPanel>
  383. </Border>
  384. </Grid>
  385. </Border>
  386. <Grid Grid.Column="1">
  387. <Grid.RowDefinitions>
  388. <RowDefinition Height="*" />
  389. <RowDefinition Height="Auto" />
  390. </Grid.RowDefinitions>
  391. <!-- 右侧图像显示区域 -->
  392. <Border Grid.Column="1"
  393. Background="#2C3E50">
  394. <!-- 图像显示画布 -->
  395. <wf:WindowsFormsHost>
  396. <vp:CogRecordDisplay x:Name="display" />
  397. </wf:WindowsFormsHost>
  398. </Border>
  399. <StackPanel Grid.Row="3"
  400. Orientation="Horizontal"
  401. VerticalAlignment="Center"
  402. HorizontalAlignment="Right">
  403. <Button Height="30"
  404. MinWidth="100"
  405. Content="{lex:Loc 确定}"
  406. materialDesign:ButtonAssist.CornerRadius="10"
  407. ToolTip="{lex:Loc 确定}"
  408. Command="{Binding ConfirmCommand}" />
  409. <Button Height="30"
  410. Margin="10,0"
  411. MinWidth="100"
  412. materialDesign:ButtonAssist.CornerRadius="10"
  413. ToolTip="{lex:Loc 取消}"
  414. Content="{lex:Loc 取消}"
  415. Command="{Binding CancelCommand}" />
  416. </StackPanel>
  417. </Grid>
  418. <materialDesign:Snackbar Grid.ColumnSpan="2"
  419. Opacity="0.8"
  420. HorizontalContentAlignment="Center"
  421. FontSize="14"
  422. MessageQueue="{Binding MessageQueue}"
  423. VerticalAlignment="Bottom" />
  424. </Grid>
  425. </UserControl>