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) =>
{