From ca67cbde2b7616468a90adc7327296f5521c2d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BC=9F?= Date: Tue, 28 Apr 2026 17:38:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E7=95=8C=E9=9D=A2:=20BGA=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E6=8C=89=E9=92=AE=E5=85=B3=E8=81=94=E3=80=81ContextMe?= =?UTF-8?q?nu=E5=8A=A8=E6=80=81=E5=88=9B=E5=BB=BA=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E9=98=BB=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XplorePlane/ViewModels/Main/MainViewModel.cs | 22 ++++++++++++++++ XplorePlane/Views/Main/MainWindow.xaml | 7 +++-- XplorePlane/Views/Main/ViewportPanelView.xaml | 12 --------- .../Views/Main/ViewportPanelView.xaml.cs | 26 +++++++++++++++++++ 4 files changed, 51 insertions(+), 16 deletions(-) diff --git a/XplorePlane/ViewModels/Main/MainViewModel.cs b/XplorePlane/ViewModels/Main/MainViewModel.cs index 5d5cdc7..d2ed694 100644 --- a/XplorePlane/ViewModels/Main/MainViewModel.cs +++ b/XplorePlane/ViewModels/Main/MainViewModel.cs @@ -91,6 +91,7 @@ namespace XplorePlane.ViewModels public DelegateCommand AngleMeasureCommand { get; } public DelegateCommand ThroughHoleFillRateMeasureCommand { get; } public DelegateCommand BgaVoidMeasureCommand { get; } + public DelegateCommand BgaDetectionCommand { get; } public DelegateCommand BubbleMeasureCommand { get; } // 辅助线命令 @@ -201,6 +202,7 @@ namespace XplorePlane.ViewModels AngleMeasureCommand = new DelegateCommand(ExecuteAngleMeasure); ThroughHoleFillRateMeasureCommand = new DelegateCommand(ExecuteThroughHoleFillRateMeasure); BgaVoidMeasureCommand = new DelegateCommand(ExecuteBgaVoidMeasure); + BgaDetectionCommand = new DelegateCommand(ExecuteBgaDetection); BubbleMeasureCommand = new DelegateCommand(ExecuteBubbleMeasure); // 辅助线命令 @@ -531,6 +533,26 @@ namespace XplorePlane.ViewModels _bgaMeasurePanel.Show(); } + private Window _bgaDetectionPanel; + + private void ExecuteBgaDetection() + { + if (!CheckImageLoaded()) return; + _logger.Info("BGA检测功能已触发"); + + if (_bgaDetectionPanel != null && _bgaDetectionPanel.IsVisible) + { + _bgaDetectionPanel.Activate(); + return; + } + + _bgaDetectionPanel = new Views.ImageProcessing.BgaDetectionPanel + { + Owner = System.Windows.Application.Current.MainWindow + }; + _bgaDetectionPanel.Show(); + } + private Window _bubbleMeasurePanel; private void ExecuteBubbleMeasure() diff --git a/XplorePlane/Views/Main/MainWindow.xaml b/XplorePlane/Views/Main/MainWindow.xaml index 47b6ea5..f9b886a 100644 --- a/XplorePlane/Views/Main/MainWindow.xaml +++ b/XplorePlane/Views/Main/MainWindow.xaml @@ -348,11 +348,10 @@ - - - - - - - - - - - - diff --git a/XplorePlane/Views/Main/ViewportPanelView.xaml.cs b/XplorePlane/Views/Main/ViewportPanelView.xaml.cs index 743a755..5a16883 100644 --- a/XplorePlane/Views/Main/ViewportPanelView.xaml.cs +++ b/XplorePlane/Views/Main/ViewportPanelView.xaml.cs @@ -31,6 +31,32 @@ namespace XplorePlane.Views InitializeComponent(); DataContextChanged += OnDataContextChanged; + // 动态创建右键菜单,支持条件性阻止弹出 + var menu = new System.Windows.Controls.ContextMenu(); + menu.Items.Add(new System.Windows.Controls.MenuItem { Header = "放大" }); + menu.Items.Add(new System.Windows.Controls.MenuItem { Header = "缩小" }); + menu.Items.Add(new System.Windows.Controls.MenuItem { Header = "适应窗口" }); + menu.Items.Add(new System.Windows.Controls.Separator()); + menu.Items.Add(new System.Windows.Controls.MenuItem { Header = "保存原始图像" }); + menu.Items.Add(new System.Windows.Controls.MenuItem { Header = "保存结果图像" }); + menu.Items.Add(new System.Windows.Controls.Separator()); + menu.Items.Add(new System.Windows.Controls.MenuItem { Header = "清除所有测量" }); + ((System.Windows.Controls.MenuItem)menu.Items[0]).Click += ZoomIn_Click; + ((System.Windows.Controls.MenuItem)menu.Items[1]).Click += ZoomOut_Click; + ((System.Windows.Controls.MenuItem)menu.Items[2]).Click += ResetView_Click; + ((System.Windows.Controls.MenuItem)menu.Items[4]).Click += SaveOriginalImage_Click; + ((System.Windows.Controls.MenuItem)menu.Items[5]).Click += SaveResultImage_Click; + ((System.Windows.Controls.MenuItem)menu.Items[7]).Click += ClearAllMeasurements_Click; + RoiCanvas.ContextMenu = menu; + RoiCanvas.ContextMenuOpening += (s, e) => + { + if (RoiCanvas.SuppressContextMenu) + { + RoiCanvas.SuppressContextMenu = false; + e.Handled = true; + } + }; + // 测量事件 → 更新主界面状态栏 RoiCanvas.MeasureCompleted += (s, e) => {