Changeset 5275 for branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Views/3.3/RunCollectionVariableImpactView.cs
- Timestamp:
- 01/11/11 15:03:46 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis.Views/3.3/RunCollectionVariableImpactView.cs
r5010 r5275 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 using System.Windows.Forms; 25 using alglib;26 26 using HeuristicLab.Common; 27 27 using HeuristicLab.Data; … … 29 29 using HeuristicLab.MainForm.WindowsForms; 30 30 using HeuristicLab.Optimization; 31 using System;32 31 33 32 namespace HeuristicLab.Problems.DataAnalysis.Views { 34 33 [Content(typeof(RunCollection), false)] 35 34 [View("RunCollection Variable Impact View")] 36 public partial class RunCollectionVariableImpactView : AsynchronousContentView {35 public sealed partial class RunCollectionVariableImpactView : AsynchronousContentView { 37 36 private const string variableImpactResultName = "Integrated variable frequencies"; 38 37 public RunCollectionVariableImpactView() { … … 45 44 } 46 45 46 #region events 47 47 protected override void RegisterContentEvents() { 48 48 base.RegisterContentEvents(); 49 this.Content.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded); 50 this.Content.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 51 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); 52 54 } 53 55 protected override void DeregisterContentEvents() { 54 56 base.RegisterContentEvents(); 55 this.Content.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded); 56 this.Content.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved); 57 this.Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset); 58 } 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 59 91 60 92 protected override void OnContentChanged() { … … 62 94 this.UpdateData(); 63 95 } 64 private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {65 this.UpdateData();66 }67 private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {68 this.UpdateData();69 }70 private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {71 this.UpdateData();72 }73 96 74 97 private void UpdateData() { … … 76 99 } 77 100 78 p ublicDoubleMatrix CalculateVariableImpactMatrix() {101 private DoubleMatrix CalculateVariableImpactMatrix() { 79 102 DoubleMatrix matrix = null; 80 103 if (Content != null) { 81 List<IRun> runsWithVariables = Content.Where(r => r. Results.ContainsKey(variableImpactResultName)).ToList();104 List<IRun> runsWithVariables = Content.Where(r => r.Visible && r.Results.ContainsKey(variableImpactResultName)).ToList(); 82 105 IEnumerable<DoubleMatrix> allVariableImpacts = (from run in runsWithVariables 83 106 select run.Results[variableImpactResultName]).Cast<DoubleMatrix>();
Note: See TracChangeset
for help on using the changeset viewer.