-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDropAdorner.cs
57 lines (49 loc) · 1.51 KB
/
DropAdorner.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System.Windows;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Shapes;
namespace MP3Joiner
{
public class DropAdorner : Adorner
{
private readonly bool _isAbove;
private readonly VisualCollection _visuals;
private readonly Line _line;
public DropAdorner(UIElement adornedElement, bool isAbove)
: base(adornedElement)
{
_isAbove = isAbove;
_visuals = new VisualCollection(this);
_line = new Line
{
Stroke = Brushes.Red,
StrokeThickness = 2,
X1 = 0,
Y1 = 0,
X2 = adornedElement.RenderSize.Width,
Y2 = 0
};
if (!_isAbove)
{
_line.Y1 = adornedElement.RenderSize.Height;
_line.Y2 = adornedElement.RenderSize.Height;
}
_visuals.Add(_line);
}
protected override int VisualChildrenCount => _visuals.Count;
protected override Visual GetVisualChild(int index)
{
return _visuals[index];
}
protected override Size MeasureOverride(Size constraint)
{
_line.X2 = AdornedElement.RenderSize.Width;
return base.MeasureOverride(constraint);
}
protected override Size ArrangeOverride(Size finalSize)
{
_line.X2 = AdornedElement.RenderSize.Width;
return finalSize;
}
}
}