[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 |
|
---|
| 22 | using System;
|
---|
[10239] | 23 | using System.Windows.Forms;
|
---|
| 24 | using HeuristicLab.Common;
|
---|
[10625] | 25 | using HeuristicLab.Core;
|
---|
[10254] | 26 | using HeuristicLab.Core.Views;
|
---|
| 27 | using HeuristicLab.MainForm;
|
---|
[10239] | 28 |
|
---|
[10558] | 29 | namespace HeuristicLab.DataPreprocessing.Views {
|
---|
[10239] | 30 | [View("DataPreprocessing View")]
|
---|
[10614] | 31 | [Content(typeof(PreprocessingContext), true)]
|
---|
| 32 | [Content(typeof(IPreprocessingContext), false)]
|
---|
[10239] | 33 | public partial class DataPreprocessingView : ItemView {
|
---|
[10998] | 34 |
|
---|
[10239] | 35 | public DataPreprocessingView() {
|
---|
| 36 | InitializeComponent();
|
---|
[10258] | 37 | }
|
---|
[10239] | 38 |
|
---|
[10614] | 39 | public new IPreprocessingContext Content {
|
---|
| 40 | get { return (IPreprocessingContext)base.Content; }
|
---|
[10617] | 41 | set { base.Content = value; }
|
---|
[10239] | 42 | }
|
---|
| 43 |
|
---|
[10614] | 44 | protected override void OnContentChanged() {
|
---|
| 45 | base.OnContentChanged();
|
---|
| 46 | if (Content != null) {
|
---|
[10617] | 47 | var data = Content.Data;
|
---|
| 48 | var searchLogic = new SearchLogic(data);
|
---|
| 49 | var statisticsLogic = new StatisticsLogic(data, searchLogic);
|
---|
[11002] | 50 | var manipulationLogic = new ManipulationLogic(data, searchLogic, statisticsLogic);
|
---|
[10620] | 51 | var filterLogic = new FilterLogic(data);
|
---|
[10970] | 52 |
|
---|
[10904] | 53 | var viewShortcuts = new ItemList<IViewShortcut> {
|
---|
[11002] | 54 | new DataGridContent(data, manipulationLogic, filterLogic),
|
---|
[10617] | 55 | new StatisticsContent(statisticsLogic),
|
---|
[10921] | 56 |
|
---|
[10992] | 57 | new LineChartContent(data),
|
---|
| 58 | new HistogramContent(data),
|
---|
| 59 | new ScatterPlotContent(data),
|
---|
[10934] | 60 | new CorrelationMatrixContent(Content),
|
---|
[11002] | 61 | new DataCompletenessChartContent(searchLogic),
|
---|
[10921] | 62 |
|
---|
| 63 | new FilterContent(filterLogic),
|
---|
[11002] | 64 | new ManipulationContent(manipulationLogic, searchLogic, filterLogic),
|
---|
[10977] | 65 | new TransformationContent(data, filterLogic)
|
---|
[10617] | 66 | };
|
---|
[10625] | 67 |
|
---|
[10904] | 68 | viewShortcutListView.Content = viewShortcuts.AsReadOnly();
|
---|
[10735] | 69 |
|
---|
[10904] | 70 | viewShortcutListView.ItemsListView.Items[0].Selected = true;
|
---|
| 71 | viewShortcutListView.Select();
|
---|
[10735] | 72 |
|
---|
[10614] | 73 | } else {
|
---|
[10904] | 74 | viewShortcutListView.Content = null;
|
---|
[10254] | 75 | }
|
---|
[10239] | 76 | }
|
---|
| 77 |
|
---|
[10969] | 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 |
|
---|
[10614] | 92 | protected override void SetEnabledStateOfControls() {
|
---|
| 93 | base.SetEnabledStateOfControls();
|
---|
[10904] | 94 | viewShortcutListView.Enabled = Content != null;
|
---|
[10614] | 95 | applyInNewTabButton.Enabled = Content != null;
|
---|
[10990] | 96 | exportProblemButton.Enabled = Content != null && Content.Problem != null;
|
---|
[10614] | 97 | undoButton.Enabled = Content != null;
|
---|
[10239] | 98 | }
|
---|
| 99 |
|
---|
[10304] | 100 | private void exportProblemButton_Click(object sender, EventArgs e) {
|
---|
[10383] | 101 | var problem = Content.ExportProblem();
|
---|
[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 | } |
---|