Changeset 10737 for branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/ManipulationView.cs
- Timestamp:
- 04/09/14 13:08:49 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/ManipulationView.cs
r10712 r10737 45 45 46 46 validators = new Action[] { 47 ()=>validateD oubleTextBox(txtDeleteColumnsInfo.Text),48 ()=>validateD oubleTextBox(txtDeleteColumnsVariance.Text),49 ()=>validateD oubleTextBox(txtDeleteRowsInfo.Text),50 ()=>{btnApply.Enabled = true; } //shuffle47 ()=>validateDeleteColumnsInfo(), 48 ()=>validateDeleteColumnsVariance(), 49 ()=>validateDeleteRowsInfo(), 50 ()=>{btnApply.Enabled = true; lblPreviewShuffle.Text = "Data will be shuffled randomly - preview not possible";} //shuffle 51 51 }; 52 52 53 manipulations = new Action[] { 53 ()=> {},54 ()=> {},55 ()=> {},54 ()=>Content.ManipulationLogic.DeleteColumnsWithMissingValuesGreater(getDeleteColumnsInfo()), 55 ()=>Content.ManipulationLogic.DeleteColumnsWithVarianceSmaller(getDeleteColumnsVariance()), 56 ()=>Content.ManipulationLogic.DeleteRowsWithMissingValuesGreater(getRowsColumnsInfo()), 56 57 ()=>Content.ManipulationLogic.ShuffleWithRanges() 57 58 }; 59 } 60 61 protected override void RegisterContentEvents() { 62 base.RegisterContentEvents(); 63 Content.ManipulationLogic.Changed += Content_Changed; 64 } 65 66 protected override void DeregisterContentEvents() { 67 base.DeregisterContentEvents(); 68 Content.ManipulationLogic.Changed -= Content_Changed; 69 } 70 71 private double getDeleteColumnsInfo() { 72 return double.Parse(txtDeleteColumnsInfo.Text); 73 } 74 75 private double getDeleteColumnsVariance() { 76 return double.Parse(txtDeleteColumnsVariance.Text); 77 } 78 79 private double getRowsColumnsInfo() { 80 return double.Parse(txtDeleteRowsInfo.Text); 81 } 82 83 private void validateDeleteColumnsInfo() { 84 validateDoubleTextBox(txtDeleteColumnsInfo.Text); 85 if (btnApply.Enabled) { 86 int count = Content.ManipulationLogic.ColumnsWithMissingValuesGreater(getDeleteColumnsInfo()).Count; 87 lblPreviewColumnsInfo.Text = count + " column" + (count > 1 || count == 0 ? "s" : "") + " were detected with more than " + txtDeleteColumnsInfo.Text + "% missing values."; 88 if (count > 0) { 89 lblPreviewColumnsInfo.Text += Environment.NewLine + Environment.NewLine + "Please press the button \"Apply Manipulation\" if you wish to delete those columns."; 90 } else { 91 btnApply.Enabled = false; 92 } 93 } else { 94 lblPreviewColumnsInfo.Text = "Preview not possible yet - please input the limit above."; 95 } 96 } 97 98 private void validateDeleteColumnsVariance() { 99 validateDoubleTextBox(txtDeleteColumnsVariance.Text); 100 if (btnApply.Enabled) { 101 int count = Content.ManipulationLogic.ColumnsWithVarianceSmaller(getDeleteColumnsVariance()).Count; 102 lblPreviewColumnsVariance.Text = count + " column" + (count > 1 || count == 0 ? "s" : "") + " were detected with a variance smaller than " + txtDeleteColumnsVariance.Text + "."; 103 if (count > 0) { 104 lblPreviewColumnsVariance.Text += Environment.NewLine + Environment.NewLine + "Please press the button \"Apply Manipulation\" if you wish to delete those columns."; 105 } else { 106 btnApply.Enabled = false; 107 } 108 } else { 109 lblPreviewColumnsVariance.Text = "Preview not possible yet - please input the limit for the variance above."; 110 } 111 } 112 113 private void validateDeleteRowsInfo() { 114 validateDoubleTextBox(txtDeleteRowsInfo.Text); 115 if (btnApply.Enabled) { 116 int count = Content.ManipulationLogic.RowsWithMissingValuesGreater(getRowsColumnsInfo()).Count; 117 lblPreviewRowsInfo.Text = count + " row" + (count > 1 || count == 0 ? "s" : "") + " were detected with more than " + txtDeleteRowsInfo.Text + "% missing values."; 118 if (count > 0) { 119 lblPreviewRowsInfo.Text += Environment.NewLine + Environment.NewLine + "Please press the button \"Apply Manipulation\" if you wish to delete those rows."; 120 } else { 121 btnApply.Enabled = false; 122 } 123 } else { 124 lblPreviewRowsInfo.Text = "Preview not possible yet - please input the limit above."; 125 } 58 126 } 59 127 … … 70 138 btnApply.Enabled = false; 71 139 72 //in order that button will be enabled if text is already valid140 //in order that button is enabled if necessary input was already entered 73 141 if (index >= 0) { 74 142 validators[index](); … … 78 146 private void btnApply_Click(object sender, System.EventArgs e) { 79 147 manipulations[lstMethods.SelectedIndex](); 148 switch (lstMethods.SelectedIndex) { 149 case 0: 150 lblPreviewColumnsInfo.Text = "columns successfully deleted."; 151 break; 152 case 1: 153 lblPreviewColumnsVariance.Text = "columns successfully deleted."; 154 break; 155 case 2: 156 lblPreviewRowsInfo.Text = "rows successfully deleted."; 157 break; 158 case 3: 159 lblPreviewShuffle.Text = "dataset shuffled successfully."; 160 btnApply.Enabled = false; 161 break; 162 } 80 163 } 81 164 … … 91 174 92 175 private void txtDeleteColumnsInfo_TextChanged(object sender, EventArgs e) { 93 validateD oubleTextBox(txtDeleteColumnsInfo.Text);176 validateDeleteColumnsInfo(); 94 177 } 95 178 96 179 private void txtDeleteColumnsVariance_TextChanged(object sender, EventArgs e) { 97 validateD oubleTextBox(txtDeleteColumnsVariance.Text);180 validateDeleteColumnsVariance(); 98 181 } 99 182 100 183 private void txtDeleteRowsInfo_TextChanged(object sender, EventArgs e) { 101 validateDoubleTextBox(txtDeleteRowsInfo.Text); 184 validateDeleteRowsInfo(); 185 } 186 187 void Content_Changed(object sender, DataPreprocessingChangedEventArgs e) { 188 switch(lstMethods.SelectedIndex){ 189 case 0: 190 validateDeleteColumnsInfo(); 191 break; 192 case 1: 193 validateDeleteColumnsVariance(); 194 break; 195 case 2: 196 validateDeleteRowsInfo(); 197 break; 198 } 102 199 } 103 200 }
Note: See TracChangeset
for help on using the changeset viewer.