#初步CNC编辑界面

This commit is contained in:
zhengxuan.zhang
2026-04-21 13:19:53 +08:00
parent b966e0b8e8
commit 8beed66ef0
3 changed files with 43 additions and 81 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ namespace XplorePlane.ViewModels
{
public class MainViewModel : BindableBase
{
private const double CncEditorHostWidth = 1162d;
private const double CncEditorHostWidth = 710d;
private readonly ILoggerService _logger;
private readonly IContainerProvider _containerProvider;
private readonly IEventAggregator _eventAggregator;
+26 -20
View File
@@ -9,7 +9,7 @@
xmlns:views="clr-namespace:XplorePlane.Views"
xmlns:vm="clr-namespace:XplorePlane.ViewModels.Cnc"
d:DesignHeight="760"
d:DesignWidth="600"
d:DesignWidth="702"
prism:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d">
@@ -69,8 +69,8 @@
</UserControl.Resources>
<Border
Width="1162"
MinWidth="1162"
Width="702"
MinWidth="702"
HorizontalAlignment="Left"
Background="{StaticResource PanelBg}"
BorderBrush="{StaticResource PanelBorder}"
@@ -78,11 +78,11 @@
CornerRadius="4">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="248" />
<ColumnDefinition Width="200" />
<ColumnDefinition Width="1" />
<ColumnDefinition Width="292" />
<ColumnDefinition Width="250" />
<ColumnDefinition Width="1" />
<ColumnDefinition Width="620" />
<ColumnDefinition Width="250" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
@@ -100,15 +100,17 @@
<StackPanel>
<TextBlock
FontFamily="{StaticResource UiFont}"
FontSize="14"
FontSize="13"
FontWeight="SemiBold"
Text="{Binding ProgramName, TargetNullValue=CNC编辑}" />
Text="{Binding ProgramName, TargetNullValue=CNC编辑}"
TextWrapping="Wrap" />
<TextBlock
Margin="0,3,0,0"
FontFamily="{StaticResource UiFont}"
FontSize="10.5"
FontSize="10"
Foreground="#666666"
Text="模块节点下会自动显示标记、等待、消息等子节点" />
Text="模块节点下会自动显示标记、等待、消息等子节点"
TextWrapping="Wrap" />
</StackPanel>
</Border>
@@ -293,7 +295,7 @@
<GroupBox
Style="{StaticResource CompactGroupBox}"
Header="采集参数"
Header="保存参数"
Visibility="{Binding SelectedNode.IsSaveNode, Converter={StaticResource BoolToVisibilityConverter}}">
<StackPanel Margin="8,8,8,6">
<CheckBox Style="{StaticResource EditorCheck}" Content="射线源开启" IsChecked="{Binding SelectedNode.IsRayOn}" />
@@ -312,7 +314,7 @@
<GroupBox
Style="{StaticResource CompactGroupBox}"
Header="采集参数"
Header="保存参数"
Visibility="{Binding SelectedNode.IsSaveNodeWithImage, Converter={StaticResource BoolToVisibilityConverter}}">
<StackPanel Margin="8,8,8,6">
<CheckBox Style="{StaticResource EditorCheck}" Content="射线源开启" IsChecked="{Binding SelectedNode.IsRayOn}" />
@@ -398,15 +400,17 @@
<StackPanel>
<TextBlock
FontFamily="{StaticResource UiFont}"
FontSize="14"
FontSize="13"
FontWeight="SemiBold"
Text="未选择节点" />
Text="未选择节点"
TextWrapping="Wrap" />
<TextBlock
Margin="0,6,0,0"
FontFamily="{StaticResource UiFont}"
FontSize="11"
FontSize="10"
Foreground="#666666"
Text="从左侧树中选择一个节点后,这里会显示可编辑的参数。" />
Text="从左侧树中选择一个节点后,这里会显示可编辑的参数。"
TextWrapping="Wrap" />
</StackPanel>
</Border>
</Grid>
@@ -434,15 +438,17 @@
<StackPanel>
<TextBlock
FontFamily="{StaticResource UiFont}"
FontSize="14"
FontSize="13"
FontWeight="SemiBold"
Text="未选择检测模块" />
Text="未选择检测模块"
TextWrapping="Wrap" />
<TextBlock
Margin="0,6,0,0"
FontFamily="{StaticResource UiFont}"
FontSize="11"
FontSize="10"
Foreground="#666666"
Text="请选择一个检测模块节点后,在这里拖拽算子并配置参数。" />
Text="请选择一个检测模块节点后,在这里拖拽算子并配置参数。"
TextWrapping="Wrap" />
</StackPanel>
</Border>
</Grid>
@@ -11,25 +11,23 @@
<UserControl.Resources>
<SolidColorBrush x:Key="PanelBg" Color="White" />
<SolidColorBrush x:Key="PanelBorder" Color="#cdcbcb" />
<SolidColorBrush x:Key="PanelBorder" Color="#CDCBCB" />
<SolidColorBrush x:Key="SeparatorBrush" Color="#E0E0E0" />
<SolidColorBrush x:Key="AccentBlue" Color="#E3F0FF" />
<FontFamily x:Key="CsdFont">Microsoft YaHei UI</FontFamily>
<!-- 节点项样式 -->
<Style x:Key="PipelineNodeItemStyle" TargetType="ListBoxItem">
<Setter Property="Padding" Value="0" />
<Setter Property="Margin" Value="0" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
<!-- 工具栏按钮样式 -->
<Style x:Key="ToolbarBtn" TargetType="Button">
<Setter Property="Width" Value="28" />
<Setter Property="Width" Value="52" />
<Setter Property="Height" Value="28" />
<Setter Property="Margin" Value="2,0" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="#cdcbcb" />
<Setter Property="BorderBrush" Value="#CDCBCB" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="FontFamily" Value="Microsoft YaHei UI" />
<Setter Property="FontSize" Value="11" />
@@ -44,21 +42,13 @@
CornerRadius="4">
<Grid>
<Grid.RowDefinitions>
<!-- Row 0: 工具栏 -->
<RowDefinition Height="Auto" />
<!-- Row 2: 流水线节点列表 -->
<RowDefinition Height="2*" MinHeight="180" />
<!-- Row 3: 分隔线 -->
<RowDefinition Height="Auto" />
<!-- Row 4: 参数面板 -->
<RowDefinition Height="2*" MinHeight="80" />
<!-- Row 5: 状态栏 -->
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!-- 标题栏:流水线名称 + 设备选择 -->
<!-- 工具栏 -->
<Border
Grid.Row="0"
Padding="6,4"
@@ -76,51 +66,23 @@
Command="{Binding SavePipelineCommand}"
Content="保存"
Style="{StaticResource ToolbarBtn}"
ToolTip="保存流水线" />
ToolTip="保存当前检测模块流水线" />
<Button
Width="43"
Width="60"
Command="{Binding SaveAsPipelineCommand}"
Content="另存为"
Style="{StaticResource ToolbarBtn}"
ToolTip="另存为" />
ToolTip="导出当前检测模块流水线" />
<Button
Width="43"
Width="52"
Command="{Binding LoadPipelineCommand}"
Content="加载"
Style="{StaticResource ToolbarBtn}"
ToolTip="加载流水线" />
<!--
<Button
Width="64"
Command="{Binding LoadImageCommand}"
Content="加载图像"
Style="{StaticResource ToolbarBtn}"
ToolTip="加载输入图像" />
<Button
Command="{Binding ExecutePipelineCommand}"
Content="▶"
Style="{StaticResource ToolbarBtn}"
ToolTip="执行流水线" />
<Button
Command="{Binding CancelExecutionCommand}"
Content="■"
Style="{StaticResource ToolbarBtn}"
ToolTip="取消执行" />
<Button
Command="{Binding DeletePipelineCommand}"
Content="🗑"
Style="{StaticResource ToolbarBtn}"
ToolTip="工具箱" />
-->
ToolTip="流水线模板加载到当前检测模块" />
</StackPanel>
</Grid>
</Border>
<!-- 流水线节点列表(拖拽目标) -->
<ListBox
x:Name="PipelineListBox"
Grid.Row="1"
@@ -139,7 +101,6 @@
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<!-- 连接线列:上半段 + 下半段 -->
<Line
x:Name="TopLine"
HorizontalAlignment="Center"
@@ -160,7 +121,6 @@
Y1="0"
Y2="14" />
<!-- 算子图标 -->
<Border
Grid.Column="0"
Width="28"
@@ -178,7 +138,6 @@
Text="{Binding IconPath}" />
</Border>
<!-- 算子名称 -->
<TextBlock
Grid.Column="1"
Margin="6,0,0,0"
@@ -187,7 +146,6 @@
FontSize="12"
Text="{Binding DisplayName}" />
<!-- 操作按钮:上移 / 下移 / 删除(悬停显示) -->
<StackPanel
x:Name="NodeActions"
Grid.Column="2"
@@ -200,11 +158,11 @@
Height="22"
Margin="1,0"
Background="Transparent"
BorderBrush="#cdcbcb"
BorderBrush="#CDCBCB"
BorderThickness="1"
Command="{Binding DataContext.MoveNodeUpCommand, RelativeSource={RelativeSource AncestorType=ListBox}}"
CommandParameter="{Binding}"
Content=""
Content=""
Cursor="Hand"
FontSize="10"
ToolTip="上移" />
@@ -213,11 +171,11 @@
Height="22"
Margin="1,0"
Background="Transparent"
BorderBrush="#cdcbcb"
BorderBrush="#CDCBCB"
BorderThickness="1"
Command="{Binding DataContext.MoveNodeDownCommand, RelativeSource={RelativeSource AncestorType=ListBox}}"
CommandParameter="{Binding}"
Content=""
Content=""
Cursor="Hand"
FontSize="10"
ToolTip="下移" />
@@ -230,7 +188,7 @@
BorderThickness="1"
Command="{Binding DataContext.RemoveOperatorCommand, RelativeSource={RelativeSource AncestorType=ListBox}}"
CommandParameter="{Binding}"
Content=""
Content=""
Cursor="Hand"
FontSize="10"
ToolTip="删除" />
@@ -247,13 +205,12 @@
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!-- 分隔线 -->
<Rectangle
Grid.Row="2"
Height="1"
Fill="{StaticResource SeparatorBrush}" />
<!-- 参数面板 -->
<ScrollViewer
Grid.Row="3"
HorizontalScrollBarVisibility="Disabled"
@@ -284,14 +241,14 @@
<TextBox
Grid.Column="1"
Padding="4,2"
BorderBrush="#cdcbcb"
BorderBrush="#CDCBCB"
BorderThickness="1"
FontFamily="Microsoft YaHei UI"
FontSize="11"
Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}">
<TextBox.Style>
<Style TargetType="TextBox">
<Setter Property="BorderBrush" Value="#cdcbcb" />
<Setter Property="BorderBrush" Value="#CDCBCB" />
<Setter Property="Background" Value="White" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsValueValid}" Value="False">
@@ -309,7 +266,6 @@
</StackPanel>
</ScrollViewer>
<!-- 状态栏 -->
<Border
Grid.Row="4"
Padding="6,4"