fix: center bga ball labels
This commit is contained in:
@@ -70,16 +70,26 @@ namespace XplorePlane.Services.ImageProcessing
|
|||||||
Canvas.SetTop(ellipse, ball.CenterY - radius);
|
Canvas.SetTop(ellipse, ball.CenterY - radius);
|
||||||
canvas.Children.Add(ellipse);
|
canvas.Children.Add(ellipse);
|
||||||
|
|
||||||
|
// 编号放在焊球中心,使用白底黑字提升在深色焊球上的可读性。
|
||||||
|
var labelWidth = Math.Max(34, Math.Min(72, radius * 0.9));
|
||||||
|
const double labelHeight = 26;
|
||||||
var label = new TextBlock
|
var label = new TextBlock
|
||||||
{
|
{
|
||||||
Text = string.IsNullOrEmpty(ball.Label) ? $"#{ball.Id}" : ball.Label,
|
Text = string.IsNullOrEmpty(ball.Label) ? $"#{ball.Id}" : ball.Label,
|
||||||
FontSize = 12,
|
Width = labelWidth,
|
||||||
|
Height = labelHeight,
|
||||||
|
FontSize = 18,
|
||||||
FontWeight = FontWeights.Bold,
|
FontWeight = FontWeights.Bold,
|
||||||
Foreground = color,
|
Foreground = Brushes.Black,
|
||||||
|
Background = Brushes.White,
|
||||||
|
Opacity = 0.92,
|
||||||
|
TextAlignment = TextAlignment.Center,
|
||||||
|
VerticalAlignment = VerticalAlignment.Center,
|
||||||
|
Padding = new Thickness(2, 0, 2, 0),
|
||||||
IsHitTestVisible = false
|
IsHitTestVisible = false
|
||||||
};
|
};
|
||||||
Canvas.SetLeft(label, ball.CenterX - radius);
|
Canvas.SetLeft(label, ball.CenterX - labelWidth / 2.0);
|
||||||
Canvas.SetTop(label, ball.CenterY + radius + 2);
|
Canvas.SetTop(label, ball.CenterY - labelHeight / 2.0);
|
||||||
canvas.Children.Add(label);
|
canvas.Children.Add(label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user