Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Breadcrumbs/HeuristicLab.Core.Views/3.3/ItemListView.cs @ 10093

Last change on this file since 10093 was 10093, checked in by jkarder, 11 years ago

#2116:

  • refactored breadcrumb navigation
  • added possibility to navigate to the first invisible breadcrumb via the ellipsis
File size: 22.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections;
24using System.Collections.Generic;
25using System.Drawing;
26using System.Linq;
27using System.Windows.Forms;
28using HeuristicLab.Collections;
29using HeuristicLab.Common;
30using HeuristicLab.MainForm;
31using HeuristicLab.MainForm.WindowsForms;
32using HeuristicLab.PluginInfrastructure;
33
34namespace HeuristicLab.Core.Views {
35  [View("ItemList View")]
36  [Content(typeof(ItemList<>), true)]
37  [Content(typeof(IItemList<>), false)]
38  public partial class ItemListView<T> : ItemView where T : class, IItem {
39    protected Dictionary<T, List<ListViewItem>> itemListViewItemMapping;
40    protected TypeSelectorDialog typeSelectorDialog;
41    protected bool validDragOperation;
42
43    public new IItemList<T> Content {
44      get { return (IItemList<T>)base.Content; }
45      set { base.Content = value; }
46    }
47
48    public ListView ItemsListView {
49      get { return itemsListView; }
50    }
51
52    public ItemListView() {
53      InitializeComponent();
54      itemListViewItemMapping = new Dictionary<T, List<ListViewItem>>();
55    }
56
57    protected override void Dispose(bool disposing) {
58      if (disposing) {
59        if (typeSelectorDialog != null) typeSelectorDialog.Dispose();
60        if (components != null) components.Dispose();
61      }
62      base.Dispose(disposing);
63    }
64
65    protected override void DeregisterContentEvents() {
66      Content.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_ItemsAdded);
67      Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_ItemsRemoved);
68      Content.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_ItemsReplaced);
69      Content.ItemsMoved -= new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_ItemsMoved);
70      Content.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_CollectionReset);
71      foreach (T item in itemListViewItemMapping.Keys) {
72        DeregisterItemEvents(item);
73      }
74      base.DeregisterContentEvents();
75    }
76    protected override void RegisterContentEvents() {
77      base.RegisterContentEvents();
78      Content.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_ItemsAdded);
79      Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_ItemsRemoved);
80      Content.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_ItemsReplaced);
81      Content.ItemsMoved += new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_ItemsMoved);
82      Content.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_CollectionReset);
83    }
84    protected virtual void DeregisterItemEvents(T item) {
85      item.ItemImageChanged -= new EventHandler(Item_ItemImageChanged);
86      item.ToStringChanged -= new EventHandler(Item_ToStringChanged);
87    }
88    protected virtual void RegisterItemEvents(T item) {
89      item.ItemImageChanged += new EventHandler(Item_ItemImageChanged);
90      item.ToStringChanged += new EventHandler(Item_ToStringChanged);
91    }
92
93    protected override void OnContentChanged() {
94      base.OnContentChanged();
95
96      int selectedIndex = -1;
97      if (itemsListView.SelectedItems.Count == 1) selectedIndex = itemsListView.SelectedIndices[0];
98
99      itemsListView.Items.Clear();
100      itemListViewItemMapping.Clear();
101      RebuildImageList();
102      viewHost.Content = null;
103      if (Content != null) {
104        foreach (T item in Content)
105          AddListViewItem(CreateListViewItem(item));
106        AdjustListViewColumnSizes();
107        if ((selectedIndex != -1) && (selectedIndex < itemsListView.Items.Count))
108          itemsListView.Items[selectedIndex].Selected = true;
109      }
110      SetEnabledStateOfControls();
111    }
112
113    protected override void SetEnabledStateOfControls() {
114      base.SetEnabledStateOfControls();
115      if (Content == null) {
116        addButton.Enabled = false;
117        moveUpButton.Enabled = false;
118        moveDownButton.Enabled = false;
119        removeButton.Enabled = false;
120        itemsListView.Enabled = false;
121        detailsGroupBox.Enabled = false;
122      } else {
123        addButton.Enabled = !Content.IsReadOnly && !ReadOnly;
124        moveUpButton.Enabled = itemsListView.SelectedItems.Count == 1 &&
125                               itemsListView.SelectedIndices[0] != 0 &&
126                               !Content.IsReadOnly && !ReadOnly;
127        moveDownButton.Enabled = itemsListView.SelectedItems.Count == 1 &&
128                                 itemsListView.SelectedIndices[0] != itemsListView.Items.Count - 1 &&
129                                 !Content.IsReadOnly && !ReadOnly;
130        removeButton.Enabled = itemsListView.SelectedItems.Count > 0 &&
131                               !Content.IsReadOnly && !ReadOnly;
132        itemsListView.Enabled = true;
133        detailsGroupBox.Enabled = itemsListView.SelectedItems.Count == 1;
134      }
135    }
136
137    protected virtual T CreateItem() {
138      if (typeSelectorDialog == null) {
139        typeSelectorDialog = new TypeSelectorDialog();
140        typeSelectorDialog.Caption = "Select Item";
141        typeSelectorDialog.TypeSelector.Caption = "Available Items";
142        typeSelectorDialog.TypeSelector.Configure(typeof(T), false, true);
143      }
144
145      if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
146        try {
147          return (T)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
148        } catch (Exception ex) {
149          ErrorHandling.ShowErrorDialog(this, ex);
150        }
151      }
152      return null;
153    }
154    protected virtual ListViewItem CreateListViewItem(T item) {
155      ListViewItem listViewItem = new ListViewItem();
156      if (item == null) {
157        listViewItem.Text = "null";
158        itemsListView.SmallImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.Nothing);
159        listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1;
160      } else {
161        listViewItem.Text = item.ToString();
162        listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription;
163        itemsListView.SmallImageList.Images.Add(item.ItemImage);
164        listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1;
165        listViewItem.Tag = item;
166      }
167      return listViewItem;
168    }
169    protected virtual void AddListViewItem(ListViewItem listViewItem) {
170      if (listViewItem == null) throw new ArgumentNullException();
171      T item = (listViewItem.Tag as T);
172      itemsListView.Items.Add(listViewItem);
173      if (item != null) {
174        if (!itemListViewItemMapping.ContainsKey(item)) {
175          RegisterItemEvents(item);
176          itemListViewItemMapping.Add(item, new List<ListViewItem>());
177        }
178        itemListViewItemMapping[item].Add(listViewItem);
179      }
180    }
181    protected virtual void InsertListViewItem(int index, ListViewItem listViewItem) {
182      if (listViewItem == null) throw new ArgumentNullException();
183      T item = (listViewItem.Tag as T);
184      itemsListView.Items.Insert(index, listViewItem);
185      if (item != null) {
186        if (!itemListViewItemMapping.ContainsKey(item)) {
187          RegisterItemEvents(item);
188          itemListViewItemMapping.Add(item, new List<ListViewItem>());
189        }
190        itemListViewItemMapping[item].Add(listViewItem);
191      }
192    }
193    protected virtual void RemoveListViewItem(ListViewItem listViewItem) {
194      if (listViewItem == null) throw new ArgumentNullException();
195      T item = (listViewItem.Tag as T);
196      if (item != null) {
197        itemListViewItemMapping[item].Remove(listViewItem);
198        if (itemListViewItemMapping[item].Count == 0) {
199          itemListViewItemMapping.Remove(item);
200          DeregisterItemEvents(item);
201        }
202      }
203      listViewItem.Remove();
204    }
205    protected virtual void UpdateListViewItemImage(ListViewItem listViewItem) {
206      if (listViewItem == null) throw new ArgumentNullException();
207      T item = listViewItem.Tag as T;
208      int i = listViewItem.ImageIndex;
209      itemsListView.SmallImageList.Images[i] = item == null ? HeuristicLab.Common.Resources.VSImageLibrary.Nothing : item.ItemImage;
210      listViewItem.ImageIndex = -1;
211      listViewItem.ImageIndex = i;
212    }
213    protected virtual void UpdateListViewItemText(ListViewItem listViewItem) {
214      if (listViewItem == null) throw new ArgumentNullException();
215      T item = listViewItem.Tag as T;
216      listViewItem.Text = item == null ? "null" : item.ToString();
217      listViewItem.ToolTipText = item == null ? string.Empty : item.ItemName + ": " + item.ItemDescription;
218    }
219    protected virtual IEnumerable<ListViewItem> GetListViewItemsForItem(T item) {
220      if (item == null) {
221        List<ListViewItem> listViewItems = new List<ListViewItem>();
222        foreach (ListViewItem listViewItem in itemsListView.Items) {
223          if (listViewItem.Tag == null) listViewItems.Add(listViewItem);
224        }
225        return listViewItems;
226      } else {
227        List<ListViewItem> listViewItems = null;
228        itemListViewItemMapping.TryGetValue(item, out listViewItems);
229        return listViewItems == null ? Enumerable.Empty<ListViewItem>() : listViewItems;
230      }
231    }
232
233    #region ListView Events
234    protected virtual void itemsListView_SelectedIndexChanged(object sender, EventArgs e) {
235      moveUpButton.Enabled = itemsListView.SelectedItems.Count == 1 &&
236                             itemsListView.SelectedIndices[0] != 0 &&
237                             (Content != null) && !Content.IsReadOnly && !ReadOnly;
238      moveDownButton.Enabled = itemsListView.SelectedItems.Count == 1 &&
239                               itemsListView.SelectedIndices[0] != itemsListView.Items.Count - 1 &&
240                               (Content != null) && !Content.IsReadOnly && !ReadOnly;
241      removeButton.Enabled = itemsListView.SelectedItems.Count > 0 &&
242                             (Content != null) && !Content.IsReadOnly && !ReadOnly;
243      AdjustListViewColumnSizes();
244      if (itemsListView.SelectedItems.Count == 1) {
245        var item = (T)itemsListView.SelectedItems[0].Tag;
246        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
247        var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this, true);
248        if (outermostViewHost.HotlinkingEnabled) {
249          outermostViewHost.ActiveView.ReadOnly = ReadOnly;
250          outermostViewHost.ActiveView.Locked = Locked;
251        } else {
252          if (showDetailsCheckBox.Checked) {
253            detailsGroupBox.Enabled = true;
254            viewHost.Content = item;
255          } else {
256            viewHost.Content = null;
257            detailsGroupBox.Enabled = false;
258          }
259        }
260      }
261    }
262
263    protected virtual void itemsListView_KeyDown(object sender, KeyEventArgs e) {
264      if (e.KeyCode == Keys.Delete) {
265        if ((itemsListView.SelectedItems.Count > 0) && !Content.IsReadOnly && !ReadOnly) {
266          foreach (ListViewItem item in itemsListView.SelectedItems)
267            Content.RemoveAt(item.Index);
268        }
269      }
270    }
271
272    protected virtual void itemsListView_DoubleClick(object sender, EventArgs e) {
273      if (itemsListView.SelectedItems.Count == 1) {
274        var item = (T)itemsListView.SelectedItems[0].Tag;
275        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
276        var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this);
277        outermostViewHost.ActiveView.ReadOnly = ReadOnly;
278        outermostViewHost.ActiveView.Locked = Locked;
279      }
280    }
281
282    protected virtual void itemsListView_ItemDrag(object sender, ItemDragEventArgs e) {
283      if (!Locked) {
284        List<T> items = new List<T>();
285        foreach (ListViewItem listViewItem in itemsListView.SelectedItems) {
286          T item = listViewItem.Tag as T;
287          if (item != null) items.Add(item);
288        }
289
290        if (items.Count > 0) {
291          DataObject data = new DataObject();
292          if (items.Count == 1) data.SetData(HeuristicLab.Common.Constants.DragDropDataFormat, items[0]);
293          else data.SetData(HeuristicLab.Common.Constants.DragDropDataFormat, items);
294          if (Content.IsReadOnly || ReadOnly) {
295            DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link);
296          } else {
297            DragDropEffects result = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move);
298            if ((result & DragDropEffects.Move) == DragDropEffects.Move) {
299              foreach (ListViewItem listViewItem in itemsListView.SelectedItems.Cast<ListViewItem>().ToArray()) {
300                if (listViewItem.Tag != null) Content.RemoveAt(listViewItem.Index);
301              }
302            }
303          }
304        }
305      }
306    }
307    protected virtual void itemsListView_DragEnter(object sender, DragEventArgs e) {
308      validDragOperation = false;
309      if (!Content.IsReadOnly && !ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is T)) {
310        validDragOperation = true;
311      } else if (!Content.IsReadOnly && !ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IEnumerable)) {
312        validDragOperation = true;
313        IEnumerable items = (IEnumerable)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
314        foreach (object item in items)
315          validDragOperation = validDragOperation && (item is T);
316      }
317    }
318    protected virtual void itemsListView_DragOver(object sender, DragEventArgs e) {
319      e.Effect = DragDropEffects.None;
320      if (validDragOperation) {
321        if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
322        else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move;  // SHIFT key
323        else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
324        else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move;
325        else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link;
326      }
327    }
328    protected virtual void itemsListView_DragDrop(object sender, DragEventArgs e) {
329      if (e.Effect != DragDropEffects.None) {
330        Point p = itemsListView.PointToClient(new Point(e.X, e.Y));
331        ListViewItem listViewItem = itemsListView.GetItemAt(p.X, p.Y);
332
333        if (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is T) {
334          T item = (T)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
335          if (listViewItem != null) Content.Insert(listViewItem.Index, e.Effect.HasFlag(DragDropEffects.Copy) ? (T)item.Clone() : item);
336          else Content.Add(e.Effect.HasFlag(DragDropEffects.Copy) ? (T)item.Clone() : item);
337        } else if (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IEnumerable) {
338          IEnumerable<T> items = ((IEnumerable)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat)).Cast<T>();
339          if (e.Effect.HasFlag(DragDropEffects.Copy)) {
340            Cloner cloner = new Cloner();
341            items = items.Select(x => cloner.Clone(x));
342          }
343          foreach (T item in items) {
344            if (listViewItem != null) Content.Insert(listViewItem.Index, item);
345            else Content.Add(item);
346          }
347        }
348      }
349    }
350    #endregion
351
352    #region Button Events
353    protected virtual void addButton_Click(object sender, EventArgs e) {
354      T item = CreateItem();
355      if (item != null)
356        Content.Add(item);
357    }
358    protected virtual void moveUpButton_Click(object sender, EventArgs e) {
359      if (itemsListView.SelectedItems.Count == 1) {
360        int index = itemsListView.SelectedIndices[0];
361        Content.Reverse(index - 1, 2);
362        itemsListView.Items[index].Selected = false;
363        itemsListView.Items[index - 1].Selected = true;
364      }
365    }
366    protected virtual void moveDownButton_Click(object sender, EventArgs e) {
367      if (itemsListView.SelectedItems.Count == 1) {
368        int index = itemsListView.SelectedIndices[0];
369        Content.Reverse(index, 2);
370        itemsListView.Items[index].Selected = false;
371        itemsListView.Items[index + 1].Selected = true;
372      }
373    }
374    protected virtual void removeButton_Click(object sender, EventArgs e) {
375      if (itemsListView.SelectedItems.Count > 0) {
376        foreach (ListViewItem item in itemsListView.SelectedItems)
377          Content.RemoveAt(item.Index);
378      }
379    }
380    #endregion
381
382    #region CheckBox Events
383    protected virtual void showDetailsCheckBox_CheckedChanged(object sender, EventArgs e) {
384      if (showDetailsCheckBox.Checked) {
385        splitContainer.Panel2Collapsed = false;
386        detailsGroupBox.Enabled = itemsListView.SelectedItems.Count == 1;
387        viewHost.Content = itemsListView.SelectedItems.Count == 1 ? (T)itemsListView.SelectedItems[0].Tag : null;
388      } else {
389        splitContainer.Panel2Collapsed = true;
390        viewHost.Content = null;
391      }
392    }
393    #endregion
394
395    #region Content Events
396    protected virtual void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<T>> e) {
397      if (InvokeRequired)
398        Invoke(new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_ItemsAdded), sender, e);
399      else {
400        foreach (IndexedItem<T> item in e.Items)
401          InsertListViewItem(item.Index, CreateListViewItem(item.Value));
402        AdjustListViewColumnSizes();
403      }
404    }
405    protected virtual void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<T>> e) {
406      if (InvokeRequired)
407        Invoke(new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_ItemsRemoved), sender, e);
408      else {
409        List<ListViewItem> listViewItems = new List<ListViewItem>();
410        foreach (IndexedItem<T> item in e.Items)
411          listViewItems.Add(itemsListView.Items[item.Index]);
412        foreach (ListViewItem listViewItem in listViewItems)
413          RemoveListViewItem(listViewItem);
414        RebuildImageList();
415      }
416    }
417    protected virtual void Content_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IndexedItem<T>> e) {
418      if (InvokeRequired)
419        Invoke(new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_ItemsReplaced), sender, e);
420      else {
421        int[] selected = new int[itemsListView.SelectedIndices.Count];
422        itemsListView.SelectedIndices.CopyTo(selected, 0);
423
424        List<ListViewItem> listViewItems = new List<ListViewItem>();
425        foreach (IndexedItem<T> item in e.OldItems)
426          listViewItems.Add(itemsListView.Items[item.Index]);
427        foreach (ListViewItem listViewItem in listViewItems)
428          RemoveListViewItem(listViewItem);
429        RebuildImageList();
430
431        foreach (IndexedItem<T> item in e.Items)
432          InsertListViewItem(item.Index, CreateListViewItem(item.Value));
433        AdjustListViewColumnSizes();
434
435        for (int i = 0; i < selected.Length; i++)
436          itemsListView.Items[selected[i]].Selected = true;
437      }
438    }
439    protected virtual void Content_ItemsMoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<T>> e) {
440      if (InvokeRequired)
441        Invoke(new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_ItemsMoved), sender, e);
442      else {
443        foreach (IndexedItem<T> item in e.Items) {
444          ListViewItem listViewItem = itemsListView.Items[item.Index];
445          if (listViewItem.Tag != null)
446            itemListViewItemMapping[(T)listViewItem.Tag].Remove(listViewItem);
447          listViewItem.Tag = item.Value;
448          if (listViewItem.Tag != null)
449            itemListViewItemMapping[item.Value].Add(listViewItem);
450          UpdateListViewItemImage(listViewItem);
451          UpdateListViewItemText(listViewItem);
452        }
453      }
454    }
455    protected virtual void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IndexedItem<T>> e) {
456      if (InvokeRequired)
457        Invoke(new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_CollectionReset), sender, e);
458      else {
459        List<ListViewItem> listViewItems = new List<ListViewItem>();
460        foreach (IndexedItem<T> item in e.OldItems)
461          listViewItems.Add(itemsListView.Items[item.Index]);
462        foreach (ListViewItem listViewItem in listViewItems)
463          RemoveListViewItem(listViewItem);
464        RebuildImageList();
465
466        foreach (IndexedItem<T> item in e.Items)
467          InsertListViewItem(item.Index, CreateListViewItem(item.Value));
468        AdjustListViewColumnSizes();
469      }
470    }
471    #endregion
472
473    #region Item Events
474    protected virtual void Item_ItemImageChanged(object sender, EventArgs e) {
475      if (InvokeRequired)
476        Invoke(new EventHandler(Item_ItemImageChanged), sender, e);
477      else {
478        T item = (T)sender;
479        foreach (ListViewItem listViewItem in GetListViewItemsForItem(item))
480          UpdateListViewItemImage(listViewItem);
481      }
482    }
483    protected virtual void Item_ToStringChanged(object sender, EventArgs e) {
484      if (InvokeRequired)
485        Invoke(new EventHandler(Item_ToStringChanged), sender, e);
486      else {
487        T item = (T)sender;
488        foreach (ListViewItem listViewItem in GetListViewItemsForItem(item))
489          UpdateListViewItemText(listViewItem);
490        AdjustListViewColumnSizes();
491      }
492    }
493    #endregion
494
495    #region Helpers
496    protected virtual void AdjustListViewColumnSizes() {
497      if (itemsListView.Items.Count > 0) {
498        for (int i = 0; i < itemsListView.Columns.Count; i++)
499          itemsListView.Columns[i].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
500      }
501    }
502    protected virtual void RebuildImageList() {
503      itemsListView.SmallImageList.Images.Clear();
504      foreach (ListViewItem listViewItem in itemsListView.Items) {
505        T item = listViewItem.Tag as T;
506        itemsListView.SmallImageList.Images.Add(item == null ? HeuristicLab.Common.Resources.VSImageLibrary.Nothing : item.ItemImage);
507        listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1;
508      }
509    }
510    #endregion
511  }
512}
Note: See TracBrowser for help on using the repository browser.