Initial Commit
This commit is contained in:
48
Charts/Navigation/RectangleSelectionAdorner.cs
Normal file
48
Charts/Navigation/RectangleSelectionAdorner.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Microsoft.Research.DynamicDataDisplay.Navigation
|
||||
{
|
||||
/// <summary>Helper class to draw semitransparent rectangle over the
|
||||
/// selection area</summary>
|
||||
public sealed class RectangleSelectionAdorner : Adorner {
|
||||
|
||||
private Rect? border = null;
|
||||
public Rect? Border {
|
||||
get { return border; }
|
||||
set { border = value; }
|
||||
}
|
||||
|
||||
public Brush Fill {
|
||||
get { return (Brush)GetValue(FillProperty); }
|
||||
set { SetValue(FillProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty FillProperty =
|
||||
DependencyProperty.Register(
|
||||
"Fill",
|
||||
typeof(Brush),
|
||||
typeof(RectangleSelectionAdorner),
|
||||
new FrameworkPropertyMetadata(
|
||||
new SolidColorBrush(Color.FromArgb(60, 100, 100, 100)),
|
||||
FrameworkPropertyMetadataOptions.AffectsRender));
|
||||
|
||||
private Pen pen;
|
||||
public Pen Pen {
|
||||
get { return pen; }
|
||||
set { pen = value; }
|
||||
}
|
||||
|
||||
public RectangleSelectionAdorner(UIElement element)
|
||||
: base(element) {
|
||||
pen = new Pen(Brushes.Black, 1.0);
|
||||
}
|
||||
|
||||
protected override void OnRender(DrawingContext dc) {
|
||||
if (border.HasValue) {
|
||||
dc.DrawRectangle(Fill, pen, border.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user