Rebracer update.
2 using System.Collections.Generic;
4 using System.Windows.Forms;
6 using System.ComponentModel;
8 namespace Aga.Controls.Tree.NodeControls
10 [DesignTimeVisible(false), ToolboxItem(false)]
11 public abstract class NodeControl : Component
15 private TreeViewAdv _parent;
17 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
18 public TreeViewAdv Parent
20 get { return _parent; }
26 _parent.NodeControls.Remove(this);
29 value.NodeControls.Add(this);
34 private IToolTipProvider _toolTipProvider;
35 [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
36 public IToolTipProvider ToolTipProvider
38 get { return _toolTipProvider; }
39 set { _toolTipProvider = value; }
42 private TreeColumn _parentColumn;
43 public TreeColumn ParentColumn
45 get { return _parentColumn; }
48 _parentColumn = value;
54 private VerticalAlignment _verticalAlign = VerticalAlignment.Center;
55 [DefaultValue(VerticalAlignment.Center)]
56 public VerticalAlignment VerticalAlign
58 get { return _verticalAlign; }
61 _verticalAlign = value;
67 private int _leftMargin = 0;
70 get { return _leftMargin; }
74 throw new ArgumentOutOfRangeException();
83 internal virtual void AssignParent(TreeViewAdv parent)
88 protected virtual Rectangle GetBounds(TreeNodeAdv node, DrawContext context)
90 Rectangle r = context.Bounds;
91 Size s = GetActualSize(node, context);
92 Size bs = new Size(r.Width - LeftMargin, Math.Min(r.Height, s.Height));
93 switch (VerticalAlign)
95 case VerticalAlignment.Top:
96 return new Rectangle(new Point(r.X + LeftMargin, r.Y), bs);
97 case VerticalAlignment.Bottom:
98 return new Rectangle(new Point(r.X + LeftMargin, r.Bottom - s.Height), bs);
100 return new Rectangle(new Point(r.X + LeftMargin, r.Y + (r.Height - s.Height) / 2), bs);
104 protected void CheckThread()
106 if (Parent != null && Control.CheckForIllegalCrossThreadCalls)
107 if (Parent.InvokeRequired)
108 throw new InvalidOperationException("Cross-thread calls are not allowed");
111 public bool IsVisible(TreeNodeAdv node)
113 NodeControlValueEventArgs args = new NodeControlValueEventArgs(node);
115 OnIsVisibleValueNeeded(args);
116 return Convert.ToBoolean(args.Value);
119 internal Size GetActualSize(TreeNodeAdv node, DrawContext context)
123 Size s = MeasureSize(node, context);
124 return new Size(s.Width + LeftMargin, s.Height);
130 public abstract Size MeasureSize(TreeNodeAdv node, DrawContext context);
132 public abstract void Draw(TreeNodeAdv node, DrawContext context);
134 public virtual string GetToolTip(TreeNodeAdv node)
136 if (ToolTipProvider != null)
137 return ToolTipProvider.GetToolTip(node, this);
142 public virtual void MouseDown(TreeNodeAdvMouseEventArgs args)
146 public virtual void MouseUp(TreeNodeAdvMouseEventArgs args)
150 public virtual void MouseDoubleClick(TreeNodeAdvMouseEventArgs args)
154 public virtual void KeyDown(KeyEventArgs args)
158 public virtual void KeyUp(KeyEventArgs args)
162 public event EventHandler<NodeControlValueEventArgs> IsVisibleValueNeeded;
163 protected virtual void OnIsVisibleValueNeeded(NodeControlValueEventArgs args)
165 if (IsVisibleValueNeeded != null)
166 IsVisibleValueNeeded(this, args);