From 04d97fee9da4313fcd7a171643c13ee615466db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BC=9F?= Date: Mon, 27 Apr 2026 09:05:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E9=87=8F=E5=B7=A5=E5=85=B7=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E5=89=8D=E6=A3=80=E6=9F=A5=E5=9B=BE=E5=83=8F=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=B7=B2=E5=8A=A0=E8=BD=BD=EF=BC=8C=E4=BD=BF=E7=94=A8?= =?UTF-8?q?HexMessageBox=E5=BC=B9=E6=A1=86=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XplorePlane/ViewModels/Main/MainViewModel.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/XplorePlane/ViewModels/Main/MainViewModel.cs b/XplorePlane/ViewModels/Main/MainViewModel.cs index 14f5ecb..fe23b8f 100644 --- a/XplorePlane/ViewModels/Main/MainViewModel.cs +++ b/XplorePlane/ViewModels/Main/MainViewModel.cs @@ -1,4 +1,4 @@ -using Prism.Commands; +using Prism.Commands; using Prism.Events; using Prism.Ioc; using Prism.Mvvm; @@ -14,6 +14,7 @@ using XplorePlane.ViewModels.Cnc; using XplorePlane.Views; using XplorePlane.Views.Cnc; using XP.Common.Logging.Interfaces; +using XP.Common.GeneralForm.Views; using XP.Common.PdfViewer.Interfaces; using XP.Hardware.MotionControl.Abstractions; @@ -449,32 +450,49 @@ namespace XplorePlane.ViewModels #region 测量命令实现 + private bool CheckImageLoaded() + { + try + { + var viewportVm = _containerProvider.Resolve(); + if (viewportVm?.ImageSource != null) return true; + } + catch { } + HexMessageBox.Show("请先加载图像", MessageBoxButton.OK, MessageBoxImage.Information); + return false; + } + private void ExecutePointDistanceMeasure() { + if (!CheckImageLoaded()) return; _logger.Info("点点距测量功能已触发"); _eventAggregator.GetEvent().Publish(MeasurementToolMode.PointDistance); } private void ExecutePointLineDistanceMeasure() { + if (!CheckImageLoaded()) return; _logger.Info("点线距测量功能已触发"); _eventAggregator.GetEvent().Publish(MeasurementToolMode.PointLineDistance); } private void ExecuteAngleMeasure() { + if (!CheckImageLoaded()) return; _logger.Info("角度测量功能已触发"); _eventAggregator.GetEvent().Publish(MeasurementToolMode.Angle); } private void ExecuteThroughHoleFillRateMeasure() { + if (!CheckImageLoaded()) return; _logger.Info("通孔填锡率测量功能已触发"); _eventAggregator.GetEvent().Publish(MeasurementToolMode.ThroughHoleFillRate); } private void ExecuteBgaVoidMeasure() { + if (!CheckImageLoaded()) return; _logger.Info("BGA空隙测量功能已触发"); _eventAggregator.GetEvent().Publish(MeasurementToolMode.BgaVoid); }