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

Last change on this file since 15856 was 15856, checked in by pfleck, 3 years ago

#2906 Implemented transformation re-apply of an already reverse-transformed model.

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