Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 16793 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
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        transformationListView.PreprocessingData = null;
46      } else {
47        transformationListView.Content = Content.TransformationList;
48        transformationListView.PreprocessingData = Content.PreprocessingData;
49        CheckFilters();
50      }
51    }
52
53    protected override void RegisterContentEvents() {
54      Content.PreprocessingData.FilterChanged += FilterLogic_FilterChanged;
55    }
56
57    protected override void DeregisterContentEvents() {
58      Content.PreprocessingData.FilterChanged -= FilterLogic_FilterChanged;
59    }
60
61    void FilterLogic_FilterChanged(object sender, EventArgs e) {
62      if (Content != null) {
63        CheckFilters();
64      }
65    }
66
67    private void CheckFilters() {
68      if (Content.PreprocessingData.IsFiltered) {
69        applyButton.Enabled = false;
70        lblFilterNotice.Visible = true;
71      } else {
72        applyButton.Enabled = true;
73        lblFilterNotice.Visible = false;
74      }
75    }
76
77    private void applyButton_Click(object sender, EventArgs e) {
78      bool success = Content.ApplyTransformations(out IEnumerable<string> errorMessages);
79
80      if (success) {
81        //Content.TransformationList.Clear();
82        MessageBox.Show(this, "Transformations applied.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
83      } else {
84        MessageBox.Show(this, string.Join(Environment.NewLine, errorMessages), "Transformation failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
85      }
86    }
87  }
88}
Note: See TracBrowser for help on using the repository browser.