diff --git a/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs b/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs index 9bcd2c7..1130f59 100644 --- a/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs +++ b/XP.ImageProcessing.RoiControl/Controls/PolygonRoiCanvas.xaml.cs @@ -375,6 +375,7 @@ namespace XP.ImageProcessing.RoiControl.Controls private BubbleSubTool _bubbleTool = BubbleSubTool.Roi; private Rectangle _bubbleRoiRect; private Ellipse _bubbleRoiHandle; // 右下角调整手柄 + private TextBlock _bubbleResultLabel; // ROI 上方结果标签 private Rect? _bubbleRoi; private Point? _bubbleRoiStart; private bool _bubbleRoiDragging; @@ -1137,6 +1138,16 @@ namespace XP.ImageProcessing.RoiControl.Controls }; _measureOverlay.Children.Add(_bubbleRoiHandle); } + if (_bubbleResultLabel == null) + { + _bubbleResultLabel = new TextBlock + { + FontSize = 13, FontWeight = FontWeights.Bold, + IsHitTestVisible = false, + Visibility = Visibility.Collapsed + }; + _measureOverlay.Children.Add(_bubbleResultLabel); + } } private void SyncBubbleRoiVisuals() @@ -1256,6 +1267,17 @@ namespace XP.ImageProcessing.RoiControl.Controls } double voidRate = roiArea > 0 ? voidArea * 100.0 / roiArea : 0; + // 更新 ROI 上方标签 + if (_bubbleResultLabel != null) + { + string cls = voidRate <= 25.0 ? "PASS" : "FAIL"; + _bubbleResultLabel.Text = $"Void: {voidRate:F1}% | {cls}"; + _bubbleResultLabel.Foreground = cls == "PASS" ? Brushes.Lime : Brushes.Red; + Canvas.SetLeft(_bubbleResultLabel, roi.X); + Canvas.SetTop(_bubbleResultLabel, roi.Y - 20); + _bubbleResultLabel.Visibility = Visibility.Visible; + } + RaiseMeasureCompleted(roi.TopLeft, roi.BottomRight, voidRate, 1, "BubbleVoid"); } @@ -1388,6 +1410,7 @@ namespace XP.ImageProcessing.RoiControl.Controls { if (_bubbleRoiRect != null) { _measureOverlay.Children.Remove(_bubbleRoiRect); _bubbleRoiRect = null; } if (_bubbleRoiHandle != null) { _measureOverlay.Children.Remove(_bubbleRoiHandle); _bubbleRoiHandle = null; } + if (_bubbleResultLabel != null) { _measureOverlay.Children.Remove(_bubbleResultLabel); _bubbleResultLabel = null; } if (_bubbleMaskImage != null) { _measureOverlay.Children.Remove(_bubbleMaskImage); _bubbleMaskImage = null; } } _bubbleRoi = null;