CNC树形结构的优化
This commit is contained in:
@@ -64,7 +64,15 @@ namespace XplorePlane.ViewModels.Cnc
|
||||
public bool IsPauseDialog => _model is PauseDialogNode;
|
||||
public bool IsWaitDelay => _model is WaitDelayNode;
|
||||
public bool IsCompleteProgram => _model is CompleteProgramNode;
|
||||
public bool IsPositionChild => _model is InspectionModuleNode or InspectionMarkerNode;
|
||||
public bool IsMotionSnapshotNode => _model is ReferencePointNode or SaveNodeNode or SaveNodeWithImageNode or SavePositionNode;
|
||||
public string RelationTag => _model switch
|
||||
{
|
||||
SavePositionNode => "位置",
|
||||
InspectionModuleNode => "检测模块",
|
||||
InspectionMarkerNode => "检测标记",
|
||||
_ => string.Empty
|
||||
};
|
||||
|
||||
public double XM
|
||||
{
|
||||
@@ -504,7 +512,9 @@ namespace XplorePlane.ViewModels.Cnc
|
||||
RaisePropertyChanged(nameof(IsPauseDialog));
|
||||
RaisePropertyChanged(nameof(IsWaitDelay));
|
||||
RaisePropertyChanged(nameof(IsCompleteProgram));
|
||||
RaisePropertyChanged(nameof(IsPositionChild));
|
||||
RaisePropertyChanged(nameof(IsMotionSnapshotNode));
|
||||
RaisePropertyChanged(nameof(RelationTag));
|
||||
RaisePropertyChanged(nameof(XM));
|
||||
RaisePropertyChanged(nameof(YM));
|
||||
RaisePropertyChanged(nameof(ZT));
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
<SolidColorBrush x:Key="PanelBorder" Color="#CDCBCB" />
|
||||
<SolidColorBrush x:Key="SeparatorBrush" Color="#E5E5E5" />
|
||||
<SolidColorBrush x:Key="HeaderBg" Color="#F7F7F7" />
|
||||
<SolidColorBrush x:Key="TreeParentBg" Color="#F6F8FB" />
|
||||
<SolidColorBrush x:Key="TreeChildBg" Color="#FBFCFE" />
|
||||
<SolidColorBrush x:Key="TreeAccentBrush" Color="#2E6FA3" />
|
||||
<SolidColorBrush x:Key="TreeChildLineBrush" Color="#B9CDE0" />
|
||||
<FontFamily x:Key="UiFont">Microsoft YaHei UI</FontFamily>
|
||||
|
||||
<Style x:Key="TreeItemStyle" TargetType="TreeViewItem">
|
||||
@@ -109,7 +113,7 @@
|
||||
FontFamily="{StaticResource UiFont}"
|
||||
FontSize="10"
|
||||
Foreground="#666666"
|
||||
Text="模块节点下会自动显示标记、等待、消息等子节点。"
|
||||
Text="保存位置节点下会自动显示检测标记和检测模块,清晰表达当前检测位置与检测内容的父子关系。"
|
||||
TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
@@ -124,97 +128,133 @@
|
||||
SelectedItemChanged="CncTreeView_SelectedItemChanged">
|
||||
<TreeView.Resources>
|
||||
<HierarchicalDataTemplate DataType="{x:Type vm:CncNodeViewModel}" ItemsSource="{Binding Children}">
|
||||
<Grid x:Name="NodeRoot" MinHeight="34">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border
|
||||
x:Name="NodeCard"
|
||||
Margin="0,1,0,1"
|
||||
Padding="0"
|
||||
Background="Transparent"
|
||||
BorderBrush="Transparent"
|
||||
BorderThickness="1"
|
||||
CornerRadius="4">
|
||||
<Grid x:Name="NodeRoot" MinHeight="28">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="18" />
|
||||
<ColumnDefinition Width="24" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border
|
||||
Grid.Column="0"
|
||||
Width="22"
|
||||
Height="22"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Background="Transparent"
|
||||
CornerRadius="4">
|
||||
<Image
|
||||
Width="15"
|
||||
Height="15"
|
||||
Source="{Binding Icon}"
|
||||
Stretch="Uniform" />
|
||||
</Border>
|
||||
<Grid Grid.Column="0">
|
||||
<Border
|
||||
x:Name="ChildStem"
|
||||
Width="2"
|
||||
Margin="8,0,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
Background="{StaticResource TreeChildLineBrush}"
|
||||
Visibility="Collapsed" />
|
||||
<Border
|
||||
x:Name="ChildBranch"
|
||||
Width="10"
|
||||
Height="2"
|
||||
Margin="8,0,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Background="{StaticResource TreeChildLineBrush}"
|
||||
Visibility="Collapsed" />
|
||||
</Grid>
|
||||
|
||||
<StackPanel
|
||||
Grid.Column="1"
|
||||
Margin="4,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock
|
||||
<Border
|
||||
Grid.Column="1"
|
||||
Width="18"
|
||||
Height="18"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="{StaticResource UiFont}"
|
||||
FontSize="10.5"
|
||||
Foreground="#888888"
|
||||
Text="{Binding Index, StringFormat='[{0}] '}" />
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="{StaticResource UiFont}"
|
||||
FontSize="11.5"
|
||||
Text="{Binding Name}" />
|
||||
</StackPanel>
|
||||
Background="Transparent"
|
||||
CornerRadius="4">
|
||||
<Image
|
||||
Width="14"
|
||||
Height="14"
|
||||
Source="{Binding Icon}"
|
||||
Stretch="Uniform" />
|
||||
</Border>
|
||||
|
||||
<StackPanel
|
||||
x:Name="NodeActions"
|
||||
Grid.Column="2"
|
||||
Margin="0,0,2,0"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal"
|
||||
Visibility="Collapsed">
|
||||
<Button
|
||||
Width="20"
|
||||
Height="20"
|
||||
Margin="1,0"
|
||||
Background="White"
|
||||
BorderBrush="#CDCBCB"
|
||||
BorderThickness="1"
|
||||
Command="{Binding DataContext.MoveNodeUpCommand, RelativeSource={RelativeSource AncestorType=TreeView}}"
|
||||
CommandParameter="{Binding}"
|
||||
Content="上"
|
||||
Cursor="Hand"
|
||||
FontSize="10"
|
||||
ToolTip="上移" />
|
||||
<Button
|
||||
Width="20"
|
||||
Height="20"
|
||||
Margin="1,0"
|
||||
Background="White"
|
||||
BorderBrush="#CDCBCB"
|
||||
BorderThickness="1"
|
||||
Command="{Binding DataContext.MoveNodeDownCommand, RelativeSource={RelativeSource AncestorType=TreeView}}"
|
||||
CommandParameter="{Binding}"
|
||||
Content="下"
|
||||
Cursor="Hand"
|
||||
FontSize="10"
|
||||
ToolTip="下移" />
|
||||
<Button
|
||||
Width="20"
|
||||
Height="20"
|
||||
Margin="1,0"
|
||||
Background="White"
|
||||
BorderBrush="#E05050"
|
||||
BorderThickness="1"
|
||||
Command="{Binding DataContext.DeleteNodeCommand, RelativeSource={RelativeSource AncestorType=TreeView}}"
|
||||
Content="删"
|
||||
Cursor="Hand"
|
||||
FontSize="10"
|
||||
ToolTip="删除" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<StackPanel
|
||||
Grid.Column="2"
|
||||
Margin="3,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="{StaticResource UiFont}"
|
||||
FontSize="10.5"
|
||||
Foreground="#888888"
|
||||
Text="{Binding Index, StringFormat='[{0}] '}" />
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="{StaticResource UiFont}"
|
||||
FontSize="11.5"
|
||||
FontWeight="SemiBold"
|
||||
Text="{Binding Name}" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel
|
||||
x:Name="NodeActions"
|
||||
Grid.Column="3"
|
||||
Margin="0,0,2,0"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal"
|
||||
Visibility="Collapsed">
|
||||
<Button
|
||||
Width="20"
|
||||
Height="20"
|
||||
Margin="1,0"
|
||||
Background="White"
|
||||
BorderBrush="#CDCBCB"
|
||||
BorderThickness="1"
|
||||
Command="{Binding DataContext.MoveNodeUpCommand, RelativeSource={RelativeSource AncestorType=TreeView}}"
|
||||
CommandParameter="{Binding}"
|
||||
Content="↑"
|
||||
Cursor="Hand"
|
||||
FontSize="10"
|
||||
ToolTip="上移" />
|
||||
<Button
|
||||
Width="20"
|
||||
Height="20"
|
||||
Margin="1,0"
|
||||
Background="White"
|
||||
BorderBrush="#CDCBCB"
|
||||
BorderThickness="1"
|
||||
Command="{Binding DataContext.MoveNodeDownCommand, RelativeSource={RelativeSource AncestorType=TreeView}}"
|
||||
CommandParameter="{Binding}"
|
||||
Content="↓"
|
||||
Cursor="Hand"
|
||||
FontSize="10"
|
||||
ToolTip="下移" />
|
||||
<Button
|
||||
Width="20"
|
||||
Height="20"
|
||||
Margin="1,0"
|
||||
Background="White"
|
||||
BorderBrush="#E05050"
|
||||
BorderThickness="1"
|
||||
Command="{Binding DataContext.DeleteNodeCommand, RelativeSource={RelativeSource AncestorType=TreeView}}"
|
||||
Content="×"
|
||||
Cursor="Hand"
|
||||
FontSize="10"
|
||||
ToolTip="删除" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
<DataTemplate.Triggers>
|
||||
<Trigger SourceName="NodeRoot" Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="NodeActions" Property="Visibility" Value="Visible" />
|
||||
<Setter TargetName="NodeCard" Property="Background" Value="#F3F7FB" />
|
||||
<Setter TargetName="NodeCard" Property="BorderBrush" Value="#D7E4F1" />
|
||||
</Trigger>
|
||||
<DataTrigger Binding="{Binding IsPositionChild}" Value="True">
|
||||
<Setter TargetName="ChildStem" Property="Visibility" Value="Visible" />
|
||||
<Setter TargetName="ChildBranch" Property="Visibility" Value="Visible" />
|
||||
</DataTrigger>
|
||||
</DataTemplate.Triggers>
|
||||
</HierarchicalDataTemplate>
|
||||
</TreeView.Resources>
|
||||
@@ -237,7 +277,7 @@
|
||||
<TextBlock Style="{StaticResource LabelStyle}" Text="名称" />
|
||||
<TextBox Style="{StaticResource EditorBox}" Text="{Binding SelectedNode.Name, UpdateSourceTrigger=PropertyChanged}" />
|
||||
|
||||
<UniformGrid Columns="2" Margin="0,0,0,8">
|
||||
<UniformGrid Margin="0,0,0,8" Columns="2">
|
||||
<StackPanel Margin="0,0,6,0">
|
||||
<TextBlock Style="{StaticResource LabelStyle}" Text="索引" />
|
||||
<TextBox Style="{StaticResource EditorBox}" IsReadOnly="True" Text="{Binding SelectedNode.Index, Mode=OneWay}" />
|
||||
@@ -345,7 +385,7 @@
|
||||
|
||||
<GroupBox
|
||||
Style="{StaticResource CompactGroupBox}"
|
||||
Header="标记参数"
|
||||
Header="检测标记"
|
||||
Visibility="{Binding SelectedNode.IsInspectionMarker, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<StackPanel Margin="8,8,8,6">
|
||||
<TextBlock Style="{StaticResource LabelStyle}" Text="标记类型" />
|
||||
|
||||
Reference in New Issue
Block a user