mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
3a9a6e8305
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@4764 21ef857c-d57f-4fe0-8362-d861dc6d29cd
102 lines
1.9 KiB
C#
102 lines
1.9 KiB
C#
using System;
|
|
using System.ComponentModel.Design;
|
|
using System.Collections.ObjectModel;
|
|
|
|
namespace Aga.Controls.Tree.NodeControls
|
|
{
|
|
public class NodeControlsCollection : Collection<NodeControl>
|
|
{
|
|
private TreeViewAdv _tree;
|
|
|
|
public NodeControlsCollection(TreeViewAdv tree)
|
|
{
|
|
_tree = tree;
|
|
}
|
|
|
|
protected override void ClearItems()
|
|
{
|
|
_tree.BeginUpdate();
|
|
|
|
try
|
|
{
|
|
while (this.Count != 0)
|
|
this.RemoveAt(this.Count - 1);
|
|
}
|
|
finally
|
|
{
|
|
_tree.EndUpdate();
|
|
}
|
|
}
|
|
|
|
protected override void InsertItem(int index, NodeControl item)
|
|
{
|
|
if (item == null)
|
|
throw new ArgumentNullException("item");
|
|
|
|
if (item.Parent == this._tree)
|
|
return;
|
|
|
|
if (item.Parent != null)
|
|
{
|
|
item.Parent.NodeControls.Remove(item);
|
|
}
|
|
|
|
base.InsertItem(index, item);
|
|
|
|
item.AssignParent(this._tree);
|
|
|
|
this._tree.FullUpdate();
|
|
}
|
|
|
|
protected override void RemoveItem(int index)
|
|
{
|
|
NodeControl value = this[index];
|
|
|
|
value.AssignParent(null);
|
|
|
|
base.RemoveItem(index);
|
|
|
|
_tree.FullUpdate();
|
|
}
|
|
|
|
protected override void SetItem(int index, NodeControl item)
|
|
{
|
|
if (item == null)
|
|
throw new ArgumentNullException("item");
|
|
|
|
_tree.BeginUpdate();
|
|
|
|
try
|
|
{
|
|
RemoveAt(index);
|
|
InsertItem(index, item);
|
|
}
|
|
finally
|
|
{
|
|
_tree.EndUpdate();
|
|
}
|
|
}
|
|
}
|
|
|
|
internal class NodeControlCollectionEditor : CollectionEditor
|
|
{
|
|
private Type[] _types;
|
|
|
|
public NodeControlCollectionEditor(Type type)
|
|
: base(type)
|
|
{
|
|
_types = new[]
|
|
{
|
|
typeof(NodeTextBox),
|
|
typeof(NodeIntegerTextBox),
|
|
typeof(NodeIcon),
|
|
};
|
|
}
|
|
|
|
protected override Type[] CreateNewItemTypes()
|
|
{
|
|
return _types;
|
|
}
|
|
}
|
|
}
|