Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/TransformationView.cs @ 17988

Last change on this file since 17988 was 15865, checked in by pfleck, 7 years ago

#2906 Added PreprocessingTransformation as a custom view-model for transformations in preprocessing.

File size: 3.0 KB
RevLine 
[10539]1#region License Information
2/* HeuristicLab
[15583]3 * Copyright (C) 2002-2018 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
[10786]22using System;
[15846]23using System.Collections.Generic;
[10814]24using System.Windows.Forms;
[10303]25using HeuristicLab.MainForm;
[10712]26using HeuristicLab.MainForm.WindowsForms;
[10303]27
28namespace HeuristicLab.DataPreprocessing.Views {
29  [View("Transformation View")]
[10712]30  [Content(typeof(TransformationContent), true)]
31  public partial class TransformationView : AsynchronousContentView {
[11068]32    public new TransformationContent Content {
[10998]33      get { return (TransformationContent)base.Content; }
34      set { base.Content = value; }
35    }
36
[10303]37    public TransformationView() {
38      InitializeComponent();
39    }
40
[10772]41    protected override void OnContentChanged() {
42      base.OnContentChanged();
43      if (Content == null) {
[10902]44        transformationListView.Content = null;
[15865]45        transformationListView.PreprocessingData = null;
[10772]46      } else {
[15865]47        transformationListView.Content = Content.TransformationList;
[15846]48        transformationListView.PreprocessingData = Content.PreprocessingData;
[10977]49        CheckFilters();
[10772]50      }
51    }
[10786]52
[10977]53    protected override void RegisterContentEvents() {
[15518]54      Content.PreprocessingData.FilterChanged += FilterLogic_FilterChanged;
[10977]55    }
56
57    protected override void DeregisterContentEvents() {
[15518]58      Content.PreprocessingData.FilterChanged -= FilterLogic_FilterChanged;
[10977]59    }
60
61    void FilterLogic_FilterChanged(object sender, EventArgs e) {
62      if (Content != null) {
63        CheckFilters();
64      }
65    }
66
67    private void CheckFilters() {
[15518]68      if (Content.PreprocessingData.IsFiltered) {
[10977]69        applyButton.Enabled = false;
70        lblFilterNotice.Visible = true;
71      } else {
72        applyButton.Enabled = true;
73        lblFilterNotice.Visible = false;
74      }
75    }
76
[10786]77    private void applyButton_Click(object sender, EventArgs e) {
[15846]78      bool success = Content.ApplyTransformations(out IEnumerable<string> errorMessages);
[10786]79
80      if (success) {
[15865]81        //Content.TransformationList.Clear();
[10814]82        MessageBox.Show(this, "Transformations applied.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
[10819]83      } else {
[15846]84        MessageBox.Show(this, string.Join(Environment.NewLine, errorMessages), "Transformation failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
[10786]85      }
86    }
[10303]87  }
88}
Note: See TracBrowser for help on using the repository browser.