Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataPreprocessingView.cs @ 10620

Last change on this file since 10620 was 10620, checked in by mleitner, 11 years ago

Fix filterlogic

File size: 3.8 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.Views;
26using HeuristicLab.MainForm;
27
28namespace HeuristicLab.DataPreprocessing.Views {
29  [View("DataPreprocessing View")]
30  [Content(typeof(PreprocessingContext), true)]
31  [Content(typeof(IPreprocessingContext), false)]
32  public partial class DataPreprocessingView : ItemView {
33    public DataPreprocessingView() {
34      InitializeComponent();
35    }
36
37    public new IPreprocessingContext Content {
38      get { return (IPreprocessingContext)base.Content; }
39      set { base.Content = value; }
40    }
41
42    protected override void OnContentChanged() {
43      base.OnContentChanged();
44      if (Content != null) {
45        var data = Content.Data;
46        var searchLogic = new SearchLogic(data);
47        var dataGridLogic = new DataGridLogic(data);
48        var statisticsLogic = new StatisticsLogic(data, searchLogic);
49        var manipulationLogic = new ManipulationLogic(data, searchLogic, statisticsLogic);
50        var transformationLogic = new TransformationLogic(data, searchLogic, statisticsLogic);
51        var lineChartLogic = new LineChartLogic(data);
52        var histogramLogic = new HistogramLogic(data);
53        var filterLogic = new FilterLogic(data);
54
55        viewShortcutCollectionView.Content = new ViewShortcutCollection {
56          new DataGridContent(dataGridLogic, manipulationLogic),
57          new StatisticsContent(statisticsLogic),
58          new FilterContent(filterLogic),
59          new TransformationContent(transformationLogic),
60          new LineChartContent(lineChartLogic),
61          new HistogramContent(histogramLogic)
62        };
63      } else {
64        viewShortcutCollectionView.Content = null;
65      }
66    }
67
68    protected override void SetEnabledStateOfControls() {
69      base.SetEnabledStateOfControls();
70      viewShortcutCollectionView.Enabled = Content != null;
71      applyInNewTabButton.Enabled = Content != null;
72      exportProblemButton.Enabled = Content != null;
73      undoButton.Enabled = Content != null;
74    }
75
76    private void exportProblemButton_Click(object sender, EventArgs e) {
77      var problem = Content.ExportProblem();
78
79      var saveFileDialog = new SaveFileDialog {
80        Title = "Save Item",
81        DefaultExt = "hl",
82        Filter = "Uncompressed HeuristicLab Files|*.hl|HeuristicLab Files|*.hl|All Files|*.*",
83        FilterIndex = 2
84      };
85
86      var content = problem as IStorableContent;
87      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
88        bool compressed = saveFileDialog.FilterIndex != 1;
89        ContentManager.Save(content, saveFileDialog.FileName, compressed);
90      }
91    }
92
93    private void applyInNewTabButton_Click(object sender, EventArgs e) {
94      var item = Content.ExportAlgorithmOrProblem();
95
96      MainFormManager.MainForm.ShowContent(item);
97    }
98
99    private void undoButton_Click(object sender, EventArgs e) {
100      Content.Data.Undo();
101    }
102  }
103}
Note: See TracBrowser for help on using the repository browser.