[10539] | 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 |
|
---|
| 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 {
|
---|
| 34 | public DataPreprocessingView() {
|
---|
| 35 | InitializeComponent();
|
---|
[10258] | 36 | }
|
---|
[10239] | 37 |
|
---|
[10614] | 38 | public new IPreprocessingContext Content {
|
---|
| 39 | get { return (IPreprocessingContext)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;
|
---|
| 47 | var searchLogic = new SearchLogic(data);
|
---|
| 48 | var dataGridLogic = new DataGridLogic(data);
|
---|
| 49 | var statisticsLogic = new StatisticsLogic(data, searchLogic);
|
---|
[10672] | 50 | var manipulationLogic = new ManipulationLogic(data, searchLogic, statisticsLogic, dataGridLogic);
|
---|
[10617] | 51 | var transformationLogic = new TransformationLogic(data, searchLogic, statisticsLogic);
|
---|
[10658] | 52 | var lineChartLogic = new ChartLogic(data);
|
---|
| 53 | var histogramLogic = new ChartLogic(data);
|
---|
[10620] | 54 | var filterLogic = new FilterLogic(data);
|
---|
[10617] | 55 |
|
---|
[10625] | 56 | var viewShortcuts = new ItemCollection<IViewShortcut>() {
|
---|
[10636] | 57 | new DataGridContent(dataGridLogic, manipulationLogic, filterLogic),
|
---|
[10617] | 58 | new StatisticsContent(statisticsLogic),
|
---|
| 59 | new FilterContent(filterLogic),
|
---|
| 60 | new TransformationContent(transformationLogic),
|
---|
| 61 | new LineChartContent(lineChartLogic),
|
---|
| 62 | new HistogramContent(histogramLogic)
|
---|
| 63 | };
|
---|
[10625] | 64 |
|
---|
| 65 | viewShortcutCollectionView.Content = viewShortcuts.AsReadOnly();
|
---|
[10614] | 66 | } else {
|
---|
| 67 | viewShortcutCollectionView.Content = null;
|
---|
[10254] | 68 | }
|
---|
[10239] | 69 | }
|
---|
| 70 |
|
---|
[10614] | 71 | protected override void SetEnabledStateOfControls() {
|
---|
| 72 | base.SetEnabledStateOfControls();
|
---|
| 73 | viewShortcutCollectionView.Enabled = Content != null;
|
---|
| 74 | applyInNewTabButton.Enabled = Content != null;
|
---|
| 75 | exportProblemButton.Enabled = Content != null;
|
---|
| 76 | undoButton.Enabled = Content != null;
|
---|
[10239] | 77 | }
|
---|
| 78 |
|
---|
[10304] | 79 | private void exportProblemButton_Click(object sender, EventArgs e) {
|
---|
[10383] | 80 | var problem = Content.ExportProblem();
|
---|
[10310] | 81 |
|
---|
[10307] | 82 | var saveFileDialog = new SaveFileDialog {
|
---|
| 83 | Title = "Save Item",
|
---|
| 84 | DefaultExt = "hl",
|
---|
| 85 | Filter = "Uncompressed HeuristicLab Files|*.hl|HeuristicLab Files|*.hl|All Files|*.*",
|
---|
| 86 | FilterIndex = 2
|
---|
| 87 | };
|
---|
| 88 |
|
---|
[10383] | 89 | var content = problem as IStorableContent;
|
---|
[10307] | 90 | if (saveFileDialog.ShowDialog() == DialogResult.OK) {
|
---|
| 91 | bool compressed = saveFileDialog.FilterIndex != 1;
|
---|
| 92 | ContentManager.Save(content, saveFileDialog.FileName, compressed);
|
---|
| 93 | }
|
---|
[10304] | 94 | }
|
---|
| 95 |
|
---|
| 96 | private void applyInNewTabButton_Click(object sender, EventArgs e) {
|
---|
[10383] | 97 | var item = Content.ExportAlgorithmOrProblem();
|
---|
[10239] | 98 |
|
---|
[10254] | 99 | MainFormManager.MainForm.ShowContent(item);
|
---|
| 100 | }
|
---|
[10550] | 101 |
|
---|
| 102 | private void undoButton_Click(object sender, EventArgs e) {
|
---|
| 103 | Content.Data.Undo();
|
---|
| 104 | }
|
---|
[10239] | 105 | }
|
---|
[10310] | 106 | } |
---|