Fixed Issue 387. The new implementation does not try to start a ring 0 driver that already exists, but could not be opened. It tries to delete the driver and install it new. The driver is now stored temporarily in the application folder. The driver is not correctly removed on system shutdown.
2 using System.Collections.Generic;
3 using System.Collections.ObjectModel;
4 using System.Runtime.Serialization;
5 using System.Security.Permissions;
7 namespace Aga.Controls.Tree
10 public sealed class TreeNodeAdv : ISerializable
12 #region NodeCollection
13 private class NodeCollection : Collection<TreeNodeAdv>
15 private TreeNodeAdv _owner;
17 public NodeCollection(TreeNodeAdv owner)
22 protected override void ClearItems()
24 while (this.Count != 0)
25 this.RemoveAt(this.Count - 1);
28 protected override void InsertItem(int index, TreeNodeAdv item)
31 throw new ArgumentNullException("item");
33 if (item.Parent != _owner)
35 if (item.Parent != null)
36 item.Parent.Nodes.Remove(item);
37 item._parent = _owner;
39 for (int i = index; i < Count; i++)
41 base.InsertItem(index, item);
44 if (_owner.Tree != null && _owner.Tree.Model == null)
46 _owner.Tree.SmartFullUpdate();
50 protected override void RemoveItem(int index)
52 TreeNodeAdv item = this[index];
55 for (int i = index + 1; i < Count; i++)
57 base.RemoveItem(index);
59 if (_owner.Tree != null && _owner.Tree.Model == null)
61 _owner.Tree.UpdateSelection();
62 _owner.Tree.SmartFullUpdate();
66 protected override void SetItem(int index, TreeNodeAdv item)
69 throw new ArgumentNullException("item");
71 InsertItem(index, item);
78 public event EventHandler<TreeViewAdvEventArgs> Collapsing;
79 internal void OnCollapsing()
81 if (Collapsing != null)
82 Collapsing(this, new TreeViewAdvEventArgs(this));
85 public event EventHandler<TreeViewAdvEventArgs> Collapsed;
86 internal void OnCollapsed()
88 if (Collapsed != null)
89 Collapsed(this, new TreeViewAdvEventArgs(this));
92 public event EventHandler<TreeViewAdvEventArgs> Expanding;
93 internal void OnExpanding()
95 if (Expanding != null)
96 Expanding(this, new TreeViewAdvEventArgs(this));
99 public event EventHandler<TreeViewAdvEventArgs> Expanded;
100 internal void OnExpanded()
102 if (Expanded != null)
103 Expanded(this, new TreeViewAdvEventArgs(this));
110 private TreeViewAdv _tree;
111 public TreeViewAdv Tree
113 get { return _tree; }
120 internal set { _row = value; }
123 private int _index = -1;
132 private bool _isSelected;
133 public bool IsSelected
135 get { return _isSelected; }
138 if (_isSelected != value)
140 if (Tree.IsMyNode(this))
142 //_tree.OnSelectionChanging
145 if (!_tree.Selection.Contains(this))
146 _tree.Selection.Add(this);
148 if (_tree.Selection.Count == 1)
149 _tree.CurrentNode = this;
152 _tree.Selection.Remove(this);
154 _tree.OnSelectionChanged();
162 /// Returns true if all parent nodes of this node are expanded.
164 internal bool IsVisible
168 TreeNodeAdv node = _parent;
171 if (!node.IsExpanded)
179 private bool _isLeaf;
182 get { return _isLeaf; }
183 internal set { _isLeaf = value; }
186 private bool _isExpandedOnce;
187 public bool IsExpandedOnce
189 get { return _isExpandedOnce; }
190 internal set { _isExpandedOnce = value; }
193 private bool _isExpanded;
194 public bool IsExpanded
196 get { return _isExpanded; }
206 internal void AssignIsExpanded(bool value)
211 private TreeNodeAdv _parent;
212 public TreeNodeAdv Parent
214 get { return _parent; }
224 return _parent.Level + 1;
228 public TreeNodeAdv PreviousNode
236 return _parent.Nodes[index - 1];
242 public TreeNodeAdv NextNode
249 if (index < _parent.Nodes.Count - 1)
250 return _parent.Nodes[index + 1];
256 internal TreeNodeAdv BottomNode
260 TreeNodeAdv parent = this.Parent;
263 if (parent.NextNode != null)
264 return parent.NextNode;
266 return parent.BottomNode;
272 internal TreeNodeAdv NextVisibleNode
276 if (IsExpanded && Nodes.Count > 0)
280 TreeNodeAdv nn = NextNode;
289 public bool CanExpand
293 return (Nodes.Count > 0 || (!IsExpandedOnce && !IsLeaf));
303 private Collection<TreeNodeAdv> _nodes;
304 internal Collection<TreeNodeAdv> Nodes
306 get { return _nodes; }
309 private ReadOnlyCollection<TreeNodeAdv> _children;
310 public ReadOnlyCollection<TreeNodeAdv> Children
318 private int? _rightBounds;
319 internal int? RightBounds
321 get { return _rightBounds; }
322 set { _rightBounds = value; }
325 private int? _height;
328 get { return _height; }
329 set { _height = value; }
332 private bool _isExpandingNow;
333 internal bool IsExpandingNow
335 get { return _isExpandingNow; }
336 set { _isExpandingNow = value; }
339 private bool _autoExpandOnStructureChanged = true;
340 public bool AutoExpandOnStructureChanged
342 get { return _autoExpandOnStructureChanged; }
343 set { _autoExpandOnStructureChanged = value; }
348 public TreeNodeAdv(object tag)
353 internal TreeNodeAdv(TreeViewAdv tree, object tag)
357 _nodes = new NodeCollection(this);
358 _children = new ReadOnlyCollection<TreeNodeAdv>(_nodes);
362 public override string ToString()
365 return Tag.ToString();
367 return base.ToString();
370 public void Collapse()
376 public void CollapseAll()
381 public void Collapse(bool ignoreChildren)
383 SetIsExpanded(false, ignoreChildren);
392 public void ExpandAll()
397 public void Expand(bool ignoreChildren)
399 SetIsExpanded(true, ignoreChildren);
402 private void SetIsExpanded(bool value, bool ignoreChildren)
407 Tree.SetIsExpanded(this, value, ignoreChildren);
410 #region ISerializable Members
412 private TreeNodeAdv(SerializationInfo info, StreamingContext context)
416 nodesCount = info.GetInt32("NodesCount");
417 _isExpanded = info.GetBoolean("IsExpanded");
418 _tag = info.GetValue("Tag", typeof(object));
420 for (int i = 0; i < nodesCount; i++)
422 TreeNodeAdv child = (TreeNodeAdv)info.GetValue("Child" + i, typeof(TreeNodeAdv));
428 [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
429 public void GetObjectData(SerializationInfo info, StreamingContext context)
431 info.AddValue("IsExpanded", IsExpanded);
432 info.AddValue("NodesCount", Nodes.Count);
433 if ((Tag != null) && Tag.GetType().IsSerializable)
434 info.AddValue("Tag", Tag, Tag.GetType());
436 for (int i = 0; i < Nodes.Count; i++)
437 info.AddValue("Child" + i, Nodes[i], typeof(TreeNodeAdv));