SystemConfigView.xaml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. <UserControl x:Class="CyberX8_MainPages.Views.SystemConfigView"
  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:CyberX8_MainPages.Views"
  7. xmlns:systemConfig="clr-namespace:CyberX8_MainPages.Unity"
  8. xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
  9. xmlns:ctrl="http://OpenSEMI.Ctrlib.com/presentation"
  10. xmlns:prism="http://prismlibrary.com/"
  11. xmlns:converters="clr-namespace:CyberX8_Themes.Converters;assembly=CyberX8_Themes"
  12. prism:ViewModelLocator.AutoWireViewModel="True"
  13. mc:Ignorable="d"
  14. d:DesignHeight="450" d:DesignWidth="800" x:Name="sysconfigView">
  15. <UserControl.Resources>
  16. <converters:Null2Bool x:Key="Null2Bool"/>
  17. <converters:Bool2Not x:Key="Bool2Not"/>
  18. <converters:Float2String x:Key="Float2String"/>
  19. <converters:String2Double x:Key="String2Double"/>
  20. <converters:BoolToVisibility2 x:Key="BoolToVisibility2"/>
  21. <HierarchicalDataTemplate x:Key="ConfigNodeTemplate" DataType="{x:Type systemConfig:ConfigNode}" ItemsSource="{Binding SubNodes}">
  22. <TextBlock Text="{Binding Name}" VerticalAlignment="Center">
  23. </TextBlock>
  24. </HierarchicalDataTemplate>
  25. <systemConfig:ConfigValueTemplateSelector x:Key="ConfigValueTemplateSelector">
  26. <systemConfig:ConfigValueTemplateSelector.BoolTemplate>
  27. <DataTemplate>
  28. <StackPanel Orientation="Horizontal" Margin="10,0">
  29. <RadioButton Content="true" VerticalAlignment="Center" IsChecked="{Binding BoolValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
  30. <RadioButton Content="false" VerticalAlignment="Center" Margin="10,0,0,0" IsChecked="{Binding BoolValue, Mode=TwoWay, Converter={StaticResource Bool2Not}, UpdateSourceTrigger=PropertyChanged}"/>
  31. </StackPanel>
  32. </DataTemplate>
  33. </systemConfig:ConfigValueTemplateSelector.BoolTemplate>
  34. <systemConfig:ConfigValueTemplateSelector.StringTemplate>
  35. <DataTemplate>
  36. <Grid Width="190">
  37. <ctrl:TextBoxEx Text="{Binding StringValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextSaved="{Binding TextSaved, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
  38. </Grid>
  39. </DataTemplate>
  40. </systemConfig:ConfigValueTemplateSelector.StringTemplate>
  41. <systemConfig:ConfigValueTemplateSelector.NumbericTemplate>
  42. <DataTemplate>
  43. <Grid Width="190">
  44. <TextBox Width="160" HorizontalAlignment="Center" Text="{Binding CurValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" >
  45. <TextBox.Style>
  46. <Style TargetType="TextBox" >
  47. <Setter Property="ToolTip" Value="{x:Null}"/>
  48. <Style.Triggers>
  49. <DataTrigger Binding="{Binding RangeFrom, Converter={StaticResource Null2Bool}}" Value="False">
  50. <Setter Property="ToolTip">
  51. <Setter.Value>
  52. <TextBlock>
  53. <Run Text="Range: "/>
  54. <Run Text="{Binding Max}"/>
  55. <Run Text="~"/>
  56. <Run Text="{Binding Min}"/>
  57. </TextBlock>
  58. </Setter.Value>
  59. </Setter>
  60. <!--<Setter Property="MinValue" Value="{Binding RangeFrom, Converter={StaticResource String2Double}}"/>
  61. <Setter Property="MaxValue" Value="{Binding RangeTo, Converter={StaticResource String2Double}}"/>-->
  62. </DataTrigger>
  63. <!--<DataTrigger Binding="{Binding Type}" Value="Int">
  64. <Setter Property="EditBoxMode" Value="SignInteger"/>
  65. </DataTrigger>
  66. <DataTrigger Binding="{Binding Type}" Value="Float">
  67. <Setter Property="EditBoxMode" Value="Decimal"/>
  68. </DataTrigger>-->
  69. </Style.Triggers>
  70. </Style>
  71. </TextBox.Style>
  72. </TextBox>
  73. </Grid>
  74. </DataTemplate>
  75. </systemConfig:ConfigValueTemplateSelector.NumbericTemplate>
  76. <systemConfig:ConfigValueTemplateSelector.EnumTemplate>
  77. <DataTemplate>
  78. <Grid Width="190">
  79. <ComboBox ItemsSource="{Binding Options}" SelectedValuePath="Value" SelectedValue="{Binding CurValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="160" HorizontalAlignment="Center">
  80. <ComboBox.ItemTemplate>
  81. <DataTemplate>
  82. <TextBlock Text="{Binding Name}" VerticalAlignment="Center"/>
  83. </DataTemplate>
  84. </ComboBox.ItemTemplate>
  85. </ComboBox>
  86. </Grid>
  87. </DataTemplate>
  88. </systemConfig:ConfigValueTemplateSelector.EnumTemplate>
  89. </systemConfig:ConfigValueTemplateSelector>
  90. </UserControl.Resources>
  91. <Grid>
  92. <Grid.ColumnDefinitions>
  93. <ColumnDefinition MinWidth="300" Width="Auto"/>
  94. <ColumnDefinition Width="Auto"/>
  95. <ColumnDefinition MinWidth="200"/>
  96. </Grid.ColumnDefinitions>
  97. <Border BorderBrush="{DynamicResource Table_BD}" BorderThickness="1" Background="{DynamicResource Table_BG_Content}" Padding="5,1">
  98. <TreeView x:Name="PART_TREE" Margin="5" ItemsSource="{Binding ConfigNodes}" ItemTemplate="{StaticResource ConfigNodeTemplate}"
  99. VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"
  100. Height="{Binding Path=ActualHeight,ElementName=PART_BORDER, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}">
  101. <!--Height should add for VirtualizingPanel, otherwise the App will be slow-->
  102. <TreeView.ItemContainerStyle>
  103. <Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource ResourceKey={x:Type TreeViewItem}}">
  104. <Setter Property="IsExpanded" Value="True"></Setter>
  105. <Setter Property="Visibility" Value="{Binding IsShow,Converter={StaticResource BoolToVisibility2}}"></Setter>
  106. </Style>
  107. </TreeView.ItemContainerStyle>
  108. <i:Interaction.Triggers>
  109. <i:EventTrigger EventName="SelectedItemChanged">
  110. <i:InvokeCommandAction Command="{Binding TreeViewSelectedItemChangedCmd}" CommandParameter="{Binding Path=SelectedItem, ElementName=PART_TREE}"/>
  111. </i:EventTrigger>
  112. </i:Interaction.Triggers>
  113. </TreeView>
  114. </Border>
  115. <GridSplitter Width="5" Grid.Column="1" HorizontalAlignment="Left" Background="Transparent">
  116. </GridSplitter>
  117. <Grid Grid.Column="1" Margin="10,0,0,0">
  118. <Grid.RowDefinitions>
  119. <RowDefinition Height="Auto"/>
  120. <RowDefinition />
  121. </Grid.RowDefinitions>
  122. <StackPanel Orientation="Horizontal">
  123. <Button Content="Reload" Width="80" Height="25" Command="{Binding ReloadCommand}">
  124. </Button>
  125. <Button Content="Save All" Width="80" Height="25" Margin="5,0,0,0" Command="{Binding SaveAllCommand}">
  126. </Button>
  127. </StackPanel>
  128. <DataGrid Grid.Row="1" AlternationCount="2" HorizontalAlignment="Left" CanUserAddRows="False" AutoGenerateColumns="False" RowHeaderWidth="0"
  129. VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"
  130. ItemsSource="{Binding ConfigItems}" Margin="0,5,0,0">
  131. <DataGrid.Columns>
  132. <DataGridTemplateColumn Header="Config Item" MinWidth="500">
  133. <DataGridTemplateColumn.CellTemplate>
  134. <DataTemplate>
  135. <TextBlock Text="{Binding Name}" Margin="5,0" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" Width="500">
  136. <TextBlock.ToolTip>
  137. <ToolTip>
  138. <ToolTip.Content>
  139. <Grid>
  140. <Grid.ColumnDefinitions>
  141. <ColumnDefinition Width="100"/>
  142. <ColumnDefinition Width="300"/>
  143. </Grid.ColumnDefinitions>
  144. <Grid.RowDefinitions>
  145. <RowDefinition Height="25"/>
  146. <RowDefinition Height="25"/>
  147. <RowDefinition Height="25"/>
  148. <RowDefinition Height="50"/>
  149. </Grid.RowDefinitions>
  150. <TextBlock Grid.Column="0" Grid.Row="0" Text="Name" VerticalAlignment="Center"></TextBlock>
  151. <TextBlock Grid.Column="1" Grid.Row="0" TextWrapping="Wrap" Text="{Binding Name}" VerticalAlignment="Center"></TextBlock>
  152. <TextBlock Grid.Column="0" Grid.Row="1" Text="Type" VerticalAlignment="Center"></TextBlock>
  153. <TextBlock Grid.Column="1" Grid.Row="1" TextWrapping="Wrap" Text="{Binding Type}" VerticalAlignment="Center"></TextBlock>
  154. <TextBlock Grid.Column="0" Grid.Row="2" Text="Default Value" VerticalAlignment="Center"></TextBlock>
  155. <TextBlock Grid.Column="1" Grid.Row="2" TextWrapping="Wrap" Text="{Binding DefaultValue}" VerticalAlignment="Center"></TextBlock>
  156. <TextBlock Grid.Column="0" Grid.Row="3" Text="Description" VerticalAlignment="Center"></TextBlock>
  157. <TextBlock Grid.Column="1" Grid.Row="3" TextWrapping="Wrap" Text="{Binding Description}" VerticalAlignment="Center"></TextBlock>
  158. </Grid>
  159. </ToolTip.Content>
  160. </ToolTip>
  161. </TextBlock.ToolTip>
  162. </TextBlock>
  163. </DataTemplate>
  164. </DataGridTemplateColumn.CellTemplate>
  165. </DataGridTemplateColumn>
  166. <DataGridTemplateColumn Header="Unit" MinWidth="80">
  167. <DataGridTemplateColumn.CellTemplate>
  168. <DataTemplate>
  169. <TextBlock Text="{Binding Unit}" Margin="5,0" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Text}"/>
  170. </DataTemplate>
  171. </DataGridTemplateColumn.CellTemplate>
  172. </DataGridTemplateColumn>
  173. <DataGridTemplateColumn Header="Min" MinWidth="80">
  174. <DataGridTemplateColumn.CellTemplate>
  175. <DataTemplate>
  176. <TextBlock Text="{Binding Min, Converter={StaticResource Float2String}}" Margin="5,0" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Text}"/>
  177. </DataTemplate>
  178. </DataGridTemplateColumn.CellTemplate>
  179. </DataGridTemplateColumn>
  180. <DataGridTemplateColumn Header="Max" MinWidth="80">
  181. <DataGridTemplateColumn.CellTemplate>
  182. <DataTemplate>
  183. <TextBlock Text="{Binding Max, Converter={StaticResource Float2String}}" Margin="5,0" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Text}"/>
  184. </DataTemplate>
  185. </DataGridTemplateColumn.CellTemplate>
  186. </DataGridTemplateColumn>
  187. <DataGridTemplateColumn Header="Value" MinWidth="80">
  188. <DataGridTemplateColumn.CellTemplate>
  189. <DataTemplate>
  190. <TextBlock Text="{Binding CurrentValue}" Margin="5,0" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Text}"/>
  191. </DataTemplate>
  192. </DataGridTemplateColumn.CellTemplate>
  193. </DataGridTemplateColumn>
  194. <DataGridTemplateColumn Header="Setpoint" CellTemplateSelector="{StaticResource ConfigValueTemplateSelector}" MinWidth="100"/>
  195. <DataGridTemplateColumn MinWidth="80">
  196. <DataGridTemplateColumn.CellTemplate>
  197. <DataTemplate>
  198. <Button Content="Set" Width="60" Height="20" FontSize="12" Command="{Binding ElementName=sysconfigView, Path=DataContext.SetValueCommand}" CommandParameter="{Binding }">
  199. </Button>
  200. </DataTemplate>
  201. </DataGridTemplateColumn.CellTemplate>
  202. </DataGridTemplateColumn>
  203. </DataGrid.Columns>
  204. </DataGrid>
  205. </Grid>
  206. <Grid Grid.Column="2" Margin="5,0,0,0">
  207. <Grid.ColumnDefinitions>
  208. <ColumnDefinition Width="50"/>
  209. <ColumnDefinition Width="auto"/>
  210. <ColumnDefinition Width="auto"/>
  211. <ColumnDefinition Width="*" />
  212. </Grid.ColumnDefinitions>
  213. <Grid.RowDefinitions>
  214. <RowDefinition Height="auto"/>
  215. <RowDefinition Height="auto"/>
  216. </Grid.RowDefinitions>
  217. <!--<TextBlock Grid.Column="0" VerticalAlignment="Center">search:</TextBlock>
  218. <TextBox x:Name="SearchTextBox" Grid.Column="1" BorderBrush="{DynamicResource Table_BG_FirstTitle}" BorderThickness="1" Background="White" Width="370"
  219. HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" VerticalAlignment="Stretch" VerticalContentAlignment="Center" Height="25"
  220. Text="{Binding SearchText ,Delay=0, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
  221. <i:Interaction.Triggers>
  222. <i:EventTrigger EventName="TextChanged">
  223. <i:InvokeCommandAction Command="{Binding SearchTextChangedCommand}" CommandParameter="{Binding Path=Text, ElementName=SearchTextBox}"/>
  224. </i:EventTrigger>
  225. </i:Interaction.Triggers>
  226. </TextBox>-->
  227. <!--<Button Grid.Column="1" Content="Search" Width="80" Height="25" Margin="5,0,0,0" Command="{Binding SearchCommand}" CommandParameter="{Binding Path=Text, ElementName=SearchTextBox}"></Button>-->
  228. <Border Grid.Column="1" Grid.Row="1" BorderBrush="{DynamicResource Table_BD}" BorderThickness="1" Background="{DynamicResource Table_BG_Content}" Padding="5,1" Visibility="{Binding SearchListBoxShow}">
  229. <Grid>
  230. <ListBox x:Name="PART_LIST_SEARCH" Margin="5" ItemsSource="{Binding SearchResultCollection}" Width="350"
  231. VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"
  232. ScrollViewer.HorizontalScrollBarVisibility="Auto" MaxHeight="215">
  233. <i:Interaction.Triggers>
  234. <i:EventTrigger EventName="SelectionChanged">
  235. <i:InvokeCommandAction Command="{Binding ListBoxSelectSearchResultCommand}" CommandParameter="{Binding Path=SelectedItem, ElementName=PART_LIST_SEARCH}"/>
  236. </i:EventTrigger>
  237. </i:Interaction.Triggers>
  238. <ListBox.ItemTemplate>
  239. <DataTemplate>
  240. <Label Content="{Binding}"></Label>
  241. </DataTemplate>
  242. </ListBox.ItemTemplate>
  243. <ListBox.ItemContainerStyle>
  244. <Style TargetType="{x:Type ListBoxItem}">
  245. <Setter Property="Background" Value="Transparent"></Setter>
  246. <Setter Property="Padding" Value="0" />
  247. <Setter Property="BorderThickness" Value="0 0 0 1" />
  248. <Setter Property="BorderBrush" Value="Gray" />
  249. </Style>
  250. </ListBox.ItemContainerStyle>
  251. </ListBox>
  252. </Grid>
  253. </Border>
  254. <Popup x:Name="PART_Popup"
  255. AllowsTransparency="true"
  256. PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"
  257. Placement="Bottom"
  258. StaysOpen="True">
  259. <Border Grid.Column="1" Grid.Row="1" BorderBrush="{DynamicResource Table_BD}" BorderThickness="1" Background="{DynamicResource Table_BG_Content}" Padding="5,1">
  260. <ListBox x:Name="PART_LIST_SEARCH1" Margin="5" ItemsSource="{Binding SearchResultCollection}" Width="350"
  261. VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"
  262. ScrollViewer.HorizontalScrollBarVisibility="Auto" MaxHeight="215">
  263. <i:Interaction.Triggers>
  264. <i:EventTrigger EventName="SelectionChanged">
  265. <i:InvokeCommandAction Command="{Binding ListBoxSelectSearchResultCommand}" CommandParameter="{Binding Path=SelectedItem, ElementName=PART_LIST_SEARCH1}"/>
  266. </i:EventTrigger>
  267. </i:Interaction.Triggers>
  268. <ListBox.ItemTemplate>
  269. <DataTemplate>
  270. <Label Content="{Binding}"></Label>
  271. </DataTemplate>
  272. </ListBox.ItemTemplate>
  273. <ListBox.ItemContainerStyle>
  274. <Style TargetType="{x:Type ListBoxItem}">
  275. <Setter Property="Background" Value="Transparent"></Setter>
  276. <Setter Property="Padding" Value="0" />
  277. <Setter Property="BorderThickness" Value="0 0 0 1" />
  278. <Setter Property="BorderBrush" Value="Gray" />
  279. <Setter Property="Template">
  280. <Setter.Value>
  281. <ControlTemplate TargetType="{x:Type ListBoxItem}">
  282. <Border x:Name="Bd"
  283. Height="38"
  284. Margin="0,0,0,4"
  285. BorderThickness="0"
  286. Background="{TemplateBinding Background}"
  287. SnapsToDevicePixels="true">
  288. <ContentPresenter HorizontalAlignment="Stretch"
  289. Margin="14,0,0,0"
  290. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  291. VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
  292. </Border>
  293. <ControlTemplate.Triggers>
  294. <Trigger Property="IsMouseOver"
  295. Value="True">
  296. <Setter TargetName="Bd"
  297. Property="BorderBrush"
  298. Value="Chartreuse" />
  299. <Setter TargetName="Bd"
  300. Property="Background"
  301. Value="Chartreuse" />
  302. <Setter Property="Foreground"
  303. Value="White" />
  304. </Trigger>
  305. <Trigger Property="IsSelected"
  306. Value="true">
  307. <Setter Property="Background"
  308. TargetName="Bd"
  309. Value="Blue" />
  310. <Setter Property="Foreground"
  311. Value="White" />
  312. </Trigger>
  313. <MultiTrigger>
  314. <MultiTrigger.Conditions>
  315. <Condition Property="IsSelected"
  316. Value="true" />
  317. <Condition Property="Selector.IsSelectionActive"
  318. Value="false" />
  319. </MultiTrigger.Conditions>
  320. <Setter Property="Background"
  321. TargetName="Bd"
  322. Value="{DynamicResource BgColorLeftTreeRowSelected}" />
  323. <Setter Property="Foreground"
  324. Value="{DynamicResource ForegroundSelect}" />
  325. </MultiTrigger>
  326. <Trigger Property="IsEnabled"
  327. Value="false">
  328. <Setter Property="Foreground"
  329. Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
  330. </Trigger>
  331. </ControlTemplate.Triggers>
  332. </ControlTemplate>
  333. </Setter.Value>
  334. </Setter>
  335. </Style>
  336. </ListBox.ItemContainerStyle>
  337. </ListBox>
  338. </Border>
  339. </Popup>
  340. </Grid>
  341. </Grid>
  342. </UserControl>