1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/External/Aga.Controls/Tree/NodeControls/NodeControlsCollection.cs Sun May 27 15:16:19 2012 +0000
1.3 @@ -0,0 +1,94 @@
1.4 +using System;
1.5 +using System.Collections.Generic;
1.6 +using System.Text;
1.7 +using System.ComponentModel.Design;
1.8 +using System.Collections.ObjectModel;
1.9 +using System.ComponentModel;
1.10 +using System.Drawing.Design;
1.11 +
1.12 +namespace Aga.Controls.Tree.NodeControls
1.13 +{
1.14 + internal class NodeControlsCollection : Collection<NodeControl>
1.15 + {
1.16 + private TreeViewAdv _tree;
1.17 +
1.18 + public NodeControlsCollection(TreeViewAdv tree)
1.19 + {
1.20 + _tree = tree;
1.21 + }
1.22 +
1.23 + protected override void ClearItems()
1.24 + {
1.25 + _tree.BeginUpdate();
1.26 + try
1.27 + {
1.28 + while (this.Count != 0)
1.29 + this.RemoveAt(this.Count - 1);
1.30 + }
1.31 + finally
1.32 + {
1.33 + _tree.EndUpdate();
1.34 + }
1.35 + }
1.36 +
1.37 + protected override void InsertItem(int index, NodeControl item)
1.38 + {
1.39 + if (item == null)
1.40 + throw new ArgumentNullException("item");
1.41 +
1.42 + if (item.Parent != _tree)
1.43 + {
1.44 + if (item.Parent != null)
1.45 + {
1.46 + item.Parent.NodeControls.Remove(item);
1.47 + }
1.48 + base.InsertItem(index, item);
1.49 + item.AssignParent(_tree);
1.50 + _tree.FullUpdate();
1.51 + }
1.52 + }
1.53 +
1.54 + protected override void RemoveItem(int index)
1.55 + {
1.56 + NodeControl value = this[index];
1.57 + value.AssignParent(null);
1.58 + base.RemoveItem(index);
1.59 + _tree.FullUpdate();
1.60 + }
1.61 +
1.62 + protected override void SetItem(int index, NodeControl item)
1.63 + {
1.64 + if (item == null)
1.65 + throw new ArgumentNullException("item");
1.66 +
1.67 + _tree.BeginUpdate();
1.68 + try
1.69 + {
1.70 + RemoveAt(index);
1.71 + InsertItem(index, item);
1.72 + }
1.73 + finally
1.74 + {
1.75 + _tree.EndUpdate();
1.76 + }
1.77 + }
1.78 + }
1.79 +
1.80 + internal class NodeControlCollectionEditor : CollectionEditor
1.81 + {
1.82 + private Type[] _types;
1.83 +
1.84 + public NodeControlCollectionEditor(Type type)
1.85 + : base(type)
1.86 + {
1.87 + _types = new Type[] { typeof(NodeTextBox), typeof(NodeIntegerTextBox), typeof(NodeDecimalTextBox),
1.88 + typeof(NodeComboBox), typeof(NodeCheckBox),
1.89 + typeof(NodeStateIcon), typeof(NodeIcon), typeof(NodeNumericUpDown), typeof(ExpandingIcon) };
1.90 + }
1.91 +
1.92 + protected override System.Type[] CreateNewItemTypes()
1.93 + {
1.94 + return _types;
1.95 + }
1.96 + }
1.97 +}