123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373 |
- <UserControl x:Class="CyberX8_MainPages.Views.SystemConfigView"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:CyberX8_MainPages.Views"
- xmlns:systemConfig="clr-namespace:CyberX8_MainPages.Unity"
- xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
- xmlns:ctrl="http://OpenSEMI.Ctrlib.com/presentation"
- xmlns:prism="http://prismlibrary.com/"
- xmlns:converters="clr-namespace:CyberX8_Themes.Converters;assembly=CyberX8_Themes"
- prism:ViewModelLocator.AutoWireViewModel="True"
- mc:Ignorable="d"
- d:DesignHeight="450" d:DesignWidth="800" x:Name="sysconfigView">
- <UserControl.Resources>
- <converters:Null2Bool x:Key="Null2Bool"/>
- <converters:Bool2Not x:Key="Bool2Not"/>
- <converters:Float2String x:Key="Float2String"/>
- <converters:String2Double x:Key="String2Double"/>
- <converters:BoolToVisibility2 x:Key="BoolToVisibility2"/>
- <HierarchicalDataTemplate x:Key="ConfigNodeTemplate" DataType="{x:Type systemConfig:ConfigNode}" ItemsSource="{Binding SubNodes}">
- <TextBlock Text="{Binding Name}" VerticalAlignment="Center">
- </TextBlock>
- </HierarchicalDataTemplate>
- <systemConfig:ConfigValueTemplateSelector x:Key="ConfigValueTemplateSelector">
- <systemConfig:ConfigValueTemplateSelector.BoolTemplate>
- <DataTemplate>
- <StackPanel Orientation="Horizontal" Margin="10,0">
- <RadioButton Content="true" VerticalAlignment="Center" IsChecked="{Binding BoolValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
- <RadioButton Content="false" VerticalAlignment="Center" Margin="10,0,0,0" IsChecked="{Binding BoolValue, Mode=TwoWay, Converter={StaticResource Bool2Not}, UpdateSourceTrigger=PropertyChanged}"/>
- </StackPanel>
- </DataTemplate>
- </systemConfig:ConfigValueTemplateSelector.BoolTemplate>
- <systemConfig:ConfigValueTemplateSelector.StringTemplate>
- <DataTemplate>
- <Grid Width="190">
- <ctrl:TextBoxEx Text="{Binding StringValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextSaved="{Binding TextSaved, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
- </Grid>
- </DataTemplate>
- </systemConfig:ConfigValueTemplateSelector.StringTemplate>
- <systemConfig:ConfigValueTemplateSelector.NumbericTemplate>
- <DataTemplate>
- <Grid Width="190">
- <TextBox Width="160" HorizontalAlignment="Center" Text="{Binding CurValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" >
- <TextBox.Style>
- <Style TargetType="TextBox" >
- <Setter Property="ToolTip" Value="{x:Null}"/>
- <Style.Triggers>
- <DataTrigger Binding="{Binding RangeFrom, Converter={StaticResource Null2Bool}}" Value="False">
- <Setter Property="ToolTip">
- <Setter.Value>
- <TextBlock>
- <Run Text="Range: "/>
- <Run Text="{Binding Max}"/>
- <Run Text="~"/>
- <Run Text="{Binding Min}"/>
- </TextBlock>
- </Setter.Value>
- </Setter>
- <!--<Setter Property="MinValue" Value="{Binding RangeFrom, Converter={StaticResource String2Double}}"/>
- <Setter Property="MaxValue" Value="{Binding RangeTo, Converter={StaticResource String2Double}}"/>-->
- </DataTrigger>
- <!--<DataTrigger Binding="{Binding Type}" Value="Int">
- <Setter Property="EditBoxMode" Value="SignInteger"/>
- </DataTrigger>
- <DataTrigger Binding="{Binding Type}" Value="Float">
- <Setter Property="EditBoxMode" Value="Decimal"/>
- </DataTrigger>-->
- </Style.Triggers>
- </Style>
- </TextBox.Style>
- </TextBox>
- </Grid>
- </DataTemplate>
- </systemConfig:ConfigValueTemplateSelector.NumbericTemplate>
- <systemConfig:ConfigValueTemplateSelector.EnumTemplate>
- <DataTemplate>
- <Grid Width="190">
- <ComboBox ItemsSource="{Binding Options}" SelectedValuePath="Value" SelectedValue="{Binding CurValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Width="160" HorizontalAlignment="Center">
- <ComboBox.ItemTemplate>
- <DataTemplate>
- <TextBlock Text="{Binding Name}" VerticalAlignment="Center"/>
- </DataTemplate>
- </ComboBox.ItemTemplate>
- </ComboBox>
- </Grid>
- </DataTemplate>
- </systemConfig:ConfigValueTemplateSelector.EnumTemplate>
- </systemConfig:ConfigValueTemplateSelector>
- </UserControl.Resources>
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition MinWidth="300" Width="Auto"/>
- <ColumnDefinition Width="Auto"/>
- <ColumnDefinition MinWidth="200"/>
- </Grid.ColumnDefinitions>
- <Border BorderBrush="{DynamicResource Table_BD}" BorderThickness="1" Background="{DynamicResource Table_BG_Content}" Padding="5,1">
- <TreeView x:Name="PART_TREE" Margin="5" ItemsSource="{Binding ConfigNodes}" ItemTemplate="{StaticResource ConfigNodeTemplate}"
- VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"
- Height="{Binding Path=ActualHeight,ElementName=PART_BORDER, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}">
- <!--Height should add for VirtualizingPanel, otherwise the App will be slow-->
- <TreeView.ItemContainerStyle>
- <Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource ResourceKey={x:Type TreeViewItem}}">
- <Setter Property="IsExpanded" Value="True"></Setter>
- <Setter Property="Visibility" Value="{Binding IsShow,Converter={StaticResource BoolToVisibility2}}"></Setter>
- </Style>
- </TreeView.ItemContainerStyle>
- <i:Interaction.Triggers>
- <i:EventTrigger EventName="SelectedItemChanged">
- <i:InvokeCommandAction Command="{Binding TreeViewSelectedItemChangedCmd}" CommandParameter="{Binding Path=SelectedItem, ElementName=PART_TREE}"/>
- </i:EventTrigger>
- </i:Interaction.Triggers>
- </TreeView>
- </Border>
- <GridSplitter Width="5" Grid.Column="1" HorizontalAlignment="Left" Background="Transparent">
- </GridSplitter>
- <Grid Grid.Column="1" Margin="10,0,0,0">
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto"/>
- <RowDefinition />
- </Grid.RowDefinitions>
- <StackPanel Orientation="Horizontal">
- <Button Content="Reload" Width="80" Height="25" Command="{Binding ReloadCommand}">
- </Button>
- <Button Content="Save All" Width="80" Height="25" Margin="5,0,0,0" Command="{Binding SaveAllCommand}">
- </Button>
- </StackPanel>
- <DataGrid Grid.Row="1" AlternationCount="2" HorizontalAlignment="Left" CanUserAddRows="False" AutoGenerateColumns="False" RowHeaderWidth="0"
- VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"
- ItemsSource="{Binding ConfigItems}" Margin="0,5,0,0">
- <DataGrid.Columns>
- <DataGridTemplateColumn Header="Config Item" MinWidth="500">
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <TextBlock Text="{Binding Name}" Margin="5,0" FontFamily="Arial" FontSize="14" Foreground="{DynamicResource FG_Black}" HorizontalAlignment="Left" VerticalAlignment="Center" Width="500">
- <TextBlock.ToolTip>
- <ToolTip>
- <ToolTip.Content>
- <Grid>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="100"/>
- <ColumnDefinition Width="300"/>
- </Grid.ColumnDefinitions>
- <Grid.RowDefinitions>
- <RowDefinition Height="25"/>
- <RowDefinition Height="25"/>
- <RowDefinition Height="25"/>
- <RowDefinition Height="50"/>
- </Grid.RowDefinitions>
- <TextBlock Grid.Column="0" Grid.Row="0" Text="Name" VerticalAlignment="Center"></TextBlock>
- <TextBlock Grid.Column="1" Grid.Row="0" TextWrapping="Wrap" Text="{Binding Name}" VerticalAlignment="Center"></TextBlock>
- <TextBlock Grid.Column="0" Grid.Row="1" Text="Type" VerticalAlignment="Center"></TextBlock>
- <TextBlock Grid.Column="1" Grid.Row="1" TextWrapping="Wrap" Text="{Binding Type}" VerticalAlignment="Center"></TextBlock>
- <TextBlock Grid.Column="0" Grid.Row="2" Text="Default Value" VerticalAlignment="Center"></TextBlock>
- <TextBlock Grid.Column="1" Grid.Row="2" TextWrapping="Wrap" Text="{Binding DefaultValue}" VerticalAlignment="Center"></TextBlock>
- <TextBlock Grid.Column="0" Grid.Row="3" Text="Description" VerticalAlignment="Center"></TextBlock>
- <TextBlock Grid.Column="1" Grid.Row="3" TextWrapping="Wrap" Text="{Binding Description}" VerticalAlignment="Center"></TextBlock>
- </Grid>
- </ToolTip.Content>
- </ToolTip>
- </TextBlock.ToolTip>
- </TextBlock>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <DataGridTemplateColumn Header="Unit" MinWidth="80">
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <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}"/>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <DataGridTemplateColumn Header="Min" MinWidth="80">
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <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}"/>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <DataGridTemplateColumn Header="Max" MinWidth="80">
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <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}"/>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <DataGridTemplateColumn Header="Value" MinWidth="80">
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <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}"/>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- <DataGridTemplateColumn Header="Setpoint" CellTemplateSelector="{StaticResource ConfigValueTemplateSelector}" MinWidth="100"/>
- <DataGridTemplateColumn MinWidth="80">
- <DataGridTemplateColumn.CellTemplate>
- <DataTemplate>
- <Button Content="Set" Width="60" Height="20" FontSize="12" Command="{Binding ElementName=sysconfigView, Path=DataContext.SetValueCommand}" CommandParameter="{Binding }">
- </Button>
- </DataTemplate>
- </DataGridTemplateColumn.CellTemplate>
- </DataGridTemplateColumn>
- </DataGrid.Columns>
- </DataGrid>
- </Grid>
- <Grid Grid.Column="2" Margin="5,0,0,0">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="50"/>
- <ColumnDefinition Width="auto"/>
- <ColumnDefinition Width="auto"/>
- <ColumnDefinition Width="*" />
- </Grid.ColumnDefinitions>
- <Grid.RowDefinitions>
- <RowDefinition Height="auto"/>
- <RowDefinition Height="auto"/>
- </Grid.RowDefinitions>
- <!--<TextBlock Grid.Column="0" VerticalAlignment="Center">search:</TextBlock>
- <TextBox x:Name="SearchTextBox" Grid.Column="1" BorderBrush="{DynamicResource Table_BG_FirstTitle}" BorderThickness="1" Background="White" Width="370"
- HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" VerticalAlignment="Stretch" VerticalContentAlignment="Center" Height="25"
- Text="{Binding SearchText ,Delay=0, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
- <i:Interaction.Triggers>
- <i:EventTrigger EventName="TextChanged">
- <i:InvokeCommandAction Command="{Binding SearchTextChangedCommand}" CommandParameter="{Binding Path=Text, ElementName=SearchTextBox}"/>
- </i:EventTrigger>
- </i:Interaction.Triggers>
- </TextBox>-->
- <!--<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>-->
- <Border Grid.Column="1" Grid.Row="1" BorderBrush="{DynamicResource Table_BD}" BorderThickness="1" Background="{DynamicResource Table_BG_Content}" Padding="5,1" Visibility="{Binding SearchListBoxShow}">
- <Grid>
- <ListBox x:Name="PART_LIST_SEARCH" Margin="5" ItemsSource="{Binding SearchResultCollection}" Width="350"
- VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"
- ScrollViewer.HorizontalScrollBarVisibility="Auto" MaxHeight="215">
- <i:Interaction.Triggers>
- <i:EventTrigger EventName="SelectionChanged">
- <i:InvokeCommandAction Command="{Binding ListBoxSelectSearchResultCommand}" CommandParameter="{Binding Path=SelectedItem, ElementName=PART_LIST_SEARCH}"/>
- </i:EventTrigger>
- </i:Interaction.Triggers>
- <ListBox.ItemTemplate>
- <DataTemplate>
- <Label Content="{Binding}"></Label>
- </DataTemplate>
- </ListBox.ItemTemplate>
- <ListBox.ItemContainerStyle>
- <Style TargetType="{x:Type ListBoxItem}">
- <Setter Property="Background" Value="Transparent"></Setter>
- <Setter Property="Padding" Value="0" />
- <Setter Property="BorderThickness" Value="0 0 0 1" />
- <Setter Property="BorderBrush" Value="Gray" />
- </Style>
- </ListBox.ItemContainerStyle>
- </ListBox>
- </Grid>
- </Border>
- <Popup x:Name="PART_Popup"
- AllowsTransparency="true"
- PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"
- Placement="Bottom"
- StaysOpen="True">
- <Border Grid.Column="1" Grid.Row="1" BorderBrush="{DynamicResource Table_BD}" BorderThickness="1" Background="{DynamicResource Table_BG_Content}" Padding="5,1">
- <ListBox x:Name="PART_LIST_SEARCH1" Margin="5" ItemsSource="{Binding SearchResultCollection}" Width="350"
- VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling"
- ScrollViewer.HorizontalScrollBarVisibility="Auto" MaxHeight="215">
- <i:Interaction.Triggers>
- <i:EventTrigger EventName="SelectionChanged">
- <i:InvokeCommandAction Command="{Binding ListBoxSelectSearchResultCommand}" CommandParameter="{Binding Path=SelectedItem, ElementName=PART_LIST_SEARCH1}"/>
- </i:EventTrigger>
- </i:Interaction.Triggers>
- <ListBox.ItemTemplate>
- <DataTemplate>
- <Label Content="{Binding}"></Label>
- </DataTemplate>
- </ListBox.ItemTemplate>
- <ListBox.ItemContainerStyle>
- <Style TargetType="{x:Type ListBoxItem}">
- <Setter Property="Background" Value="Transparent"></Setter>
- <Setter Property="Padding" Value="0" />
- <Setter Property="BorderThickness" Value="0 0 0 1" />
- <Setter Property="BorderBrush" Value="Gray" />
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type ListBoxItem}">
- <Border x:Name="Bd"
- Height="38"
- Margin="0,0,0,4"
- BorderThickness="0"
- Background="{TemplateBinding Background}"
- SnapsToDevicePixels="true">
- <ContentPresenter HorizontalAlignment="Stretch"
- Margin="14,0,0,0"
- SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
- VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsMouseOver"
- Value="True">
- <Setter TargetName="Bd"
- Property="BorderBrush"
- Value="Chartreuse" />
- <Setter TargetName="Bd"
- Property="Background"
- Value="Chartreuse" />
- <Setter Property="Foreground"
- Value="White" />
- </Trigger>
- <Trigger Property="IsSelected"
- Value="true">
- <Setter Property="Background"
- TargetName="Bd"
- Value="Blue" />
- <Setter Property="Foreground"
- Value="White" />
- </Trigger>
- <MultiTrigger>
- <MultiTrigger.Conditions>
- <Condition Property="IsSelected"
- Value="true" />
- <Condition Property="Selector.IsSelectionActive"
- Value="false" />
- </MultiTrigger.Conditions>
- <Setter Property="Background"
- TargetName="Bd"
- Value="{DynamicResource BgColorLeftTreeRowSelected}" />
- <Setter Property="Foreground"
- Value="{DynamicResource ForegroundSelect}" />
- </MultiTrigger>
- <Trigger Property="IsEnabled"
- Value="false">
- <Setter Property="Foreground"
- Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </ListBox.ItemContainerStyle>
- </ListBox>
- </Border>
- </Popup>
- </Grid>
- </Grid>
- </UserControl>
|