Changeset 190
- Timestamp:
- 04/25/08 12:18:16 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Data/ItemDictionaryView_T.cs
r188 r190 9 9 10 10 namespace HeuristicLab.Data { 11 public partial class ItemDictionaryView<K, V> : ViewBase 11 public partial class ItemDictionaryView<K, V> : ViewBase 12 12 where K : IItem 13 13 where V : IItem { … … 15 15 private EditKeyValueDialog editKeyValueDialog; 16 16 17 public ItemDictionary<K, V> ItemDictionary {18 get { return (ItemDictionary<K, V>) Item; }17 public ItemDictionary<K, V> ItemDictionary { 18 get { return (ItemDictionary<K, V>) Item; } 19 19 set { base.Item = value; } 20 20 } … … 29 29 } 30 30 31 public ItemDictionaryView() : this(new ItemDictionary<K,V>()) { } 32 33 public ItemDictionaryView(ItemDictionary<K,V> dictionary) { 31 public ItemDictionaryView() { 34 32 InitializeComponent(); 35 ItemDictionary = dictionary;36 33 listView.View = View.Details; 37 34 listView.Columns[0].Text = "Key"; 38 35 listView.Columns[1].Text = "Value"; 36 } 37 38 public ItemDictionaryView(ItemDictionary<K, V> dictionary) 39 : this() { 40 ItemDictionary = dictionary; 39 41 valueTypeTextBox.Text = typeof(V).ToString(); 40 keyTypeTextBox.Text = typeof(K).ToString(); 42 keyTypeTextBox.Text = typeof(K).ToString(); 41 43 } 42 44 … … 133 135 keyPanel.Enabled = false; 134 136 removeButton.Enabled = false; 135 136 foreach (ListViewItem item in listView.Items) { 137 ((IItem) item.SubItems[0]).Changed -= new EventHandler(Item_Changed); 138 ((IItem) item.SubItems[1]).Changed -= new EventHandler(Item_Changed); 139 } 140 listView.Items.Clear(); 141 foreach (KeyValuePair<K, V> data in ItemDictionary) { 142 ListViewItem item = CreateListViewItem(data.Key, data.Value); 143 listView.Items.Add(item); 144 data.Key.Changed += new EventHandler(Item_Changed); 145 data.Value.Changed += new EventHandler(Item_Changed); 137 if (ItemDictionary != null) { 138 foreach (ListViewItem item in listView.Items) { 139 ((IItem) item.SubItems[0]).Changed -= new EventHandler(Item_Changed); 140 ((IItem) item.SubItems[1]).Changed -= new EventHandler(Item_Changed); 141 } 142 listView.Items.Clear(); 143 foreach (KeyValuePair<K, V> data in ItemDictionary) { 144 ListViewItem item = CreateListViewItem(data.Key, data.Value); 145 listView.Items.Add(item); 146 data.Key.Changed += new EventHandler(Item_Changed); 147 data.Value.Changed += new EventHandler(Item_Changed); 148 } 149 addButton.Enabled = true; 150 } else { 151 addButton.Enabled = false; 146 152 } 147 153 }
Note: See TracChangeset
for help on using the changeset viewer.