Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.CEDMA.Charting/3.3/TableResultsView.cs @ 2291

Last change on this file since 2291 was 2289, checked in by mkommend, 15 years ago
  • added VisualMatrix to represent data in BubbleChart
  • made BubbleChart abstract and added inherited ModelingBubbleChart, which reacts as the BubbleChart
  • moved classes between CEDMA.Core and CEDMA.Charting
  • deleted unnecessary classes (results, resultsentry)

(ticket #723)

File size: 2.8 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Data;
6using System.Linq;
7using System.Text;
8using System.Windows.Forms;
9using HeuristicLab.Core;
10using HeuristicLab.CEDMA.Core;
11using HeuristicLab.PluginInfrastructure;
12using HeuristicLab.CEDMA.Charting;
13
14namespace HeuristicLab.CEDMA.Core {
15
16  public partial class TableResultsView : ViewBase {
17    private VisualMatrix VisualMatrix {
18      get { return (VisualMatrix)Item; }
19      set { Item = value; }
20    }
21    private bool suppressEvents;
22    public TableResultsView(VisualMatrix visualMatrix) {
23      suppressEvents = false;
24      InitializeComponent();
25      VisualMatrix = visualMatrix;
26      VisualMatrix.Changed += new EventHandler(VisualMatrixChanged);
27    }
28
29    private void VisualMatrixChanged(object sender, EventArgs e) {
30      if (suppressEvents) return;
31      UpdateControls();
32    }
33
34    protected override void UpdateControls() {
35      suppressEvents = true;
36      dataGridView.Rows.Clear();
37      dataGridView.Columns.Clear();
38      foreach (var attribute in VisualMatrix.Attributes) {
39        dataGridView.Columns.Add(attribute, attribute);
40      }
41
42      foreach (var row in VisualMatrix.Rows) {
43        if (row.Visible) {
44          int rowIndex = dataGridView.Rows.Add();
45          dataGridView.Rows[rowIndex].Tag = row;
46          foreach (string attrName in VisualMatrix.Attributes) {
47            dataGridView.Rows[rowIndex].Cells[attrName].Value = row.Get(attrName);
48          }
49          if (row.Selected) dataGridView.Rows[rowIndex].Selected = true;
50        }
51      }
52      dataGridView.Update();
53      suppressEvents = false;
54    }
55
56    private void dataGridView_SelectionChanged(object sender, EventArgs e) {
57      if (suppressEvents) return;
58      foreach (DataGridViewRow row in dataGridView.Rows) {
59        ((VisualMatrixRow)row.Tag).Selected = row.Selected;
60      }
61      suppressEvents = true;
62      VisualMatrix.FireChanged();
63      suppressEvents = false;
64    }
65
66    private void dataGridView_MouseDoubleClick(object sender, MouseEventArgs e) {
67      if (e.Button == MouseButtons.Left && e.Clicks == 2) {
68        DataGridView.HitTestInfo hitInfo = dataGridView.HitTest(e.X, e.Y);
69        VisualMatrixRow entry = (VisualMatrixRow)dataGridView.Rows[hitInfo.RowIndex].Tag;       
70        var model = (IItem)PersistenceManager.RestoreFromGZip((byte[])entry.Get("PersistedData"));
71        PluginManager.ControlManager.ShowControl(model.CreateView());
72      }
73    }
74  }
75
76  public class TablesResultsViewFactory : IResultsViewFactory {
77    #region IResultsViewFactory Members
78
79    public string Name {
80      get { return "Table"; }
81    }
82
83    public IControl CreateView(VisualMatrix matrix) {
84      return new TableResultsView(matrix);
85    }
86
87    #endregion
88  }
89}
Note: See TracBrowser for help on using the repository browser.