Line | |
---|
1 | using System.Windows;
|
---|
2 | using System.Windows.Documents;
|
---|
3 | using System.Windows.Media;
|
---|
4 |
|
---|
5 | namespace Microsoft.Research.DynamicDataDisplay.Navigation
|
---|
6 | {
|
---|
7 | /// <summary>Helper class to draw semitransparent rectangle over the
|
---|
8 | /// selection area</summary>
|
---|
9 | public sealed class RectangleSelectionAdorner : Adorner {
|
---|
10 |
|
---|
11 | private Rect? border = null;
|
---|
12 | public Rect? Border {
|
---|
13 | get { return border; }
|
---|
14 | set { border = value; }
|
---|
15 | }
|
---|
16 |
|
---|
17 | public Brush Fill {
|
---|
18 | get { return (Brush)GetValue(FillProperty); }
|
---|
19 | set { SetValue(FillProperty, value); }
|
---|
20 | }
|
---|
21 |
|
---|
22 | public static readonly DependencyProperty FillProperty =
|
---|
23 | DependencyProperty.Register(
|
---|
24 | "Fill",
|
---|
25 | typeof(Brush),
|
---|
26 | typeof(RectangleSelectionAdorner),
|
---|
27 | new FrameworkPropertyMetadata(
|
---|
28 | new SolidColorBrush(Color.FromArgb(60, 100, 100, 100)),
|
---|
29 | FrameworkPropertyMetadataOptions.AffectsRender));
|
---|
30 |
|
---|
31 | private Pen pen;
|
---|
32 | public Pen Pen {
|
---|
33 | get { return pen; }
|
---|
34 | set { pen = value; }
|
---|
35 | }
|
---|
36 |
|
---|
37 | public RectangleSelectionAdorner(UIElement element)
|
---|
38 | : base(element) {
|
---|
39 | pen = new Pen(Brushes.Black, 1.0);
|
---|
40 | }
|
---|
41 |
|
---|
42 | protected override void OnRender(DrawingContext dc) {
|
---|
43 | if (border.HasValue) {
|
---|
44 | dc.DrawRectangle(Fill, pen, border.Value);
|
---|
45 | }
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.