算子调节参数控件的显示与选择的优化
This commit is contained in:
@@ -19,6 +19,7 @@ namespace XplorePlane.ViewModels
|
|||||||
MinValue = parameter.MinValue;
|
MinValue = parameter.MinValue;
|
||||||
MaxValue = parameter.MaxValue;
|
MaxValue = parameter.MaxValue;
|
||||||
Options = parameter.Options;
|
Options = parameter.Options;
|
||||||
|
IsVisible = parameter.IsVisible;
|
||||||
ParameterType = parameter.ValueType?.Name?.ToLowerInvariant() switch
|
ParameterType = parameter.ValueType?.Name?.ToLowerInvariant() switch
|
||||||
{
|
{
|
||||||
"int32" or "int" => "int",
|
"int32" or "int" => "int",
|
||||||
@@ -34,7 +35,11 @@ namespace XplorePlane.ViewModels
|
|||||||
public object MinValue { get; }
|
public object MinValue { get; }
|
||||||
public object MaxValue { get; }
|
public object MaxValue { get; }
|
||||||
public string[]? Options { get; }
|
public string[]? Options { get; }
|
||||||
|
public bool IsVisible { get; }
|
||||||
public string ParameterType { get; }
|
public string ParameterType { get; }
|
||||||
|
public bool HasOptions => Options is { Length: > 0 };
|
||||||
|
public bool IsBool => ParameterType == "bool";
|
||||||
|
public bool IsTextInput => !IsBool && !HasOptions;
|
||||||
|
|
||||||
public bool IsValueValid
|
public bool IsValueValid
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -226,6 +226,16 @@
|
|||||||
Foreground="#555"
|
Foreground="#555"
|
||||||
Text="参数配置" />
|
Text="参数配置" />
|
||||||
<ItemsControl ItemsSource="{Binding SelectedNode.Parameters}">
|
<ItemsControl ItemsSource="{Binding SelectedNode.Parameters}">
|
||||||
|
<ItemsControl.ItemContainerStyle>
|
||||||
|
<Style TargetType="ContentPresenter">
|
||||||
|
<Setter Property="Visibility" Value="Visible" />
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding IsVisible}" Value="False">
|
||||||
|
<Setter Property="Visibility" Value="Collapsed" />
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</ItemsControl.ItemContainerStyle>
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<Grid Margin="0,3">
|
<Grid Margin="0,3">
|
||||||
@@ -241,6 +251,7 @@
|
|||||||
Text="{Binding DisplayName}"
|
Text="{Binding DisplayName}"
|
||||||
TextTrimming="CharacterEllipsis" />
|
TextTrimming="CharacterEllipsis" />
|
||||||
<TextBox
|
<TextBox
|
||||||
|
x:Name="TextValueEditor"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Padding="4,2"
|
Padding="4,2"
|
||||||
BorderBrush="#CDCBCB"
|
BorderBrush="#CDCBCB"
|
||||||
@@ -252,7 +263,11 @@
|
|||||||
<Style TargetType="TextBox">
|
<Style TargetType="TextBox">
|
||||||
<Setter Property="BorderBrush" Value="#CDCBCB" />
|
<Setter Property="BorderBrush" Value="#CDCBCB" />
|
||||||
<Setter Property="Background" Value="White" />
|
<Setter Property="Background" Value="White" />
|
||||||
|
<Setter Property="Visibility" Value="Visible" />
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding IsTextInput}" Value="False">
|
||||||
|
<Setter Property="Visibility" Value="Collapsed" />
|
||||||
|
</DataTrigger>
|
||||||
<DataTrigger Binding="{Binding IsValueValid}" Value="False">
|
<DataTrigger Binding="{Binding IsValueValid}" Value="False">
|
||||||
<Setter Property="BorderBrush" Value="Red" />
|
<Setter Property="BorderBrush" Value="Red" />
|
||||||
<Setter Property="Background" Value="#FFF0F0" />
|
<Setter Property="Background" Value="#FFF0F0" />
|
||||||
@@ -261,6 +276,44 @@
|
|||||||
</Style>
|
</Style>
|
||||||
</TextBox.Style>
|
</TextBox.Style>
|
||||||
</TextBox>
|
</TextBox>
|
||||||
|
<ComboBox
|
||||||
|
Grid.Column="1"
|
||||||
|
MinHeight="24"
|
||||||
|
Padding="4,1"
|
||||||
|
BorderBrush="#CDCBCB"
|
||||||
|
BorderThickness="1"
|
||||||
|
FontFamily="Microsoft YaHei UI"
|
||||||
|
FontSize="11"
|
||||||
|
ItemsSource="{Binding Options}"
|
||||||
|
SelectedItem="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
|
||||||
|
<ComboBox.Style>
|
||||||
|
<Style TargetType="ComboBox">
|
||||||
|
<Setter Property="Visibility" Value="Collapsed" />
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding HasOptions}" Value="True">
|
||||||
|
<Setter Property="Visibility" Value="Visible" />
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</ComboBox.Style>
|
||||||
|
</ComboBox>
|
||||||
|
<CheckBox
|
||||||
|
Grid.Column="1"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
FontFamily="Microsoft YaHei UI"
|
||||||
|
FontSize="11"
|
||||||
|
IsChecked="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
|
||||||
|
<CheckBox.Style>
|
||||||
|
<Style TargetType="CheckBox">
|
||||||
|
<Setter Property="Visibility" Value="Collapsed" />
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding IsBool}" Value="True">
|
||||||
|
<Setter Property="Visibility" Value="Visible" />
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</CheckBox.Style>
|
||||||
|
</CheckBox>
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
|
|||||||
Reference in New Issue
Block a user