forked from icsharpcode/ILSpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GeneralAdorner.cs
66 lines (58 loc) · 1.25 KB
/
GeneralAdorner.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
58
59
60
61
62
63
64
65
66
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System.Windows.Documents;
using System.Windows;
using System.Windows.Media;
namespace ICSharpCode.TreeView
{
public class GeneralAdorner : Adorner
{
public GeneralAdorner(UIElement target)
: base(target)
{
}
FrameworkElement child;
public FrameworkElement Child
{
get
{
return child;
}
set
{
if (child != value) {
RemoveVisualChild(child);
RemoveLogicalChild(child);
child = value;
AddLogicalChild(value);
AddVisualChild(value);
InvalidateMeasure();
}
}
}
protected override int VisualChildrenCount
{
get { return child == null ? 0 : 1; }
}
protected override Visual GetVisualChild(int index)
{
return child;
}
protected override Size MeasureOverride(Size constraint)
{
if (child != null) {
child.Measure(constraint);
return child.DesiredSize;
}
return new Size();
}
protected override Size ArrangeOverride(Size finalSize)
{
if (child != null) {
child.Arrange(new Rect(finalSize));
return finalSize;
}
return new Size();
}
}
}