Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/DataPreprocessingView.cs @ 10947

Last change on this file since 10947 was 10934, checked in by mleitner, 10 years ago

Update correlationmatrix on preprocessing data change - improve performance on datagrid selection.

File size: 4.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 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;
23using System.Windows.Forms;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Core.Views;
27using HeuristicLab.MainForm;
28using HeuristicLab.DataPreprocessing;
29using HeuristicLab.Problems.DataAnalysis;
30
31namespace HeuristicLab.DataPreprocessing.Views {
32  [View("DataPreprocessing View")]
33  [Content(typeof(PreprocessingContext), true)]
34  [Content(typeof(IPreprocessingContext), false)]
35  public partial class DataPreprocessingView : ItemView {
36    public DataPreprocessingView() {
37      InitializeComponent();
38    }
39
40    public new IPreprocessingContext Content {
41      get { return (IPreprocessingContext)base.Content; }
42      set { base.Content = value; }
43    }
44
45    protected override void OnContentChanged() {
46      base.OnContentChanged();
47      if (Content != null) {
48        var data = Content.Data;
49        var searchLogic = new SearchLogic(data);
50        var dataGridLogic = new DataGridLogic(data);
51        var statisticsLogic = new StatisticsLogic(data, searchLogic);
52        var manipulationLogic = new ManipulationLogic(data, searchLogic, statisticsLogic, dataGridLogic);
53        var chartLogic = new ChartLogic(data);
54        //var correlationMatrixLogic = new ChartLogic(data);
55        var filterLogic = new FilterLogic(data);
56       
57        //var dataCompletenessLogic = new ChartLogic(data);
58
59        var viewShortcuts = new ItemList<IViewShortcut> {
60          new DataGridContent(dataGridLogic, manipulationLogic, filterLogic),
61          new StatisticsContent(statisticsLogic),
62
63          new LineChartContent(chartLogic),
64          new HistogramContent(chartLogic),
65          new ScatterPlotContent(chartLogic),
66          new CorrelationMatrixContent(Content),
67          new DataCompletenessChartContent(dataGridLogic, searchLogic),
68         
69          new FilterContent(filterLogic),
70          new ManipulationContent(manipulationLogic, searchLogic, dataGridLogic),
71          new TransformationContent(data)
72        };
73
74        viewShortcutListView.Content = viewShortcuts.AsReadOnly();
75
76        viewShortcutListView.ItemsListView.Items[0].Selected = true;
77        viewShortcutListView.Select();
78
79      } else {
80        viewShortcutListView.Content = null;
81      }
82    }
83
84    protected override void SetEnabledStateOfControls() {
85      base.SetEnabledStateOfControls();
86      viewShortcutListView.Enabled = Content != null;
87      applyInNewTabButton.Enabled = Content != null;
88      exportProblemButton.Enabled = Content != null;
89      undoButton.Enabled = Content != null;
90    }
91
92    private void exportProblemButton_Click(object sender, EventArgs e) {
93      var problem = Content.ExportProblem();
94
95      var saveFileDialog = new SaveFileDialog {
96        Title = "Save Item",
97        DefaultExt = "hl",
98        Filter = "Uncompressed HeuristicLab Files|*.hl|HeuristicLab Files|*.hl|All Files|*.*",
99        FilterIndex = 2
100      };
101
102      var content = problem as IStorableContent;
103      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
104        bool compressed = saveFileDialog.FilterIndex != 1;
105        ContentManager.Save(content, saveFileDialog.FileName, compressed);
106      }
107    }
108
109    private void applyInNewTabButton_Click(object sender, EventArgs e) {
110      var item = Content.ExportAlgorithmOrProblem();
111
112      MainFormManager.MainForm.ShowContent(item);
113    }
114
115    private void undoButton_Click(object sender, EventArgs e) {
116      Content.Data.Undo();
117    }
118  }
119}
Note: See TracBrowser for help on using the repository browser.