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;
|
---|
23 | using System.Drawing;
|
---|
24 | using System.Windows.Forms;
|
---|
25 | using HeuristicLab.Core.Views;
|
---|
26 | using HeuristicLab.MainForm;
|
---|
27 |
|
---|
28 | namespace HeuristicLab.DataPreprocessing.Views {
|
---|
29 |
|
---|
30 | [View("Manipulation Chart View")]
|
---|
31 | [Content(typeof(ManipulationContent), false)]
|
---|
32 | public partial class ManipulationView : ItemView {
|
---|
33 |
|
---|
34 | private Action[] validators;
|
---|
35 | private Action[] manipulations;
|
---|
36 |
|
---|
37 | public ManipulationView() {
|
---|
38 | InitializeComponent();
|
---|
39 | tabsData.Appearance = TabAppearance.FlatButtons;
|
---|
40 | tabsData.ItemSize = new Size(0, 1);
|
---|
41 | tabsData.SizeMode = TabSizeMode.Fixed;
|
---|
42 | tabsPreview.Appearance = TabAppearance.FlatButtons;
|
---|
43 | tabsPreview.ItemSize = new Size(0, 1);
|
---|
44 | tabsPreview.SizeMode = TabSizeMode.Fixed;
|
---|
45 |
|
---|
46 | validators = new Action[] {
|
---|
47 | ()=>validateDoubleTextBox(txtDeleteColumnsInfo.Text),
|
---|
48 | ()=>validateDoubleTextBox(txtDeleteColumnsVariance.Text),
|
---|
49 | ()=>validateDoubleTextBox(txtDeleteRowsInfo.Text),
|
---|
50 | ()=>{btnApply.Enabled = true;} //shuffle
|
---|
51 | };
|
---|
52 | manipulations = new Action[] {
|
---|
53 | ()=>{},
|
---|
54 | ()=>{},
|
---|
55 | ()=>{},
|
---|
56 | ()=>Content.ManipulationLogic.ShuffleWithRanges()
|
---|
57 | };
|
---|
58 | }
|
---|
59 |
|
---|
60 | public new ManipulationContent Content {
|
---|
61 | get { return (ManipulationContent)base.Content; }
|
---|
62 | set { base.Content = value; }
|
---|
63 | }
|
---|
64 |
|
---|
65 | private void lstMethods_SelectedIndexChanged(object sender, System.EventArgs e) {
|
---|
66 |
|
---|
67 | int index = lstMethods.SelectedIndex;
|
---|
68 | tabsData.SelectedIndex = index + 1;
|
---|
69 | tabsPreview.SelectedIndex = index + 1;
|
---|
70 | btnApply.Enabled = false;
|
---|
71 |
|
---|
72 | //in order that button will be enabled if text is already valid
|
---|
73 | if (index >= 0) {
|
---|
74 | validators[index]();
|
---|
75 | }
|
---|
76 | }
|
---|
77 |
|
---|
78 | private void btnApply_Click(object sender, System.EventArgs e) {
|
---|
79 | manipulations[lstMethods.SelectedIndex]();
|
---|
80 | }
|
---|
81 |
|
---|
82 | private void validateDoubleTextBox(String text) {
|
---|
83 | btnApply.Enabled = false;
|
---|
84 | if (!string.IsNullOrEmpty(text)) {
|
---|
85 | double percent;
|
---|
86 | if (Double.TryParse(text, out percent)) {
|
---|
87 | btnApply.Enabled = true;
|
---|
88 | }
|
---|
89 | }
|
---|
90 | }
|
---|
91 |
|
---|
92 | private void txtDeleteColumnsInfo_TextChanged(object sender, EventArgs e) {
|
---|
93 | validateDoubleTextBox(txtDeleteColumnsInfo.Text);
|
---|
94 | }
|
---|
95 |
|
---|
96 | private void txtDeleteColumnsVariance_TextChanged(object sender, EventArgs e) {
|
---|
97 | validateDoubleTextBox(txtDeleteColumnsVariance.Text);
|
---|
98 | }
|
---|
99 |
|
---|
100 | private void txtDeleteRowsInfo_TextChanged(object sender, EventArgs e) {
|
---|
101 | validateDoubleTextBox(txtDeleteRowsInfo.Text);
|
---|
102 | }
|
---|
103 | }
|
---|
104 | }
|
---|