moel@345
|
1 |
using System;
|
moel@345
|
2 |
using System.Collections.Generic;
|
moel@345
|
3 |
using System.Text;
|
moel@345
|
4 |
using System.ComponentModel.Design;
|
moel@345
|
5 |
using System.Collections.ObjectModel;
|
moel@345
|
6 |
using System.ComponentModel;
|
moel@345
|
7 |
using System.Drawing.Design;
|
moel@345
|
8 |
|
moel@345
|
9 |
namespace Aga.Controls.Tree.NodeControls
|
moel@345
|
10 |
{
|
moel@345
|
11 |
internal class NodeControlsCollection : Collection<NodeControl>
|
moel@345
|
12 |
{
|
moel@345
|
13 |
private TreeViewAdv _tree;
|
moel@345
|
14 |
|
moel@345
|
15 |
public NodeControlsCollection(TreeViewAdv tree)
|
moel@345
|
16 |
{
|
moel@345
|
17 |
_tree = tree;
|
moel@345
|
18 |
}
|
moel@345
|
19 |
|
moel@345
|
20 |
protected override void ClearItems()
|
moel@345
|
21 |
{
|
moel@345
|
22 |
_tree.BeginUpdate();
|
moel@345
|
23 |
try
|
moel@345
|
24 |
{
|
moel@345
|
25 |
while (this.Count != 0)
|
moel@345
|
26 |
this.RemoveAt(this.Count - 1);
|
moel@345
|
27 |
}
|
moel@345
|
28 |
finally
|
moel@345
|
29 |
{
|
moel@345
|
30 |
_tree.EndUpdate();
|
moel@345
|
31 |
}
|
moel@345
|
32 |
}
|
moel@345
|
33 |
|
moel@345
|
34 |
protected override void InsertItem(int index, NodeControl item)
|
moel@345
|
35 |
{
|
moel@345
|
36 |
if (item == null)
|
moel@345
|
37 |
throw new ArgumentNullException("item");
|
moel@345
|
38 |
|
moel@345
|
39 |
if (item.Parent != _tree)
|
moel@345
|
40 |
{
|
moel@345
|
41 |
if (item.Parent != null)
|
moel@345
|
42 |
{
|
moel@345
|
43 |
item.Parent.NodeControls.Remove(item);
|
moel@345
|
44 |
}
|
moel@345
|
45 |
base.InsertItem(index, item);
|
moel@345
|
46 |
item.AssignParent(_tree);
|
moel@345
|
47 |
_tree.FullUpdate();
|
moel@345
|
48 |
}
|
moel@345
|
49 |
}
|
moel@345
|
50 |
|
moel@345
|
51 |
protected override void RemoveItem(int index)
|
moel@345
|
52 |
{
|
moel@345
|
53 |
NodeControl value = this[index];
|
moel@345
|
54 |
value.AssignParent(null);
|
moel@345
|
55 |
base.RemoveItem(index);
|
moel@345
|
56 |
_tree.FullUpdate();
|
moel@345
|
57 |
}
|
moel@345
|
58 |
|
moel@345
|
59 |
protected override void SetItem(int index, NodeControl item)
|
moel@345
|
60 |
{
|
moel@345
|
61 |
if (item == null)
|
moel@345
|
62 |
throw new ArgumentNullException("item");
|
moel@345
|
63 |
|
moel@345
|
64 |
_tree.BeginUpdate();
|
moel@345
|
65 |
try
|
moel@345
|
66 |
{
|
moel@345
|
67 |
RemoveAt(index);
|
moel@345
|
68 |
InsertItem(index, item);
|
moel@345
|
69 |
}
|
moel@345
|
70 |
finally
|
moel@345
|
71 |
{
|
moel@345
|
72 |
_tree.EndUpdate();
|
moel@345
|
73 |
}
|
moel@345
|
74 |
}
|
moel@345
|
75 |
}
|
moel@345
|
76 |
|
moel@345
|
77 |
internal class NodeControlCollectionEditor : CollectionEditor
|
moel@345
|
78 |
{
|
moel@345
|
79 |
private Type[] _types;
|
moel@345
|
80 |
|
moel@345
|
81 |
public NodeControlCollectionEditor(Type type)
|
moel@345
|
82 |
: base(type)
|
moel@345
|
83 |
{
|
moel@345
|
84 |
_types = new Type[] { typeof(NodeTextBox), typeof(NodeIntegerTextBox), typeof(NodeDecimalTextBox),
|
moel@345
|
85 |
typeof(NodeComboBox), typeof(NodeCheckBox),
|
moel@345
|
86 |
typeof(NodeStateIcon), typeof(NodeIcon), typeof(NodeNumericUpDown), typeof(ExpandingIcon) };
|
moel@345
|
87 |
}
|
moel@345
|
88 |
|
moel@345
|
89 |
protected override System.Type[] CreateNewItemTypes()
|
moel@345
|
90 |
{
|
moel@345
|
91 |
return _types;
|
moel@345
|
92 |
}
|
moel@345
|
93 |
}
|
moel@345
|
94 |
}
|