Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/DataPreprocessingView.cs @ 13502

Last change on this file since 13502 was 13502, checked in by pfleck, 8 years ago

#2559

  • Adapted import and export for preprocessing.
  • Added MenuItem to be able to open Preprocessing without creating a DataAnalysisProblem before.
  • Added coloring in ScatterPlot.
  • Removed IPreprocessingContext interface.
  • Reformatted code:
    • Added missing copyright headers.
    • Corrected namespaces.
    • Deleted unnecessary usings.
    • Applied correct formatting.
File size: 4.4 KB
RevLine 
[10539]1#region License Information
2/* HeuristicLab
[12012]3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[10539]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;
[10239]23using System.Windows.Forms;
24using HeuristicLab.Common;
[10625]25using HeuristicLab.Core;
[10254]26using HeuristicLab.Core.Views;
27using HeuristicLab.MainForm;
[10239]28
[10558]29namespace HeuristicLab.DataPreprocessing.Views {
[10239]30  [View("DataPreprocessing View")]
[10614]31  [Content(typeof(PreprocessingContext), true)]
[10239]32  public partial class DataPreprocessingView : ItemView {
[10998]33
[10239]34    public DataPreprocessingView() {
35      InitializeComponent();
[10258]36    }
[10239]37
[13502]38    public new PreprocessingContext Content {
39      get { return (PreprocessingContext)base.Content; }
[10617]40      set { base.Content = value; }
[10239]41    }
42
[10614]43    protected override void OnContentChanged() {
44      base.OnContentChanged();
45      if (Content != null) {
[10617]46        var data = Content.Data;
[12676]47        var filterLogic = new FilterLogic(data);
48        var searchLogic = new SearchLogic(data, filterLogic);
[10617]49        var statisticsLogic = new StatisticsLogic(data, searchLogic);
[11002]50        var manipulationLogic = new ManipulationLogic(data, searchLogic, statisticsLogic);
[10970]51
[10904]52        var viewShortcuts = new ItemList<IViewShortcut> {
[11002]53          new DataGridContent(data, manipulationLogic, filterLogic),
[10617]54          new StatisticsContent(statisticsLogic),
[10921]55
[10992]56          new LineChartContent(data),
57          new HistogramContent(data),
58          new ScatterPlotContent(data),
[10934]59          new CorrelationMatrixContent(Content),
[11002]60          new DataCompletenessChartContent(searchLogic),
[13502]61
[10921]62          new FilterContent(filterLogic),
[11002]63          new ManipulationContent(manipulationLogic, searchLogic, filterLogic),
[10977]64          new TransformationContent(data, filterLogic)
[10617]65        };
[10625]66
[10904]67        viewShortcutListView.Content = viewShortcuts.AsReadOnly();
[10735]68
[10904]69        viewShortcutListView.ItemsListView.Items[0].Selected = true;
70        viewShortcutListView.Select();
[10735]71
[10614]72      } else {
[10904]73        viewShortcutListView.Content = null;
[10254]74      }
[10239]75    }
76
[10969]77    protected override void RegisterContentEvents() {
78      base.RegisterContentEvents();
79      Content.Data.FilterChanged += Data_FilterChanged;
80    }
81
82    protected override void DeregisterContentEvents() {
83      base.DeregisterContentEvents();
84      Content.Data.FilterChanged -= Data_FilterChanged;
85    }
86
87    void Data_FilterChanged(object sender, EventArgs e) {
88      lblFilterActive.Visible = Content.Data.IsFiltered;
89    }
90
[10614]91    protected override void SetEnabledStateOfControls() {
92      base.SetEnabledStateOfControls();
[10904]93      viewShortcutListView.Enabled = Content != null;
[10614]94      applyInNewTabButton.Enabled = Content != null;
[13502]95      exportProblemButton.Enabled = Content != null && Content.CanExport;
[10614]96      undoButton.Enabled = Content != null;
[10239]97    }
98
[10304]99    private void exportProblemButton_Click(object sender, EventArgs e) {
[13502]100      // ToDo: select one export probability
101      var problem = Content.Export();
[10310]102
[10307]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
[10383]110      var content = problem as IStorableContent;
[10307]111      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
112        bool compressed = saveFileDialog.FilterIndex != 1;
113        ContentManager.Save(content, saveFileDialog.FileName, compressed);
114      }
[10304]115    }
116
117    private void applyInNewTabButton_Click(object sender, EventArgs e) {
[10990]118      var item = Content.Export();
[10239]119
[10254]120      MainFormManager.MainForm.ShowContent(item);
121    }
[10550]122
123    private void undoButton_Click(object sender, EventArgs e) {
124      Content.Data.Undo();
125    }
[10239]126  }
[10310]127}
Note: See TracBrowser for help on using the repository browser.