moel@345: using System; moel@345: using System.Collections.Generic; moel@345: using System.Text; moel@345: using System.ComponentModel.Design; moel@345: using System.Collections.ObjectModel; moel@345: using System.ComponentModel; moel@345: using System.Drawing.Design; moel@345: moel@345: namespace Aga.Controls.Tree.NodeControls moel@345: { moel@345: internal class NodeControlsCollection : Collection moel@345: { moel@345: private TreeViewAdv _tree; moel@345: moel@345: public NodeControlsCollection(TreeViewAdv tree) moel@345: { moel@345: _tree = tree; moel@345: } moel@345: moel@345: protected override void ClearItems() moel@345: { moel@345: _tree.BeginUpdate(); moel@345: try moel@345: { moel@345: while (this.Count != 0) moel@345: this.RemoveAt(this.Count - 1); moel@345: } moel@345: finally moel@345: { moel@345: _tree.EndUpdate(); moel@345: } moel@345: } moel@345: moel@345: protected override void InsertItem(int index, NodeControl item) moel@345: { moel@345: if (item == null) moel@345: throw new ArgumentNullException("item"); moel@345: moel@345: if (item.Parent != _tree) moel@345: { moel@345: if (item.Parent != null) moel@345: { moel@345: item.Parent.NodeControls.Remove(item); moel@345: } moel@345: base.InsertItem(index, item); moel@345: item.AssignParent(_tree); moel@345: _tree.FullUpdate(); moel@345: } moel@345: } moel@345: moel@345: protected override void RemoveItem(int index) moel@345: { moel@345: NodeControl value = this[index]; moel@345: value.AssignParent(null); moel@345: base.RemoveItem(index); moel@345: _tree.FullUpdate(); moel@345: } moel@345: moel@345: protected override void SetItem(int index, NodeControl item) moel@345: { moel@345: if (item == null) moel@345: throw new ArgumentNullException("item"); moel@345: moel@345: _tree.BeginUpdate(); moel@345: try moel@345: { moel@345: RemoveAt(index); moel@345: InsertItem(index, item); moel@345: } moel@345: finally moel@345: { moel@345: _tree.EndUpdate(); moel@345: } moel@345: } moel@345: } moel@345: moel@345: internal class NodeControlCollectionEditor : CollectionEditor moel@345: { moel@345: private Type[] _types; moel@345: moel@345: public NodeControlCollectionEditor(Type type) moel@345: : base(type) moel@345: { moel@345: _types = new Type[] { typeof(NodeTextBox), typeof(NodeIntegerTextBox), typeof(NodeDecimalTextBox), moel@345: typeof(NodeComboBox), typeof(NodeCheckBox), moel@345: typeof(NodeStateIcon), typeof(NodeIcon), typeof(NodeNumericUpDown), typeof(ExpandingIcon) }; moel@345: } moel@345: moel@345: protected override System.Type[] CreateNewItemTypes() moel@345: { moel@345: return _types; moel@345: } moel@345: } moel@345: }