主界面: BGA检测按钮关联、ContextMenu动态创建支持条件阻止
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -348,11 +348,10 @@
|
||||
</telerik:RadRibbonGroup.Variants>
|
||||
|
||||
<telerik:RadRibbonButton
|
||||
telerik:ScreenTip.Description="Create a link in your document for quick access to webpages and files. Hyperlinks can also take you to places in your document."
|
||||
telerik:ScreenTip.Title="Add a Hyperlink"
|
||||
Command="{Binding Path=ShowHyperlinkDialog.Command}"
|
||||
telerik:ScreenTip.Description="自动检测BGA焊球并计算空隙率"
|
||||
telerik:ScreenTip.Title="BGA检测"
|
||||
Command="{Binding BgaDetectionCommand}"
|
||||
Content="BGA检测"
|
||||
IsEnabled="{Binding Path=ShowHyperlinkDialog.IsEnabled}"
|
||||
Size="Large"
|
||||
SmallImage="/Assets/Icons/bga.png" />
|
||||
<telerik:RadRibbonButton
|
||||
|
||||
@@ -33,18 +33,6 @@
|
||||
x:Name="RoiCanvas"
|
||||
Background="White"
|
||||
ImageSource="{Binding ImageSource}">
|
||||
<roi:PolygonRoiCanvas.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="放大" Click="ZoomIn_Click" />
|
||||
<MenuItem Header="缩小" Click="ZoomOut_Click" />
|
||||
<MenuItem Header="适应窗口" Click="ResetView_Click" />
|
||||
<Separator />
|
||||
<MenuItem Header="保存原始图像" Click="SaveOriginalImage_Click" />
|
||||
<MenuItem Header="保存结果图像" Click="SaveResultImage_Click" />
|
||||
<Separator />
|
||||
<MenuItem Header="清除所有测量" Click="ClearAllMeasurements_Click" />
|
||||
</ContextMenu>
|
||||
</roi:PolygonRoiCanvas.ContextMenu>
|
||||
</roi:PolygonRoiCanvas>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
@@ -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) =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user