mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
style<Avatar>: apply corner radius for avatar pictures
This commit is contained in:
parent
766f24f4b0
commit
79e3759681
1 changed files with 5 additions and 3 deletions
|
@ -103,10 +103,9 @@ namespace SourceGit.Views.Controls {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dc"></param>
|
/// <param name="dc"></param>
|
||||||
protected override void OnRender(DrawingContext dc) {
|
protected override void OnRender(DrawingContext dc) {
|
||||||
base.OnRender(dc);
|
var corner = Math.Max(2, Width / 16);
|
||||||
|
|
||||||
if (Source == null && label != null) {
|
if (Source == null && label != null) {
|
||||||
var corner = Math.Max(2, Width / 16);
|
|
||||||
var offsetX = (double)0;
|
var offsetX = (double)0;
|
||||||
if (HorizontalAlignment == HorizontalAlignment.Right) {
|
if (HorizontalAlignment == HorizontalAlignment.Right) {
|
||||||
offsetX = -Width * 0.5;
|
offsetX = -Width * 0.5;
|
||||||
|
@ -117,6 +116,9 @@ namespace SourceGit.Views.Controls {
|
||||||
Brush brush = BACKGROUND_BRUSHES[colorIdx];
|
Brush brush = BACKGROUND_BRUSHES[colorIdx];
|
||||||
dc.DrawRoundedRectangle(brush, null, new Rect(-Width * 0.5 + offsetX, -Height * 0.5, Width, Height), corner, corner);
|
dc.DrawRoundedRectangle(brush, null, new Rect(-Width * 0.5 + offsetX, -Height * 0.5, Width, Height), corner, corner);
|
||||||
dc.DrawText(label, new Point(label.Width * -0.5 + offsetX, label.Height * -0.5));
|
dc.DrawText(label, new Point(label.Width * -0.5 + offsetX, label.Height * -0.5));
|
||||||
|
} else {
|
||||||
|
dc.PushClip(new RectangleGeometry(new Rect(0, 0, Width, Height), corner, corner));
|
||||||
|
base.OnRender(dc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue