SystemConfigView.xaml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. <UserControl x:Class="Venus_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:Venus_MainPages.Views"
  7. xmlns:systemConfig="clr-namespace:Venus_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:Venus_Themes.Converters;assembly=Venus_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="260">
  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="260">
  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 Header="Restart" MinWidth="50" Visibility="{Binding ReatsrtIsVisibility}">
  196. <DataGridTemplateColumn.CellTemplate>
  197. <DataTemplate>
  198. <TextBlock Text="{Binding NeedRestart}" FontFamily="Arial" FontSize="14" Padding="8 2 0 0" Foreground="{DynamicResource FG_Black}" >
  199. <TextBlock.Style>
  200. <Style TargetType="TextBlock">
  201. <Style.Triggers>
  202. <DataTrigger Binding="{Binding Text, RelativeSource={RelativeSource Self}}" Value="True">
  203. <Setter Property="Background" Value="LightGreen"/>
  204. </DataTrigger>
  205. </Style.Triggers>
  206. </Style>
  207. </TextBlock.Style>
  208. </TextBlock>
  209. </DataTemplate>
  210. </DataGridTemplateColumn.CellTemplate>
  211. </DataGridTemplateColumn>
  212. <DataGridTemplateColumn MinWidth="80">
  213. <DataGridTemplateColumn.CellTemplate>
  214. <DataTemplate>
  215. <Button Content="Set" Width="60" Height="20" FontSize="12" Command="{Binding ElementName=sysconfigView, Path=DataContext.SetValueCommand}" CommandParameter="{Binding }">
  216. </Button>
  217. </DataTemplate>
  218. </DataGridTemplateColumn.CellTemplate>
  219. </DataGridTemplateColumn>
  220. </DataGrid.Columns>
  221. </DataGrid>
  222. </Grid>
  223. <Grid Grid.Column="2" Margin="5,0,0,0">
  224. <Grid.ColumnDefinitions>
  225. <ColumnDefinition Width="50"/>
  226. <ColumnDefinition Width="auto"/>
  227. <ColumnDefinition Width="auto"/>
  228. <ColumnDefinition Width="*" />
  229. </Grid.ColumnDefinitions>
  230. <Grid.RowDefinitions>
  231. <RowDefinition Height="auto"/>
  232. <RowDefinition Height="auto"/>
  233. </Grid.RowDefinitions>
  234. <TextBlock Grid.Column="0" VerticalAlignment="Center">search:</TextBlock>
  235. <TextBox x:Name="SearchTextBox" Grid.Column="1" BorderBrush="{DynamicResource Table_BG_FirstTitle}" BorderThickness="1" Background="White" Width="370"
  236. HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" VerticalAlignment="Stretch" VerticalContentAlignment="Center" Height="25"
  237. Text="{Binding SearchText ,Delay=0, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
  238. <i:Interaction.Triggers>
  239. <i:EventTrigger EventName="TextChanged">
  240. <i:InvokeCommandAction Command="{Binding SearchTextChangedCommand}" CommandParameter="{Binding Path=Text, ElementName=SearchTextBox}"/>
  241. </i:EventTrigger>
  242. </i:Interaction.Triggers>
  243. </TextBox>
  244. <!--<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>-->
  245. <Border Grid.Column="1" Grid.Row="1" BorderBrush="{DynamicResource Table_BD}" BorderThickness="1" Background="{DynamicResource Table_BG_Content}" Padding="5,1" Visibility="{Binding SearchListBoxShow}">
  246. <Grid>
  247. <ListBox x:Name="PART_LIST_SEARCH" Margin="5" ItemsSource="{Binding SearchResultCollection}" Width="350"
  248. VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"
  249. ScrollViewer.HorizontalScrollBarVisibility="Auto" MaxHeight="215">
  250. <i:Interaction.Triggers>
  251. <i:EventTrigger EventName="SelectionChanged">
  252. <i:InvokeCommandAction Command="{Binding ListBoxSelectSearchResultCommand}" CommandParameter="{Binding Path=SelectedItem, ElementName=PART_LIST_SEARCH}"/>
  253. </i:EventTrigger>
  254. </i:Interaction.Triggers>
  255. <ListBox.ItemTemplate>
  256. <DataTemplate>
  257. <Label Content="{Binding}"></Label>
  258. </DataTemplate>
  259. </ListBox.ItemTemplate>
  260. <ListBox.ItemContainerStyle>
  261. <Style TargetType="{x:Type ListBoxItem}">
  262. <Setter Property="Background" Value="Transparent"></Setter>
  263. <Setter Property="Padding" Value="0" />
  264. <Setter Property="BorderThickness" Value="0 0 0 1" />
  265. <Setter Property="BorderBrush" Value="Gray" />
  266. </Style>
  267. </ListBox.ItemContainerStyle>
  268. </ListBox>
  269. </Grid>
  270. </Border>
  271. <Popup x:Name="PART_Popup"
  272. AllowsTransparency="true"
  273. PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"
  274. Placement="Bottom"
  275. StaysOpen="True">
  276. <Border Grid.Column="1" Grid.Row="1" BorderBrush="{DynamicResource Table_BD}" BorderThickness="1" Background="{DynamicResource Table_BG_Content}" Padding="5,1">
  277. <ListBox x:Name="PART_LIST_SEARCH1" Margin="5" ItemsSource="{Binding SearchResultCollection}" Width="350"
  278. VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"
  279. ScrollViewer.HorizontalScrollBarVisibility="Auto" MaxHeight="215">
  280. <i:Interaction.Triggers>
  281. <i:EventTrigger EventName="SelectionChanged">
  282. <i:InvokeCommandAction Command="{Binding ListBoxSelectSearchResultCommand}" CommandParameter="{Binding Path=SelectedItem, ElementName=PART_LIST_SEARCH1}"/>
  283. </i:EventTrigger>
  284. </i:Interaction.Triggers>
  285. <ListBox.ItemTemplate>
  286. <DataTemplate>
  287. <Label Content="{Binding}"></Label>
  288. </DataTemplate>
  289. </ListBox.ItemTemplate>
  290. <ListBox.ItemContainerStyle>
  291. <Style TargetType="{x:Type ListBoxItem}">
  292. <Setter Property="Background" Value="Transparent"></Setter>
  293. <Setter Property="Padding" Value="0" />
  294. <Setter Property="BorderThickness" Value="0 0 0 1" />
  295. <Setter Property="BorderBrush" Value="Gray" />
  296. <Setter Property="Template">
  297. <Setter.Value>
  298. <ControlTemplate TargetType="{x:Type ListBoxItem}">
  299. <Border x:Name="Bd"
  300. Height="38"
  301. Margin="0,0,0,4"
  302. BorderThickness="0"
  303. Background="{TemplateBinding Background}"
  304. SnapsToDevicePixels="true">
  305. <ContentPresenter HorizontalAlignment="Stretch"
  306. Margin="14,0,0,0"
  307. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  308. VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
  309. </Border>
  310. <ControlTemplate.Triggers>
  311. <Trigger Property="IsMouseOver"
  312. Value="True">
  313. <Setter TargetName="Bd"
  314. Property="BorderBrush"
  315. Value="Chartreuse" />
  316. <Setter TargetName="Bd"
  317. Property="Background"
  318. Value="Chartreuse" />
  319. <Setter Property="Foreground"
  320. Value="White" />
  321. </Trigger>
  322. <Trigger Property="IsSelected"
  323. Value="true">
  324. <Setter Property="Background"
  325. TargetName="Bd"
  326. Value="Blue" />
  327. <Setter Property="Foreground"
  328. Value="White" />
  329. </Trigger>
  330. <MultiTrigger>
  331. <MultiTrigger.Conditions>
  332. <Condition Property="IsSelected"
  333. Value="true" />
  334. <Condition Property="Selector.IsSelectionActive"
  335. Value="false" />
  336. </MultiTrigger.Conditions>
  337. <Setter Property="Background"
  338. TargetName="Bd"
  339. Value="{DynamicResource BgColorLeftTreeRowSelected}" />
  340. <Setter Property="Foreground"
  341. Value="{DynamicResource ForegroundSelect}" />
  342. </MultiTrigger>
  343. <Trigger Property="IsEnabled"
  344. Value="false">
  345. <Setter Property="Foreground"
  346. Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
  347. </Trigger>
  348. </ControlTemplate.Triggers>
  349. </ControlTemplate>
  350. </Setter.Value>
  351. </Setter>
  352. </Style>
  353. </ListBox.ItemContainerStyle>
  354. </ListBox>
  355. </Border>
  356. </Popup>
  357. </Grid>
  358. </Grid>
  359. </UserControl>