Changeset 9857


Ignore:
Timestamp:
08/07/13 07:19:20 (9 years ago)
Author:
gkronber
Message:

#2044: merged r9839 from trunk to stable branch.

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Core.Views/3.3/CheckedItemCollectionView.cs

    r9456 r9857  
    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}
  • stable/HeuristicLab.Core.Views/3.3/CheckedItemListView.cs

    r9456 r9857  
    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.