Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/08/11 01:47:47 (14 years ago)
Author:
swagner
Message:

#1324:

  • Added performance optimization in all other item collection views
  • Checked and refactored item event registration/deregistration
  • Enabled null items in item collection views
  • Moved non-default Dispose methods from designer files into user files
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionConstraintCollectionView.cs

    r4162 r5237  
    2323using System.Drawing;
    2424using System.Windows.Forms;
    25 using HeuristicLab.Collections;
    2625using HeuristicLab.Core;
    2726using HeuristicLab.Core.Views;
     
    6059    protected override ListViewItem CreateListViewItem(IRunCollectionConstraint item) {
    6160      ListViewItem listViewItem = base.CreateListViewItem(item);
    62       if (item.Active)
    63         listViewItem.Font = new Font(listViewItem.Font, FontStyle.Bold);
    64       else
    65         listViewItem.Font = new Font(listViewItem.Font, FontStyle.Regular);
     61      if (item != null) {
     62        listViewItem.Font = item.Active ? new Font(listViewItem.Font, FontStyle.Bold) : new Font(listViewItem.Font, FontStyle.Regular);
     63      }
    6664      return listViewItem;
    6765    }
    6866
    69     protected override void RegisterContentEvents() {
    70       base.RegisterContentEvents();
    71       foreach (IRunCollectionConstraint constraint in Content)
    72         RegisterConstraintEvents(constraint);
     67    protected override void DeregisterItemEvents(IRunCollectionConstraint item) {
     68      item.ActiveChanged -= new EventHandler(Item_ActiveChanged);
     69      base.DeregisterItemEvents(item);
    7370    }
    74     protected override void DeregisterContentEvents() {
    75       base.DeregisterContentEvents();
    76       foreach (IRunCollectionConstraint constraint in Content)
    77         DeregisterConstraintEvents(constraint);
    78     }
    79     protected override void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) {
    80       base.Content_ItemsAdded(sender, e);
    81       foreach (IRunCollectionConstraint constraint in e.Items)
    82         RegisterConstraintEvents(constraint);
    83 
    84     }
    85     protected override void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) {
    86       base.Content_ItemsRemoved(sender, e);
    87       foreach (IRunCollectionConstraint constraint in e.Items)
    88         DeregisterConstraintEvents(constraint);
    89     }
    90     protected override void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) {
    91       base.Content_CollectionReset(sender, e);
    92       foreach (IRunCollectionConstraint constraint in e.OldItems)
    93         RegisterConstraintEvents(constraint);
    94       foreach (IRunCollectionConstraint constraint in e.Items)
    95         DeregisterConstraintEvents(constraint);
     71    protected override void RegisterItemEvents(IRunCollectionConstraint item) {
     72      base.RegisterItemEvents(item);
     73      item.ActiveChanged += new EventHandler(Item_ActiveChanged);
    9674    }
    9775
    98     protected virtual void RegisterConstraintEvents(IRunCollectionConstraint constraint) {
    99       constraint.ActiveChanged += new EventHandler(constraint_ActiveChanged);
    100     }
    101     protected virtual void DeregisterConstraintEvents(IRunCollectionConstraint constraint) {
    102       constraint.ActiveChanged -= new EventHandler(constraint_ActiveChanged);
    103     }
    104     protected virtual void constraint_ActiveChanged(object sender, EventArgs e) {
     76    protected virtual void Item_ActiveChanged(object sender, EventArgs e) {
    10577      IRunCollectionConstraint constraint = (IRunCollectionConstraint)sender;
    10678      foreach (ListViewItem listViewItem in GetListViewItemsForItem(constraint)) {
Note: See TracChangeset for help on using the changeset viewer.