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