Index: branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/ChartAnalysisView.cs
===================================================================
--- branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/ChartAnalysisView.cs	(revision 9377)
+++ branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/ChartAnalysisView.cs	(revision 9378)
@@ -44,4 +44,6 @@
     }
 
+    private List<IRun> runs;
+
     public ChartAnalysisView() {
       InitializeComponent();
@@ -77,11 +79,5 @@
       Content.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
       Content.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
-
-      RegisterRunEvents(Content);
-    }
-
-    private void RegisterRunEvents(IEnumerable<IRun> runs) {
-      foreach (IRun run in runs)
-        run.Changed += new EventHandler(run_Changed);
+      Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged;
     }
 
@@ -91,37 +87,22 @@
       Content.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
       Content.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
-
-      DeregisterRunEvents(Content);
-    }
-
-    private void DeregisterRunEvents(IEnumerable<IRun> runs) {
-      foreach (IRun run in runs)
-        run.Changed -= new EventHandler(run_Changed);
+      Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged;
     }
 
     private void Content_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
-      DeregisterRunEvents(e.OldItems);
-      RegisterRunEvents(e.Items);
-      RebuildCombinedDataTable();
+      RebuildDataTable();
     }
 
     private void Content_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
-      DeregisterRunEvents(e.Items);
-      RebuildCombinedDataTable();
+      RebuildDataTable();
     }
 
     private void Content_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IRun> e) {
-      RegisterRunEvents(e.Items);
-      RebuildCombinedDataTable();
-    }
-
-    private void run_Changed(object sender, EventArgs e) {
-      if (InvokeRequired)
-        this.Invoke(new EventHandler(run_Changed), sender, e);
-      else {
-        if (!Content.UpdateOfRunsInProgress) {
-          IRun run = (IRun)sender;
-          UpdateRun(run);
-        }
+      RebuildDataTable();
+    }
+
+    void Content_UpdateOfRunsInProgressChanged(object sender, EventArgs e) {
+      if (!Content.UpdateOfRunsInProgress) {
+        RebuildDataTable();
       }
     }
@@ -131,5 +112,5 @@
     void DataGridView_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) {
       if (e.RowIndex >= 0) {
-        IRun run = Content.ElementAt(stringConvertibleMatrixView.GetRowIndex(e.RowIndex));
+        IRun run = runs[stringConvertibleMatrixView.GetRowIndex(e.RowIndex)];
         IContentView view = MainFormManager.MainForm.ShowContent(run);
         if (view != null) {
@@ -145,5 +126,5 @@
 
     private void dataRowComboBox_SelectedIndexChanged(object sender, EventArgs e) {
-      RebuildCombinedDataTable();
+      RebuildDataTable();
     }
 
@@ -151,7 +132,6 @@
       string resultName = (string)dataTableComboBox.SelectedItem;
       string rowName = (string)dataRowComboBox.SelectedItem;
-      var runs = Content.Where(x => x.Results.ContainsKey(resultName) && x.Visible);
-
-      foreach (Run run in runs) {
+
+      foreach (IRun run in runs) {
         DataTable resTable = (DataTable)run.Results[resultName];
         DataRow row = resTable.Rows[rowName];
@@ -173,27 +153,22 @@
       string resultName = (string)dataTableComboBox.SelectedItem;
       string rowName = (string)dataRowComboBox.SelectedItem;
-      var runs = Content.Where(x => x.Results.ContainsKey(resultName) && x.Visible);
-      StringMatrix sm = (StringMatrix)stringConvertibleMatrixView.Content;
+      DoubleMatrix sm = (DoubleMatrix)stringConvertibleMatrixView.Content;
 
       Content.UpdateOfRunsInProgress = true;
       for (int i = 0; i < runs.Count(); i++) {
-        IRun run = runs.ElementAt(i);
+        IRun run = runs[i];
 
         for (int j = 0; j < sm.ColumnNames.Count(); j++) {
-          string newResultName = resultName + " " + rowName + " " + sm.ColumnNames.ElementAt(j);
-          if (!run.Results.ContainsKey(newResultName))
-            run.Results.Add(new KeyValuePair<string, Core.IItem>(newResultName, new DoubleValue(double.Parse(sm[i, j]))));
+          if (stringConvertibleMatrixView.DataGridView.Columns[j].Visible) {
+            string newResultName = resultName + " " + rowName + " " + sm.ColumnNames.ElementAt(j);
+            if (!run.Results.ContainsKey(newResultName)) {
+              run.Results.Add(new KeyValuePair<string, Core.IItem>(newResultName, new DoubleValue(sm[i, j])));
+            }
+          }
         }
       }
       Content.UpdateOfRunsInProgress = false;
-      //update column names of run collection
-      Content.Modify();
     }
     #endregion
-
-    private void UpdateRun(IRun run) {
-      //TODO: hacky di hack... this is baaaadddd
-      RebuildCombinedDataTable();
-    }
 
     private void UpdateDataRowComboBox() {
@@ -222,12 +197,11 @@
     }
 
-    private void RebuildCombinedDataTable() {
+    private void RebuildDataTable() {
       string resultName = (string)dataTableComboBox.SelectedItem;
       string rowName = (string)dataRowComboBox.SelectedItem;
       string[] columnNames = new string[] { "Count", "Minimum", "Maximum", "Average", "Median", "Standard Deviation", "Variance", "25th Percentile", "75th Percentile", "Gradient", "Relative Error", "Avg. of Upper 25 %", " Avg. of Lower 25 %", "Avg. of First 25 %", "Avg. of Last 25 %" };
 
-      var runs = Content.Where(x => x.Results.ContainsKey(resultName) && x.Visible);
-
-      StringMatrix dt = new StringMatrix(runs.Count(), columnNames.Count());
+      runs = Content.Where(x => x.Results.ContainsKey(resultName) && x.Visible).ToList();
+      DoubleMatrix dt = new DoubleMatrix(runs.Count(), columnNames.Count());
       dt.RowNames = runs.Select(x => x.Name);
       dt.ColumnNames = columnNames;
@@ -257,24 +231,27 @@
         double lastAvg = values.Skip((int)(values.Count() * 0.75)).Average();
 
-        dt[i, 0] = cnt.ToString();
-        dt[i, 1] = min.ToString();
-        dt[i, 2] = max.ToString();
-        dt[i, 3] = avg.ToString();
-        dt[i, 4] = median.ToString();
-        dt[i, 5] = stdDev.ToString();
-        dt[i, 6] = variance.ToString();
-        dt[i, 7] = percentile25.ToString();
-        dt[i, 8] = percentile75.ToString();
-        dt[i, 9] = k.ToString();
-        dt[i, 10] = r.ToString();
-        dt[i, 11] = upperAvg.ToString();
-        dt[i, 12] = lowerAvg.ToString();
-        dt[i, 13] = firstAvg.ToString();
-        dt[i, 14] = lastAvg.ToString();
+        dt[i, 0] = cnt;
+        dt[i, 1] = min;
+        dt[i, 2] = max;
+        dt[i, 3] = avg;
+        dt[i, 4] = median;
+        dt[i, 5] = stdDev;
+        dt[i, 6] = variance;
+        dt[i, 7] = percentile25;
+        dt[i, 8] = percentile75;
+        dt[i, 9] = k;
+        dt[i, 10] = r;
+        dt[i, 11] = upperAvg;
+        dt[i, 12] = lowerAvg;
+        dt[i, 13] = firstAvg;
+        dt[i, 14] = lastAvg;
 
         i++;
       }
-
       stringConvertibleMatrixView.Content = dt;
+
+      for (i = 0; i < runs.Count(); i++) {
+        stringConvertibleMatrixView.DataGridView.Rows[i].DefaultCellStyle.ForeColor = runs[i].Color;
+      }
     }
   }
