Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/18/14 16:55:53 (10 years ago)
Author:
ascheibe
Message:

#2031 improved code of views

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/CorrelationView.cs

    r11644 r11697  
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using HeuristicLab.Collections;
    26 using HeuristicLab.Core;
    2725using HeuristicLab.Core.Views;
    2826using HeuristicLab.Data;
     
    8078    protected override void RegisterContentEvents() {
    8179      base.RegisterContentEvents();
    82       Content.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
    83       Content.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
     80      Content.ColumnsChanged += Content_ColumnsChanged;
     81      Content.RowsChanged += Content_RowsChanged;
    8482      Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    8583      Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged;
    86       RegisterRunEvents(Content);
    8784    }
    8885
    8986    protected override void DeregisterContentEvents() {
    9087      base.DeregisterContentEvents();
    91       Content.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
    92       Content.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
     88      Content.ColumnsChanged -= Content_ColumnsChanged;
     89      Content.RowsChanged -= Content_RowsChanged;
    9390      Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
    9491      Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged;
    95       DeregisterRunEvents(Content);
    96     }
    97 
    98     private void RegisterRunEvents(IEnumerable<IRun> runs) {
    99       foreach (IRun run in runs) {
    100         RegisterRunResultsEvents(run);
    101         RegisterRunParametersEvents(run);
    102         run.PropertyChanged += run_PropertyChanged;
    103       }
    104     }
    105 
    106     private void DeregisterRunEvents(IEnumerable<IRun> runs) {
    107       foreach (IRun run in runs) {
    108         DeregisterRunResultsEvents(run);
    109         DeregisterRunParametersEvents(run);
    110         run.PropertyChanged -= run_PropertyChanged;
    111       }
    112     }
    113 
    114     private void RegisterRunResultsEvents(IRun run) {
    115       IObservableDictionary<string, IItem> dict = run.Results;
    116       dict.ItemsAdded += run_Changed;
    117       dict.ItemsRemoved += run_Changed;
    118       dict.ItemsReplaced += run_Changed;
    119       dict.CollectionReset += run_Changed;
    120     }
    121 
    122     private void DeregisterRunResultsEvents(IRun run) {
    123       IObservableDictionary<string, IItem> dict = run.Results;
    124       dict.ItemsAdded -= run_Changed;
    125       dict.ItemsRemoved -= run_Changed;
    126       dict.ItemsReplaced -= run_Changed;
    127       dict.CollectionReset -= run_Changed;
    128     }
    129 
    130     private void RegisterRunParametersEvents(IRun run) {
    131       IObservableDictionary<string, IItem> dict = run.Parameters;
    132       dict.ItemsAdded += run_Changed;
    133       dict.ItemsRemoved += run_Changed;
    134       dict.ItemsReplaced += run_Changed;
    135       dict.CollectionReset += run_Changed;
    136     }
    137 
    138     private void DeregisterRunParametersEvents(IRun run) {
    139       IObservableDictionary<string, IItem> dict = run.Parameters;
    140       dict.ItemsAdded -= run_Changed;
    141       dict.ItemsRemoved -= run_Changed;
    142       dict.ItemsReplaced -= run_Changed;
    143       dict.CollectionReset -= run_Changed;
     92    }
     93
     94    void Content_RowsChanged(object sender, EventArgs e) {
     95      UpdateUI();
     96    }
     97
     98    void Content_ColumnsChanged(object sender, EventArgs e) {
     99      UpdateUI();
    144100    }
    145101
    146102    private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    147       DeregisterRunEvents(e.OldItems);
    148       RegisterRunEvents(e.Items);
    149       UpdateUI();
    150     }
    151 
    152     private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    153       DeregisterRunEvents(e.Items);
    154       UpdateUI();
    155     }
    156 
    157     private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
    158       RegisterRunEvents(e.Items);
    159103      UpdateUI();
    160104    }
     
    162106    private void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
    163107      suppressUpdates = Content.UpdateOfRunsInProgress;
    164       UpdateUI();
    165     }
    166 
    167     private void run_Changed(object sender, EventArgs e) {
    168       if (InvokeRequired) {
    169         Invoke(new EventHandler(run_Changed), sender, e);
    170       }
    171       UpdateUI();
    172     }
    173 
    174     void run_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) {
    175108      UpdateUI();
    176109    }
Note: See TracChangeset for help on using the changeset viewer.