VisionStaticAccuracyAnalyzer.xaml 20 KB

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