SharpDisplay: Migrating to new robust client scheme.
2 using System.Collections.Generic;
4 using System.Collections.ObjectModel;
5 using System.ComponentModel;
6 using System.Windows.Forms;
8 namespace Aga.Controls.Tree
10 internal class TreeColumnCollection : Collection<TreeColumn>
12 private TreeViewAdv _treeView;
14 public TreeColumnCollection(TreeViewAdv treeView)
19 protected override void InsertItem(int index, TreeColumn item)
21 base.InsertItem(index, item);
23 _treeView.UpdateColumns();
26 protected override void RemoveItem(int index)
28 UnbindEvents(this[index]);
29 base.RemoveItem(index);
30 _treeView.UpdateColumns();
33 protected override void SetItem(int index, TreeColumn item)
35 UnbindEvents(this[index]);
36 base.SetItem(index, item);
39 _treeView.UpdateColumns();
42 protected override void ClearItems()
44 foreach (TreeColumn c in Items)
47 _treeView.UpdateColumns();
50 private void BindEvents(TreeColumn item)
53 item.HeaderChanged += HeaderChanged;
54 item.IsVisibleChanged += IsVisibleChanged;
55 item.WidthChanged += WidthChanged;
56 item.SortOrderChanged += SortOrderChanged;
59 private void UnbindEvents(TreeColumn item)
62 item.HeaderChanged -= HeaderChanged;
63 item.IsVisibleChanged -= IsVisibleChanged;
64 item.WidthChanged -= WidthChanged;
65 item.SortOrderChanged -= SortOrderChanged;
68 void SortOrderChanged(object sender, EventArgs e)
70 TreeColumn changed = sender as TreeColumn;
71 //Only one column at a time can have a sort property set
72 if (changed.SortOrder != SortOrder.None)
74 foreach (TreeColumn col in this)
77 col.SortOrder = SortOrder.None;
80 _treeView.UpdateHeaders();
83 void WidthChanged(object sender, EventArgs e)
85 _treeView.ChangeColumnWidth(sender as TreeColumn);
88 void IsVisibleChanged(object sender, EventArgs e)
90 _treeView.FullUpdate();
93 void HeaderChanged(object sender, EventArgs e)
95 _treeView.UpdateView();