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