Free cookie consent management tool by TermsFeed Policy Generator

source: branches/histogram/HeuristicLab.Analysis.Views/3.3/DataTableVisualPropertiesDialog.cs @ 6012

Last change on this file since 6012 was 6012, checked in by abeham, 13 years ago

#1465

  • fine tuned UI for setting data(table|row) visual properties
  • added control for the data table visual properties
  • added a few more visual properties
File size: 2.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System.Collections.Generic;
23using System.Windows.Forms;
24using HeuristicLab.Common.Resources;
25
26namespace HeuristicLab.Analysis.Views {
27  public partial class DataTableVisualPropertiesDialog : Form {
28    protected DataTable Content { get; private set; }
29    private DataTableVisualProperties originalDataTableVPs;
30    private Dictionary<string, DataRowVisualProperties> originalDataRowVPs;
31
32    public DataTableVisualPropertiesDialog(DataTable dataTable) {
33      InitializeComponent();
34      Content = dataTable;
35      originalDataTableVPs = (DataTableVisualProperties)Content.VisualProperties.Clone();
36      originalDataRowVPs = new Dictionary<string, DataRowVisualProperties>();
37      foreach (DataRow row in Content.Rows)
38        originalDataRowVPs.Add(row.Name, (DataRowVisualProperties)row.VisualProperties.Clone());
39      seriesListView.Items.Clear();
40      seriesListView.SmallImageList = new ImageList();
41      seriesListView.SmallImageList.Images.Add(VSImageLibrary.Graph);
42      FillSeriesListView();
43      dataTableVisualPropertiesControl.Content = Content.VisualProperties;
44    }
45
46    private void FillSeriesListView() {
47      seriesListView.SelectedIndices.Clear();
48      foreach (DataRow row in Content.Rows) {
49        seriesListView.Items.Add(new ListViewItem(row.Name, 0));
50      }
51      seriesListView.SelectedIndices.Add(0);
52    }
53
54    private void seriesListView_SelectedIndexChanged(object sender, System.EventArgs e) {
55      if (seriesListView.SelectedItems.Count == 0) return;
56      string rowName = seriesListView.SelectedItems[0].Text;
57      dataRowVisualPropertiesControl.Content = Content.Rows[rowName].VisualProperties;
58    }
59
60    private void okButton_Click(object sender, System.EventArgs e) {
61      DialogResult = DialogResult.OK;
62      Close();
63    }
64
65    private void cancelButton_Click(object sender, System.EventArgs e) {
66      DialogResult = DialogResult.Cancel;
67      foreach (DataRow row in Content.Rows) {
68        row.VisualProperties = originalDataRowVPs[row.Name];
69      }
70      Content.VisualProperties = originalDataTableVPs;
71      Close();
72    }
73  }
74}
Note: See TracBrowser for help on using the repository browser.