csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.4 KiB
43 lines
1.4 KiB
// -----------------------------------------------------------------------
|
|
// <copyright file="Border.cs" company="Steven Kirk">
|
|
// Copyright 2014 MIT Licence. See licence.md for more information.
|
|
// </copyright>
|
|
// -----------------------------------------------------------------------
|
|
|
|
namespace Perspex.Controls
|
|
{
|
|
using System;
|
|
using System.Reactive.Linq;
|
|
using Perspex.Media;
|
|
|
|
public class Border : Decorator
|
|
{
|
|
public Border()
|
|
{
|
|
Observable.Merge(
|
|
this.GetObservable(BackgroundProperty),
|
|
this.GetObservable(BorderBrushProperty))
|
|
.Subscribe(_ => this.InvalidateVisual());
|
|
}
|
|
|
|
public override void Render(IDrawingContext context)
|
|
{
|
|
if (this.Visibility == Visibility.Visible)
|
|
{
|
|
Brush background = this.Background;
|
|
Brush borderBrush = this.BorderBrush;
|
|
double borderThickness = this.BorderThickness;
|
|
|
|
if (background != null)
|
|
{
|
|
context.FillRectange(background, new Rect(this.Bounds.Size));
|
|
}
|
|
|
|
if (borderBrush != null && borderThickness > 0)
|
|
{
|
|
context.DrawRectange(new Pen(borderBrush, borderThickness), new Rect(this.Bounds.Size));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|