Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4944


Ignore:
Timestamp:
11/26/10 13:27:55 (14 years ago)
Author:
mkommend
Message:

Added code to react on visibility changes of runs in the RunCollectionVariableImpactView (ticket #1200).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/RunCollectionVariableImpactView.cs

    r4385 r4944  
    3333  [Content(typeof(RunCollection), false)]
    3434  [View("RunCollection Variable Impact View")]
    35   public partial class RunCollectionVariableImpactView : AsynchronousContentView {
     35  public sealed partial class RunCollectionVariableImpactView : AsynchronousContentView {
    3636    private const string variableImpactResultName = "Integrated variable frequencies";
    3737    public RunCollectionVariableImpactView() {
     
    4444    }
    4545
     46    #region events
    4647    protected override void RegisterContentEvents() {
    4748      base.RegisterContentEvents();
    48       this.Content.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
    49       this.Content.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    50       this.Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     49      Content.UpdateOfRunsInProgressChanged += new EventHandler(Content_UpdateOfRunsInProgressChanged);
     50      Content.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
     51      Content.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
     52      Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     53      RegisterRunEvents(Content);
    5154    }
    5255    protected override void DeregisterContentEvents() {
    5356      base.RegisterContentEvents();
    54       this.Content.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
    55       this.Content.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
    56       this.Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    57     }
     57      Content.UpdateOfRunsInProgressChanged -= new EventHandler(Content_UpdateOfRunsInProgressChanged);
     58      Content.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
     59      Content.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
     60      Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
     61      DeregisterRunEvents(Content);
     62    }
     63    private void RegisterRunEvents(IEnumerable<IRun> runs) {
     64      foreach (IRun run in runs)
     65        run.Changed += new EventHandler(Run_Changed);
     66    }
     67    private void DeregisterRunEvents(IEnumerable<IRun> runs) {
     68      foreach (IRun run in runs)
     69        run.Changed -= new EventHandler(Run_Changed);
     70    }
     71    private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
     72      RegisterRunEvents(e.Items);
     73      UpdateData();
     74    }
     75    private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
     76      DeregisterRunEvents(e.Items);
     77      UpdateData();
     78    }
     79    private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
     80      DeregisterRunEvents(e.OldItems);
     81      RegisterRunEvents(e.Items);
     82      UpdateData();
     83    }
     84    private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
     85      if (!Content.UpdateOfRunsInProgress) UpdateData();
     86    }
     87    private void Run_Changed(object sender, EventArgs e) {
     88      if (!Content.UpdateOfRunsInProgress) UpdateData();
     89    }
     90    #endregion
    5891
    5992    protected override void OnContentChanged() {
    6093      base.OnContentChanged();
    61       this.UpdateData();
    62     }
    63     private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    64       this.UpdateData();
    65     }
    66     private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    67       this.UpdateData();
    68     }
    69     private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    7094      this.UpdateData();
    7195    }
Note: See TracChangeset for help on using the changeset viewer.