Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9839 for trunk


Ignore:
Timestamp:
08/01/13 16:56:57 (11 years ago)
Author:
abeham
Message:

#2044:

  • Updated checked state of listview items in CheckedItemListView when elements were moved in the CheckedItemList
  • Cosmetic change in CheckedItemCollectionView
Location:
trunk/sources/HeuristicLab.Core.Views/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core.Views/3.3/CheckedItemCollectionView.cs

    r9456 r9839  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Drawing;
    2425using System.Linq;
     
    9798
    9899    #region Content Events
    99     protected virtual void Content_CheckedItemsChanged(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<T> e) {
     100    protected virtual void Content_CheckedItemsChanged(object sender, CollectionItemsChangedEventArgs<T> e) {
    100101      if (InvokeRequired)
    101102        Invoke(new CollectionItemsChangedEventHandler<T>(Content_CheckedItemsChanged), sender, e);
    102103      else {
    103         foreach (T item in e.Items) {
    104           foreach (ListViewItem listViewItem in GetListViewItemsForItem(item)) {
    105             if (listViewItem.Checked != Content.ItemChecked(item))
    106               listViewItem.Checked = Content.ItemChecked(item);
    107           }
    108         }
     104        UpdateCheckedItemState(e.Items);
    109105        SetNumberOfCheckItems();
    110106      }
     
    131127      }
    132128    }
     129
     130    private void UpdateCheckedItemState(IEnumerable<T> items) {
     131      foreach (T item in items) {
     132        foreach (ListViewItem listViewItem in GetListViewItemsForItem(item)) {
     133          var isChecked = Content.ItemChecked(item);
     134          if (listViewItem.Checked != isChecked)
     135            listViewItem.Checked = isChecked;
     136        }
     137      }
     138    }
    133139  }
    134140}
  • trunk/sources/HeuristicLab.Core.Views/3.3/CheckedItemListView.cs

    r9456 r9839  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Drawing;
    2425using System.Linq;
     
    137138        Invoke(new CollectionItemsChangedEventHandler<IndexedItem<T>>(Content_CheckedItemsChanged), sender, e);
    138139      else {
    139         foreach (var item in e.Items) {
    140           if (itemsListView.Items[item.Index].Checked != Content.ItemChecked(item.Value))
    141             itemsListView.Items[item.Index].Checked = Content.ItemChecked(item.Value);
    142         }
     140        UpdateCheckedItemState(e.Items);
    143141        SetNumberOfCheckItems();
    144142      }
     
    154152    protected override void Content_ItemsMoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<T>> e) {
    155153      base.Content_ItemsMoved(sender, e);
     154      UpdateCheckedItemState(e.Items);
    156155      SetNumberOfCheckItems();
    157156    }
     
    173172      }
    174173    }
     174
     175    private void UpdateCheckedItemState(IEnumerable<IndexedItem<T>> items) {
     176      foreach (var item in items) {
     177        var isChecked = Content.ItemChecked(item.Value);
     178        if (itemsListView.Items[item.Index].Checked != isChecked)
     179          itemsListView.Items[item.Index].Checked = isChecked;
     180      }
     181    }
    175182  }
    176183}
Note: See TracChangeset for help on using the changeset viewer.