Changeset 3449


Ignore:
Timestamp:
04/20/10 18:19:03 (11 years ago)
Author:
mkommend
Message:

added reaction of color & visibility of IRuns in RunCollectionView (ticket #970)

Location:
trunk/sources/HeuristicLab.Optimization.Views/3.3
Files:
3 edited

Legend:

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

    r3448 r3449  
    119119    }
    120120    private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    121       DeregisterRunEvents(e.OldItems);
     121      DeregisterRunEvents(e.Items);
    122122    }
    123123    private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionTabularView.cs

    r3448 r3449  
    8686    }
    8787    private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    88       DeregisterRunEvents(e.OldItems);
     88      DeregisterRunEvents(e.Items);
    8989    }
    9090    private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunCollectionView.cs

    r3435 r3449  
    2727using System.Windows.Forms;
    2828using System;
     29using System.Drawing;
    2930using System.Collections.Generic;
    3031
     
    5758      Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    5859      Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     60      DeregisterRunEvents(Content);
    5961      base.DeregisterContentEvents();
    6062    }
     
    6466      Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    6567      Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     68      RegisterRunEvents(Content);
     69    }
     70    protected virtual void RegisterRunEvents(IEnumerable<IRun> runs) {
     71      foreach (IRun run in runs)
     72        run.Changed += new EventHandler(run_Changed);
     73    }
     74    protected virtual void DeregisterRunEvents(IEnumerable<IRun> runs) {
     75      foreach (IRun run in runs)
     76        run.Changed -= new EventHandler(run_Changed);
    6677    }
    6778
     
    7889      }
    7990      SetEnabledStateOfControls();
     91    }
     92
     93    private void run_Changed(object sender, EventArgs e) {
     94      IRun run = (IRun)sender;
     95      foreach (ListViewItem listViewItem in GetListViewItemsForItem(run)) {
     96        if (run.Visible) {
     97          listViewItem.Font = new Font(listViewItem.Font, FontStyle.Regular);
     98          listViewItem.ForeColor = run.Color;
     99        } else {
     100          listViewItem.Font = new Font(listViewItem.Font, FontStyle.Italic);
     101          listViewItem.ForeColor = Color.LightGray;
     102        }
     103      }
    80104    }
    81105
     
    224248      if (InvokeRequired)
    225249        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded), sender, e);
    226       else
     250      else {
     251        RegisterRunEvents(e.Items);
    227252        foreach (IRun item in e.Items)
    228253          AddListViewItem(CreateListViewItem(item));
     254      }
    229255    }
    230256    protected virtual void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     
    232258        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved), sender, e);
    233259      else {
     260        DeregisterRunEvents(e.Items);
    234261        foreach (IRun item in e.Items) {
    235262          foreach (ListViewItem listViewItem in GetListViewItemsForItem(item)) {
     
    244271        Invoke(new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset), sender, e);
    245272      else {
     273        DeregisterRunEvents(e.OldItems);
    246274        foreach (IRun item in e.OldItems) {
    247275          foreach (ListViewItem listViewItem in GetListViewItemsForItem(item)) {
     
    250278          }
    251279        }
     280        RegisterRunEvents(e.Items);
    252281        foreach (IRun item in e.Items)
    253282          AddListViewItem(CreateListViewItem(item));
Note: See TracChangeset for help on using the changeset viewer.