Changeset 3327 for trunk/sources/HeuristicLab.Core.Views/3.3
- Timestamp:
- 04/13/10 12:01:02 (14 years ago)
- Location:
- trunk/sources/HeuristicLab.Core.Views/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs
r3317 r3327 102 102 listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription; 103 103 listViewItem.Tag = item; 104 SetListViewItemImage(listViewItem); 104 itemsListView.SmallImageList.Images.Add(item.ItemImage); 105 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 105 106 return listViewItem; 106 107 } … … 119 120 sortDescendingButton.Enabled = itemsListView.Items.Count > 0; 120 121 } 121 protected virtual void UpdateListViewItem(ListViewItem listViewItem) { 122 protected virtual void UpdateListViewItemImage(ListViewItem listViewItem) { 123 int i = listViewItem.ImageIndex; 124 listViewItem.ImageList.Images[i] = ((T)listViewItem.Tag).ItemImage; 125 listViewItem.ImageIndex = -1; 126 listViewItem.ImageIndex = i; 127 } 128 protected virtual void UpdateListViewItemText(ListViewItem listViewItem) { 122 129 if (!listViewItem.Text.Equals(listViewItem.Tag.ToString())) 123 130 listViewItem.Text = listViewItem.Tag.ToString(); 124 if (itemsListView.SmallImageList.Images[listViewItem.ImageIndex] != ((T)listViewItem.Tag).ItemImage)125 SetListViewItemImage(listViewItem);126 131 } 127 132 protected virtual IEnumerable<ListViewItem> GetListViewItemsForItem(T item) { … … 262 267 T item = (T)sender; 263 268 foreach (ListViewItem listViewItem in GetListViewItemsForItem(item)) 264 UpdateListViewItem (listViewItem);269 UpdateListViewItemImage(listViewItem); 265 270 } 266 271 } … … 271 276 T item = (T)sender; 272 277 foreach (ListViewItem listViewItem in GetListViewItemsForItem(item)) 273 UpdateListViewItem (listViewItem);278 UpdateListViewItemText(listViewItem); 274 279 } 275 280 } … … 277 282 278 283 #region Helpers 279 protected virtual void SetListViewItemImage(ListViewItem listViewItem) {280 T item = (T)listViewItem.Tag;281 int i = 0;282 while ((i < itemsListView.SmallImageList.Images.Count) && !item.ItemImage.Equals(itemsListView.SmallImageList.Images[i]))283 i++;284 if (i == itemsListView.SmallImageList.Images.Count) itemsListView.SmallImageList.Images.Add(item.ItemImage);285 listViewItem.ImageIndex = i;286 }287 284 protected virtual void SortItemsListView(SortOrder sortOrder) { 288 285 itemsListView.Sorting = SortOrder.None; -
trunk/sources/HeuristicLab.Core.Views/3.3/ItemListView.cs
r3306 r3327 123 123 listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription; 124 124 listViewItem.Tag = item; 125 SetListViewItemImage(listViewItem); 125 itemsListView.SmallImageList.Images.Add(item.ItemImage); 126 listViewItem.ImageIndex = itemsListView.SmallImageList.Images.Count - 1; 126 127 return listViewItem; 127 128 } … … 141 142 listViewItem.Remove(); 142 143 } 143 protected virtual void UpdateListViewItem(ListViewItem listViewItem) { 144 T item = (T)listViewItem.Tag; 145 listViewItem.Text = item.ToString(); 146 listViewItem.ToolTipText = item.ItemName + ": " + item.ItemDescription; 147 if (itemsListView.SmallImageList.Images[listViewItem.ImageIndex] != item.ItemImage) 148 SetListViewItemImage(listViewItem); 144 protected virtual void UpdateListViewItemImage(ListViewItem listViewItem) { 145 int i = listViewItem.ImageIndex; 146 listViewItem.ImageList.Images[i] = ((T)listViewItem.Tag).ItemImage; 147 listViewItem.ImageIndex = -1; 148 listViewItem.ImageIndex = i; 149 } 150 protected virtual void UpdateListViewItemText(ListViewItem listViewItem) { 151 if (!listViewItem.Text.Equals(listViewItem.Tag.ToString())) 152 listViewItem.Text = listViewItem.Tag.ToString(); 149 153 } 150 154 … … 311 315 ListViewItem listViewItem = itemsListView.Items[item.Index]; 312 316 listViewItem.Tag = item.Value; 313 UpdateListViewItem(listViewItem); 317 UpdateListViewItemImage(listViewItem); 318 UpdateListViewItemText(listViewItem); 314 319 } 315 320 } … … 339 344 foreach (ListViewItem listViewItem in itemsListView.Items) { 340 345 if (((T)listViewItem.Tag) == item) 341 UpdateListViewItem (listViewItem);346 UpdateListViewItemImage(listViewItem); 342 347 } 343 348 } … … 350 355 foreach (ListViewItem listViewItem in itemsListView.Items) { 351 356 if (((T)listViewItem.Tag) == item) 352 UpdateListViewItem (listViewItem);357 UpdateListViewItemText(listViewItem); 353 358 } 354 359 } 355 }356 #endregion357 358 #region Helpers359 protected virtual void SetListViewItemImage(ListViewItem listViewItem) {360 T item = (T)listViewItem.Tag;361 int i = 0;362 while ((i < itemsListView.SmallImageList.Images.Count) && (item.ItemImage != itemsListView.SmallImageList.Images[i]))363 i++;364 if (i == itemsListView.SmallImageList.Images.Count) itemsListView.SmallImageList.Images.Add(item.ItemImage);365 listViewItem.ImageIndex = i;366 360 } 367 361 #endregion -
trunk/sources/HeuristicLab.Core.Views/3.3/NamedItemCollectionView.cs
r2947 r3327 100 100 foreach (T item in e.Items) { 101 101 foreach (ListViewItem listViewItem in GetListViewItemsForItem(item)) 102 UpdateListViewItem (listViewItem);102 UpdateListViewItemText(listViewItem); 103 103 } 104 104 }
Note: See TracChangeset
for help on using the changeset viewer.