#region License Information /* HeuristicLab * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Windows.Forms; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Core.Views; using HeuristicLab.MainForm; namespace HeuristicLab.DataPreprocessing.Views { [View("DataPreprocessing View")] [Content(typeof(PreprocessingContext), true)] [Content(typeof(IPreprocessingContext), false)] public partial class DataPreprocessingView : ItemView { public DataPreprocessingView() { InitializeComponent(); } public new IPreprocessingContext Content { get { return (IPreprocessingContext)base.Content; } set { base.Content = value; } } protected override void OnContentChanged() { base.OnContentChanged(); if (Content != null) { var data = Content.Data; var searchLogic = new SearchLogic(data); var dataGridLogic = new DataGridLogic(data); var statisticsLogic = new StatisticsLogic(data, searchLogic); var manipulationLogic = new ManipulationLogic(data, searchLogic, statisticsLogic, dataGridLogic); var transformationLogic = new TransformationLogic(data, searchLogic, statisticsLogic); var lineChartLogic = new ChartLogic(data); var histogramLogic = new ChartLogic(data); var filterLogic = new FilterLogic(data); var viewShortcuts = new ItemCollection() { new DataGridContent(dataGridLogic, manipulationLogic, filterLogic), new StatisticsContent(statisticsLogic), new FilterContent(filterLogic), new TransformationContent(transformationLogic), new ManipulationContent(manipulationLogic), new LineChartContent(lineChartLogic), new HistogramContent(histogramLogic) }; viewShortcutCollectionView.Content = viewShortcuts.AsReadOnly(); viewShortcutCollectionView.ItemsListView.Items[0].Selected = true; viewShortcutCollectionView.Select(); } else { viewShortcutCollectionView.Content = null; } } protected override void SetEnabledStateOfControls() { base.SetEnabledStateOfControls(); viewShortcutCollectionView.Enabled = Content != null; applyInNewTabButton.Enabled = Content != null; exportProblemButton.Enabled = Content != null; undoButton.Enabled = Content != null; } private void exportProblemButton_Click(object sender, EventArgs e) { var problem = Content.ExportProblem(); var saveFileDialog = new SaveFileDialog { Title = "Save Item", DefaultExt = "hl", Filter = "Uncompressed HeuristicLab Files|*.hl|HeuristicLab Files|*.hl|All Files|*.*", FilterIndex = 2 }; var content = problem as IStorableContent; if (saveFileDialog.ShowDialog() == DialogResult.OK) { bool compressed = saveFileDialog.FilterIndex != 1; ContentManager.Save(content, saveFileDialog.FileName, compressed); } } private void applyInNewTabButton_Click(object sender, EventArgs e) { var item = Content.ExportAlgorithmOrProblem(); MainFormManager.MainForm.ShowContent(item); } private void undoButton_Click(object sender, EventArgs e) { Content.Data.Undo(); } } }