CNC编辑模式与常规模式切换

This commit is contained in:
zhengxuan.zhang
2026-04-20 21:36:46 +08:00
parent 33fef1b6eb
commit c91b55785e
12 changed files with 103 additions and 169 deletions
@@ -1878,10 +1878,7 @@
"Telerik.UI.for.Wpf.NetCore.Xaml": "2024.1.408"
},
"runtime": {
"XP.Common.dll": {
"assemblyVersion": "1.4.16.1",
"fileVersion": "1.4.16.1"
}
"XP.Common.dll": {}
},
"resources": {
"en-US/XP.Common.resources.dll": {
@@ -34,11 +34,4 @@
<ProjectReference Include="..\XplorePlane\XplorePlane.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="ImageProcessing.Core">
<HintPath>..\XplorePlane\Libs\ImageProcessing\ImageProcessing.Core.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
</Project>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 174 KiB

+41 -2
View File
@@ -1,4 +1,4 @@
using Prism.Commands;
using Prism.Commands;
using Prism.Events;
using Prism.Ioc;
using Prism.Mvvm;
@@ -10,6 +10,8 @@ using System.IO;
using System.Windows;
using System.Windows.Media.Imaging;
using XplorePlane.Events;
using XplorePlane.Views;
using XplorePlane.Views.Cnc;
using XP.Common.Logging.Interfaces;
using XP.Common.PdfViewer.Interfaces;
using XP.Hardware.MotionControl.Abstractions;
@@ -62,6 +64,20 @@ namespace XplorePlane.ViewModels
public DelegateCommand OpenLanguageSwitcherCommand { get; }
public DelegateCommand OpenRealTimeLogViewerCommand { get; }
/// <summary>右侧图像区域内容 | Right-side image panel content</summary>
public object ImagePanelContent
{
get => _imagePanelContent;
set => SetProperty(ref _imagePanelContent, value);
}
/// <summary>右侧图像区域宽度 | Right-side image panel width</summary>
public GridLength ImagePanelWidth
{
get => _imagePanelWidth;
set => SetProperty(ref _imagePanelWidth, value);
}
// 窗口引用(单例窗口防止重复打开)
private Window _motionDebugWindow;
private Window _detectorConfigWindow;
@@ -69,6 +85,9 @@ namespace XplorePlane.ViewModels
private Window _realTimeLogViewerWindow;
private Window _toolboxWindow;
private Window _raySourceConfigWindow;
private object _imagePanelContent;
private GridLength _imagePanelWidth = new GridLength(350);
private bool _isCncEditorMode;
public MainViewModel(ILoggerService logger, IContainerProvider containerProvider, IEventAggregator eventAggregator)
{
@@ -90,7 +109,7 @@ namespace XplorePlane.ViewModels
OpenImageProcessingCommand = new DelegateCommand(() => ShowWindow(new Views.ImageProcessingWindow(), "图像处理"));
LoadImageCommand = new DelegateCommand(ExecuteLoadImage);
OpenPipelineEditorCommand = new DelegateCommand(() => ShowWindow(new Views.PipelineEditorWindow(), "流水线编辑器"));
OpenCncEditorCommand = new DelegateCommand(() => ShowWindow(new Views.Cnc.CncEditorWindow(), "CNC 编辑器"));
OpenCncEditorCommand = new DelegateCommand(ExecuteOpenCncEditor);
OpenMatrixEditorCommand = new DelegateCommand(() => ShowWindow(new Views.Cnc.MatrixEditorWindow(), "矩阵编排"));
OpenToolboxCommand = new DelegateCommand(ExecuteOpenToolbox);
OpenLibraryVersionsCommand = new DelegateCommand(() => ShowWindow(new Views.LibraryVersionsWindow(), "关于"));
@@ -109,6 +128,9 @@ namespace XplorePlane.ViewModels
OpenLanguageSwitcherCommand = new DelegateCommand(ExecuteOpenLanguageSwitcher);
OpenRealTimeLogViewerCommand = new DelegateCommand(ExecuteOpenRealTimeLogViewer);
ImagePanelContent = new PipelineEditorView();
ImagePanelWidth = new GridLength(350);
_logger.Info("MainViewModel 已初始化");
}
@@ -153,6 +175,23 @@ namespace XplorePlane.ViewModels
ShowOrActivate(_toolboxWindow, w => _toolboxWindow = w, () => new Views.OperatorToolboxWindow(), "算子工具箱");
}
private void ExecuteOpenCncEditor()
{
if (_isCncEditorMode)
{
ImagePanelContent = new PipelineEditorView();
ImagePanelWidth = new GridLength(350);
_isCncEditorMode = false;
_logger.Info("已退出 CNC 编辑模式");
return;
}
ImagePanelContent = new CncPageView();
ImagePanelWidth = new GridLength(430);
_isCncEditorMode = true;
_logger.Info("CNC 编辑器已切换到主界面图像区域");
}
private void ExecuteOpenUserManual()
{
try
+6 -3
View File
@@ -1,12 +1,15 @@
<Window
<Window
x:Class="XplorePlane.Views.Cnc.CncEditorWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cnc="clr-namespace:XplorePlane.Views.Cnc"
Title="CNC 编辑器"
Width="350"
Width="544"
Height="750"
MinWidth="544"
MinHeight="750"
ResizeMode="CanResize"
ShowInTaskbar="False"
WindowStartupLocation="CenterOwner">
<cnc:CncPageView />
</Window>
</Window>
+12 -135
View File
@@ -1,32 +1,28 @@
<!-- CNC 编辑器主页面视图 | CNC editor main page view -->
<UserControl
<UserControl
x:Class="XplorePlane.Views.Cnc.CncPageView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://prismlibrary.com/"
xmlns:views="clr-namespace:XplorePlane.Views"
d:DesignHeight="700"
d:DesignWidth="350"
d:DesignWidth="544"
prism:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d">
<UserControl.Resources>
<!-- 面板背景和边框颜色 | Panel background and border colors -->
<SolidColorBrush x:Key="PanelBg" Color="White" />
<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>
<!-- 节点列表项样式 | Node list item style -->
<Style x:Key="CncNodeItemStyle" TargetType="ListBoxItem">
<Setter Property="Padding" Value="0" />
<Setter Property="Margin" Value="0" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
<!-- 工具栏按钮样式 | Toolbar button style -->
<Style x:Key="ToolbarBtn" TargetType="Button">
<Setter Property="Height" Value="28" />
<Setter Property="Margin" Value="2,0" />
@@ -47,110 +43,16 @@
CornerRadius="4">
<Grid>
<Grid.RowDefinitions>
<!-- Row 0: 工具栏 | Toolbar -->
<RowDefinition Height="Auto" />
<!-- Row 1: 主内容区(左侧节点列表 + 右侧参数面板)| Main content (left: node list, right: parameter panel) -->
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- ═══ 工具栏:节点插入命令 + 文件操作命令 | Toolbar: node insert commands + file operation commands ═══ -->
<Border
Grid.Row="0"
Padding="6,4"
Background="#F5F5F5"
BorderBrush="{StaticResource PanelBorder}"
BorderThickness="0,0,0,1">
<WrapPanel Orientation="Horizontal">
<!-- 文件操作按钮 | File operation buttons -->
<Button
Command="{Binding NewProgramCommand}"
Content="新建"
Style="{StaticResource ToolbarBtn}"
ToolTip="新建程序 | New Program" />
<Button
Command="{Binding SaveProgramCommand}"
Content="保存"
Style="{StaticResource ToolbarBtn}"
ToolTip="保存程序 | Save Program" />
<Button
Command="{Binding LoadProgramCommand}"
Content="加载"
Style="{StaticResource ToolbarBtn}"
ToolTip="加载程序 | Load Program" />
<Button
Command="{Binding ExportCsvCommand}"
Content="导出CSV"
Style="{StaticResource ToolbarBtn}"
ToolTip="导出 CSV | Export CSV" />
<!-- 分隔线 | Separator -->
<Rectangle
Width="1"
Height="20"
Margin="4,0"
Fill="{StaticResource SeparatorBrush}" />
<!-- 节点插入按钮(9 种节点类型)| Node insert buttons (9 node types) -->
<Button
Command="{Binding InsertReferencePointCommand}"
Content="参考点"
Style="{StaticResource ToolbarBtn}"
ToolTip="插入参考点 | Insert Reference Point" />
<Button
Command="{Binding InsertSaveNodeWithImageCommand}"
Content="保存+图"
Style="{StaticResource ToolbarBtn}"
ToolTip="保存节点并保存图片 | Save Node With Image" />
<Button
Command="{Binding InsertSaveNodeCommand}"
Content="保存节点"
Style="{StaticResource ToolbarBtn}"
ToolTip="仅保存节点 | Save Node" />
<Button
Command="{Binding InsertSavePositionCommand}"
Content="保存位置"
Style="{StaticResource ToolbarBtn}"
ToolTip="保存位置 | Save Position" />
<Button
Command="{Binding InsertInspectionModuleCommand}"
Content="检测模块"
Style="{StaticResource ToolbarBtn}"
ToolTip="插入检测模块 | Insert Inspection Module" />
<Button
Command="{Binding InsertInspectionMarkerCommand}"
Content="检测标记"
Style="{StaticResource ToolbarBtn}"
ToolTip="插入检测标记 | Insert Inspection Marker" />
<Button
Command="{Binding InsertPauseDialogCommand}"
Content="停顿"
Style="{StaticResource ToolbarBtn}"
ToolTip="插入停顿对话框 | Insert Pause Dialog" />
<Button
Command="{Binding InsertWaitDelayCommand}"
Content="延时"
Style="{StaticResource ToolbarBtn}"
ToolTip="设置等待延时 | Insert Wait Delay" />
<Button
Command="{Binding InsertCompleteProgramCommand}"
Content="完成"
Style="{StaticResource ToolbarBtn}"
ToolTip="完成程序 | Complete Program" />
</WrapPanel>
</Border>
<!-- ═══ 主内容区:左侧节点列表 + 右侧参数面板 | Main content: left node list + right parameter panel ═══ -->
<Grid Grid.Row="1">
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<!-- 左侧:节点列表 | Left: node list -->
<ColumnDefinition Width="3*" MinWidth="150" />
<!-- 分隔线 | Splitter -->
<ColumnDefinition Width="Auto" />
<!-- 右侧:参数面板 | Right: parameter panel -->
<ColumnDefinition Width="2*" MinWidth="150" />
<ColumnDefinition Width="250" MinWidth="230" />
<ColumnDefinition Width="1" />
<ColumnDefinition Width="*" MinWidth="260" />
</Grid.ColumnDefinitions>
<!-- ── 左侧:CNC 节点列表 | Left: CNC node list ── -->
<ListBox
x:Name="CncNodeListBox"
Grid.Column="0"
@@ -164,15 +66,11 @@
<DataTemplate>
<Grid x:Name="NodeRoot" MinHeight="40">
<Grid.ColumnDefinitions>
<!-- 图标列 | Icon column -->
<ColumnDefinition Width="40" />
<!-- 名称列 | Name column -->
<ColumnDefinition Width="*" />
<!-- 操作按钮列 | Action buttons column -->
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<!-- 节点图标 | Node icon -->
<Border
Grid.Column="0"
Width="28"
@@ -190,7 +88,6 @@
Stretch="Uniform" />
</Border>
<!-- 节点序号和名称 | Node index and name -->
<StackPanel
Grid.Column="1"
Margin="6,0,0,0"
@@ -209,7 +106,6 @@
Text="{Binding Name}" />
</StackPanel>
<!-- 悬停操作按钮:上移 / 下移 / 删除 | Hover actions: MoveUp / MoveDown / Delete -->
<StackPanel
x:Name="NodeActions"
Grid.Column="2"
@@ -229,7 +125,7 @@
Content="▲"
Cursor="Hand"
FontSize="10"
ToolTip="上移 | Move Up" />
ToolTip="上移" />
<Button
Width="22"
Height="22"
@@ -242,7 +138,7 @@
Content="▼"
Cursor="Hand"
FontSize="10"
ToolTip="下移 | Move Down" />
ToolTip="下移" />
<Button
Width="22"
Height="22"
@@ -254,11 +150,10 @@
Content="✕"
Cursor="Hand"
FontSize="10"
ToolTip="删除 | Delete" />
ToolTip="删除" />
</StackPanel>
</Grid>
<DataTemplate.Triggers>
<!-- 鼠标悬停时显示操作按钮 | Show action buttons on mouse hover -->
<Trigger SourceName="NodeRoot" Property="IsMouseOver" Value="True">
<Setter TargetName="NodeActions" Property="Visibility" Value="Visible" />
</Trigger>
@@ -267,31 +162,13 @@
</ListBox.ItemTemplate>
</ListBox>
<!-- 垂直分隔线 | Vertical separator -->
<Rectangle
Grid.Column="1"
Width="1"
Fill="{StaticResource SeparatorBrush}" />
<!-- ── 右侧:参数面板(根据节点类型动态渲染)| Right: parameter panel (dynamic rendering by node type) ── -->
<ScrollViewer
Grid.Column="2"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto">
<StackPanel Margin="8,6">
<TextBlock
Margin="0,0,0,4"
FontFamily="{StaticResource CsdFont}"
FontSize="11"
FontWeight="Bold"
Foreground="#555"
Text="参数配置" />
<!-- 动态参数内容区域(占位:根据 SelectedNode 类型渲染)| Dynamic parameter content area (placeholder for node-type-based rendering) -->
<ContentControl Content="{Binding SelectedNode}" />
</StackPanel>
</ScrollViewer>
<views:PipelineEditorView Grid.Column="2" />
</Grid>
</Grid>
</Border>
</UserControl>
</UserControl>
+22 -3
View File
@@ -1,16 +1,35 @@
using System;
using System.Windows;
using System.Windows.Controls;
using Prism.Ioc;
using XplorePlane.ViewModels.Cnc;
namespace XplorePlane.Views.Cnc
{
/// <summary>
/// CNC 编辑器主页面视图(MVVM 模式,逻辑在 ViewModel 中)
/// CNC editor main page view (MVVM pattern, logic in ViewModel)
/// CNC editor main page view.
/// </summary>
public partial class CncPageView : UserControl
{
public CncPageView()
{
InitializeComponent();
Loaded += OnLoaded;
}
private void OnLoaded(object sender, RoutedEventArgs e)
{
if (DataContext is not CncEditorViewModel)
{
try
{
DataContext = ContainerLocator.Current?.Resolve<CncEditorViewModel>();
}
catch (Exception)
{
// keep existing DataContext if resolution fails
}
}
}
}
}
}
@@ -96,7 +96,7 @@
Content="加载图像"
Style="{StaticResource ToolbarBtn}"
ToolTip="加载输入图像" />
-->
<Button
Command="{Binding ExecutePipelineCommand}"
Content="▶"
@@ -112,6 +112,7 @@
Content="🗑"
Style="{StaticResource ToolbarBtn}"
ToolTip="工具箱" />
-->
</StackPanel>
</Grid>
</Border>
+2 -3
View File
@@ -1,10 +1,9 @@
<UserControl
<UserControl
x:Class="XplorePlane.Views.ImagePanelView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:XplorePlane.Views"
d:DesignHeight="400"
d:DesignWidth="250"
mc:Ignorable="d">
@@ -17,6 +16,6 @@
<TextBlock Margin="8,4" HorizontalAlignment="Left" VerticalAlignment="Center"
FontWeight="SemiBold" Foreground="#333333" Text="图像" />
</Border>
<views:PipelineEditorView Grid.Row="1" />
<ContentControl Grid.Row="1" Content="{Binding ImagePanelContent}" />
</Grid>
</UserControl>
+14 -11
View File
@@ -16,7 +16,7 @@
Height="1040"
d:DesignWidth="1580"
Background="#F5F5F5"
Icon="pack://application:,,,/XplorerPlane.ico"
Icon="pack://application:,,,/XplorePlane;component/XplorerPlane.ico"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d">
<Window.Resources>
@@ -284,16 +284,9 @@
Command="{Binding OpenCncEditorCommand}"
Size="Large"
SmallImage="/Assets/Icons/cnc.png"
Text="CNC 编辑" />
Text="CNC 编辑" />
<!-- 矩阵编排入口按钮 -->
<telerik:RadRibbonButton
telerik:ScreenTip.Description="打开矩阵编排窗口,配置多工件阵列检测方案"
telerik:ScreenTip.Title="矩阵编排"
Command="{Binding OpenMatrixEditorCommand}"
Size="Large"
SmallImage="/Assets/Icons/matrix.png"
Text="矩阵编排" />
<!-- CNC 节点快捷工具 -->
<StackPanel>
@@ -342,6 +335,16 @@
SmallImage="/Assets/Icons/wait.png"
Text="插入等待" />
</StackPanel>
<!-- 矩阵编排入口按钮 -->
<telerik:RadRibbonButton
telerik:ScreenTip.Description="打开矩阵编排窗口,配置多工件阵列检测方案"
telerik:ScreenTip.Title="矩阵编排"
Command="{Binding OpenMatrixEditorCommand}"
Size="Large"
SmallImage="/Assets/Icons/matrix.png"
Text="矩阵编排" />
</telerik:RadRibbonGroup>
<telerik:RadRibbonGroup Header="高级模块" IsEnabled="{Binding Path=CellsGroup.IsEnabled}">
@@ -459,7 +462,7 @@
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="NavColumn" Width="0" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="350" />
<ColumnDefinition Width="{Binding ImagePanelWidth}" />
<ColumnDefinition Width="350" />
</Grid.ColumnDefinitions>
+3
View File
@@ -146,6 +146,9 @@
<Link>Libs\Hardware\zh-TW\%(Filename)%(Extension)</Link>
</None>
<Compile Remove="Views\Main\MainWindowB.xaml.cs" />
<Content Include="XplorerPlane.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Resource Include="XplorerPlane.ico" />
Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 92 KiB