CameraParams.xaml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <UserControl x:Class="TeamAAS_VP.Views.Product.CameraParams"
  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:d="http://schemas.microsoft.com/expression/blend/2008"
  9. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  10. xmlns:vm="clr-namespace:TeamAAS_VP.ViewModels.Product"
  11. xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
  12. xmlns:sys="clr-namespace:System;assembly=mscorlib"
  13. xmlns:uControl="clr-namespace:TeamAAS_VP.Controls"
  14. xmlns:localbehaviors="clr-namespace:TeamAAS_VP.Behaviors"
  15. xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
  16. xmlns:lex="http://wpflocalizeextension.codeplex.com"
  17. lex:LocalizeDictionary.DesignCulture="zh-CN"
  18. lex:ResxLocalizationProvider.DefaultAssembly="TeamAAS-VP"
  19. lex:ResxLocalizationProvider.DefaultDictionary="Lang"
  20. prism:ViewModelLocator.AutoWireViewModel="True"
  21. mc:Ignorable="d"
  22. d:DataContext="{d:DesignInstance Type=vm:CameraParamsViewModel}"
  23. d:Height="600"
  24. d:Width="1024"
  25. d:Background="White"
  26. FontFamily="{DynamicResource DefaultFont}">
  27. <b:Interaction.Triggers>
  28. <b:EventTrigger EventName="Loaded">
  29. <b:InvokeCommandAction Command="{Binding LoadedCommand}" />
  30. </b:EventTrigger>
  31. </b:Interaction.Triggers>
  32. <Grid>
  33. <Grid.RowDefinitions>
  34. <RowDefinition Height="auto" />
  35. <RowDefinition Height="*" />
  36. <RowDefinition Height="auto" />
  37. </Grid.RowDefinitions>
  38. <Button Grid.Row="0"
  39. Content="{materialDesign:PackIcon Kind=ArrowLeftCircle}"
  40. Width="50"
  41. HorizontalAlignment="Left"
  42. VerticalAlignment="Top"
  43. ToolTip="{lex:Loc 返回}"
  44. Style="{StaticResource MaterialDesignIconButton}"
  45. Command="{Binding BackCommand}" />
  46. <StackPanel Grid.Row="0"
  47. Orientation="Horizontal"
  48. Margin="50,0"
  49. VerticalAlignment="Center">
  50. <materialDesign:PackIcon Kind="CubeOutline"
  51. Width="30"
  52. Height="30" />
  53. <TextBlock Text="{Binding SelectProduct.Name}"
  54. VerticalAlignment="Center" />
  55. <TextBlock Text="{lex:Loc 图像源配置,Converter={StaticResource StringFormatConverter},ConverterParameter=' - {0}'}"
  56. VerticalAlignment="Center" />
  57. </StackPanel>
  58. <Border BorderThickness="1,1,1,1"
  59. VerticalAlignment="Bottom"
  60. Height="1">
  61. <Border.BorderBrush>
  62. <VisualBrush>
  63. <VisualBrush.Visual>
  64. <Rectangle StrokeDashArray="4 4"
  65. Stroke="LightGray"
  66. StrokeThickness="1"
  67. Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualWidth}"
  68. Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Border}}, Path=ActualHeight}" />
  69. </VisualBrush.Visual>
  70. </VisualBrush>
  71. </Border.BorderBrush>
  72. </Border>
  73. <materialDesign:DrawerHost Grid.Row="1"
  74. OpenMode="Standard"
  75. x:Name="DrawerHost"
  76. d:IsRightDrawerOpen="true"
  77. IsEnabled="{Binding IsAllowEdit}">
  78. <materialDesign:DrawerHost.RightDrawerContent>
  79. <uControl:PlcRobotManual x:Name="robotManual"
  80. Visibility="{Binding IsHaveRobot,Converter={StaticResource BooleanToVisibilityConverter}}" />
  81. </materialDesign:DrawerHost.RightDrawerContent>
  82. <Grid>
  83. <Grid.ColumnDefinitions>
  84. <ColumnDefinition Width="auto" />
  85. <ColumnDefinition Width="*" />
  86. </Grid.ColumnDefinitions>
  87. <Expander Grid.Column="0"
  88. ExpandDirection="Right"
  89. Background="Transparent">
  90. <Expander.Header>
  91. <TextBlock RenderTransformOrigin=".5,.5"
  92. Text="Navigation Description">
  93. <TextBlock.LayoutTransform>
  94. <RotateTransform Angle="90" />
  95. </TextBlock.LayoutTransform>
  96. </TextBlock>
  97. </Expander.Header>
  98. <ScrollViewer>
  99. <StackPanel Margin="8,24,16,24"
  100. Orientation="Vertical">
  101. <Image Source="pack://application:,,,/TeamAAS-VP;component/Resources/Images/4图像采集.png"
  102. Stretch="Uniform"
  103. Width="350"
  104. HorizontalAlignment="Center"
  105. VerticalAlignment="Top" />
  106. <TextBlock Text="{lex:Loc 图像源配置}" />
  107. <TextBlock Foreground="Gray"
  108. TextWrapping="Wrap"
  109. Text="{lex:Loc 图像源配置描述}" />
  110. </StackPanel>
  111. </ScrollViewer>
  112. </Expander>
  113. <Grid Grid.Column="1">
  114. <Grid.ColumnDefinitions>
  115. <ColumnDefinition Width="*" />
  116. <ColumnDefinition Width="auto" />
  117. </Grid.ColumnDefinitions>
  118. <Grid Grid.Column="1">
  119. <Grid.RowDefinitions>
  120. <RowDefinition Height="auto" />
  121. <RowDefinition Height="auto" />
  122. <RowDefinition Height="auto" />
  123. <RowDefinition Height="auto" />
  124. <RowDefinition Height="auto" />
  125. </Grid.RowDefinitions>
  126. <Grid.ColumnDefinitions>
  127. <ColumnDefinition Width="auto" />
  128. <ColumnDefinition Width="*" />
  129. </Grid.ColumnDefinitions>
  130. <ToggleButton Grid.Column="1"
  131. HorizontalAlignment="Right"
  132. VerticalAlignment="Top"
  133. Visibility="{Binding IsHaveRobot,Converter={StaticResource BooleanToVisibilityConverter}}"
  134. materialDesign:ToggleButtonAssist.OnContent="{materialDesign:PackIcon Kind=ArrowRight}"
  135. Content="{materialDesign:PackIcon Kind=RobotIndustrial}"
  136. Style="{StaticResource MaterialDesignActionToggleButton}"
  137. ToolTip="{lex:Loc 机器人步进}"
  138. Margin="5,0"
  139. IsChecked="{Binding IsRightDrawerOpen,ElementName=DrawerHost}" />
  140. <TextBlock Text="{lex:Loc 相机参数设置}"
  141. Grid.Row="1"
  142. FontWeight="Bold"
  143. Margin="10"
  144. Grid.ColumnSpan="2" />
  145. <TextBlock Grid.Row="2"
  146. Grid.Column="0"
  147. Margin="5"
  148. VerticalAlignment="Center"
  149. Text="{lex:Loc 曝光时间,Converter={StaticResource StringFormatConverter},ConverterParameter='{}{0}: '}" />
  150. <mah:NumericUpDown Grid.Row="2"
  151. Grid.Column="1"
  152. Margin="5"
  153. Minimum="35"
  154. Maximum="999985"
  155. Interval="35"
  156. StringFormat="{}{0:N0} us"
  157. Value="{Binding ExposureTime,Mode=TwoWay}" />
  158. <TextBlock Grid.Row="3"
  159. Grid.Column="0"
  160. Margin="5"
  161. VerticalAlignment="Center"
  162. Text="{lex:Loc 增益,Converter={StaticResource StringFormatConverter},ConverterParameter='{}{0}: '}" />
  163. <mah:NumericUpDown Grid.Row="3"
  164. Grid.Column="1"
  165. Margin="5"
  166. Minimum="0"
  167. Maximum="63"
  168. Interval="1"
  169. StringFormat="{}{0:N2} db"
  170. Value="{Binding Gain,Mode=TwoWay}" />
  171. <!-- 光源通道列表与调节 -->
  172. <StackPanel Orientation="Vertical"
  173. Grid.Row="4"
  174. Grid.ColumnSpan="2"
  175. Margin="5" >
  176. <TextBlock Text="{lex:Loc 光源通道列表}"
  177. FontWeight="Bold" />
  178. <ItemsControl ItemsSource="{Binding SelectProcedure.LightChannels}">
  179. <ItemsControl.ItemTemplate>
  180. <DataTemplate>
  181. <Grid>
  182. <Grid.RowDefinitions>
  183. <RowDefinition Height="auto" />
  184. <RowDefinition Height="auto" />
  185. <RowDefinition Height="auto" />
  186. </Grid.RowDefinitions>
  187. <TextBlock Width="120"
  188. Grid.Row="0"
  189. HorizontalAlignment="Left"
  190. VerticalAlignment="Center">
  191. <TextBlock.Text>
  192. <MultiBinding StringFormat="{}{0} . {1}">
  193. <Binding Path="GlobalIndex" />
  194. <Binding Path="Name" />
  195. </MultiBinding>
  196. </TextBlock.Text>
  197. </TextBlock>
  198. <StackPanel Grid.Row="1"
  199. Orientation="Horizontal"
  200. Margin="0,4">
  201. <Slider Minimum="0"
  202. Maximum="255"
  203. Width="200"
  204. Value="{Binding DefaultBrightness,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
  205. <b:Interaction.Behaviors>
  206. <localbehaviors:SliderUserInteractionBehavior UserInteractionCommand="{Binding DataContext.SetChannelBrightnessCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
  207. CommandParameter="{Binding}" />
  208. </b:Interaction.Behaviors>
  209. </Slider>
  210. <TextBlock Text="{Binding DefaultBrightness}"
  211. Width="40"
  212. VerticalAlignment="Center"
  213. Margin="6,0" />
  214. </StackPanel>
  215. <StackPanel Grid.Row="2"
  216. Orientation="Horizontal"
  217. HorizontalAlignment="Right"
  218. Margin="0,4">
  219. <Button Content="{lex:Loc 打开}"
  220. Command="{Binding DataContext.TurnOnCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
  221. CommandParameter="{Binding}"
  222. Margin="0,0,8,0" />
  223. <Button Content="{lex:Loc 关闭}"
  224. Command="{Binding DataContext.TurnOffCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
  225. CommandParameter="{Binding}"
  226. Margin="0,0,8,0" />
  227. </StackPanel>
  228. </Grid>
  229. </DataTemplate>
  230. </ItemsControl.ItemTemplate>
  231. </ItemsControl>
  232. </StackPanel>
  233. </Grid>
  234. <wf:WindowsFormsHost Grid.Column="0"
  235. Margin="0,40">
  236. <vp:CogRecordDisplay x:Name="display" />
  237. </wf:WindowsFormsHost>
  238. <StackPanel Orientation="Horizontal"
  239. Grid.Column="0"
  240. Margin="5"
  241. Visibility="{Binding IsHaveFeeder,Converter={StaticResource BooleanToVisibilityConverter}}"
  242. VerticalAlignment="Top">
  243. <TextBlock Text="{lex:Loc 光源亮度,Converter={StaticResource StringFormatConverter},ConverterParameter='{}{0}: '}"
  244. Margin="5,0"
  245. VerticalAlignment="Center" />
  246. <Button Width="25"
  247. Height="25"
  248. Margin="5,0"
  249. Content="{materialDesign:PackIcon Kind=Minus}"
  250. Style="{StaticResource MaterialDesignIconForegroundButton}"
  251. Command="{Binding LightValueSubCommand}" />
  252. <Slider x:Name="lightSlider"
  253. Maximum="100"
  254. Minimum="1"
  255. Width="100"
  256. Value="{Binding SelectProcedure.LightValue}"
  257. Height="20"
  258. VerticalAlignment="Center">
  259. <b:Interaction.Triggers>
  260. <b:EventTrigger EventName="ValueChanged">
  261. <b:InvokeCommandAction Command="{Binding LightValueChangedCommand}"
  262. CommandParameter="{Binding ElementName=lightSlider,Path=Value}" />
  263. </b:EventTrigger>
  264. </b:Interaction.Triggers>
  265. </Slider>
  266. <Button Width="25"
  267. Height="25"
  268. Margin="5,0"
  269. Content="{materialDesign:PackIcon Kind=Plus}"
  270. Style="{StaticResource MaterialDesignIconForegroundButton}"
  271. Command="{Binding LightValueAddCommand}" />
  272. <TextBlock Text="{Binding ElementName=lightSlider,Path=Value,Mode=TwoWay,StringFormat={}{0:F0}}"
  273. VerticalAlignment="Center" />
  274. </StackPanel>
  275. <StackPanel Grid.Column="0"
  276. HorizontalAlignment="Left"
  277. VerticalAlignment="Bottom"
  278. Orientation="Horizontal">
  279. <Button Grid.Column="0"
  280. Content="{lex:Loc 开始采集}"
  281. IsEnabled="{Binding IsAllowEdit}"
  282. MinWidth="100"
  283. materialDesign:ButtonAssist.CornerRadius="10"
  284. Style="{StaticResource MaterialDesignRaisedButton}"
  285. Command="{Binding StartGrabbingCommand}" />
  286. <Button Grid.Column="0"
  287. Content="{lex:Loc 停止采集}"
  288. IsEnabled="{Binding IsAllowEdit}"
  289. MinWidth="100"
  290. Margin="10,0"
  291. materialDesign:ButtonAssist.CornerRadius="10"
  292. Style="{StaticResource MaterialDesignRaisedButton}"
  293. Command="{Binding StopGrabbingCommand}" />
  294. <TextBlock Text="{Binding Message}"
  295. VerticalAlignment="Center"
  296. Foreground="Gray" />
  297. </StackPanel>
  298. </Grid>
  299. </Grid>
  300. </materialDesign:DrawerHost>
  301. <StackPanel Grid.Row="2"
  302. Orientation="Horizontal"
  303. HorizontalAlignment="Center"
  304. VerticalAlignment="Center"
  305. Margin="20">
  306. <Button Content="{lex:Loc 下一步}"
  307. IsEnabled="{Binding IsAllowEdit}"
  308. MinWidth="100"
  309. HorizontalAlignment="Center"
  310. VerticalAlignment="Center"
  311. materialDesign:ButtonAssist.CornerRadius="10"
  312. Style="{StaticResource MaterialDesignRaisedButton}"
  313. Command="{Binding NextCommand}" />
  314. </StackPanel>
  315. </Grid>
  316. </UserControl>