Changeset 10905 for branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/ManipulationView.cs
- Timestamp:
- 05/28/14 14:37:39 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/ManipulationView.cs
r10811 r10905 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Drawing; 24 25 using System.Windows.Forms; … … 60 61 ()=>Content.ManipulationLogic.ShuffleWithRanges() 61 62 }; 63 64 } 65 66 protected override void OnContentChanged() { 67 base.OnContentChanged(); 68 if (Content != null) { 69 cmbVariableNames.Items.Clear(); 70 foreach (var name in Content.DataGridLogic.ColumnNames) { 71 cmbVariableNames.Items.Add(name); 72 } 73 cmbVariableNames.SelectedIndex = 0; 74 } 62 75 } 63 76 … … 85 98 86 99 private void replaceMissingValues() { 87 var cells = Content.SearchLogic.GetMissingValueIndices(); 88 switch (cmbReplaceWith.SelectedIndex) { 100 var allIndices = Content.SearchLogic.GetMissingValueIndices(); 101 var columnIndex = cmbVariableNames.SelectedIndex; 102 var columnIndices = new Dictionary<int, IList<int>>{ 103 {columnIndex, allIndices[columnIndex]} 104 }; 105 106 switch (cmbReplaceWith.SelectedIndex) { 89 107 case 0: //Value 90 Content.ManipulationLogic.ReplaceIndicesByValue(c ells, txtReplaceValue.Text);108 Content.ManipulationLogic.ReplaceIndicesByValue(columnIndices, txtReplaceValue.Text); 91 109 break; 92 110 case 1: //Average 93 Content.ManipulationLogic.ReplaceIndicesByAverageValue(c ells);111 Content.ManipulationLogic.ReplaceIndicesByAverageValue(columnIndices); 94 112 break; 95 113 case 2: //Median 96 Content.ManipulationLogic.ReplaceIndicesByMedianValue(c ells);114 Content.ManipulationLogic.ReplaceIndicesByMedianValue(columnIndices); 97 115 break; 98 116 case 3: //Most Common 99 Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(c ells);117 Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(columnIndices); 100 118 break; 101 119 case 4: //Random 102 Content.ManipulationLogic.ReplaceIndicesByRandomValue(c ells);120 Content.ManipulationLogic.ReplaceIndicesByRandomValue(columnIndices); 103 121 break; 104 122 } … … 152 170 private void validateReplaceWith() { 153 171 btnApply.Enabled = false; 154 string replaceValue = cmbReplaceWith.SelectedText; 172 string replaceWith = (string)cmbReplaceWith.SelectedItem; 173 int columnIndex = cmbVariableNames.SelectedIndex; 174 155 175 if (cmbReplaceWith.SelectedIndex == 0) { 156 btnApply.Enabled = !string.IsNullOrEmpty(txtReplaceValue.Text); 157 replaceValue = @"\"+ txtReplaceValue.Text + @"\"; 176 string errorMessage; 177 string replaceValue = txtReplaceValue.Text; 178 if (string.IsNullOrEmpty(replaceValue)) { 179 lblPreviewReplaceMissingValues.Text = "Preview not possible yet - please input the text which will be used as replacement."; 180 } else if (!Content.DataGridLogic.Validate(txtReplaceValue.Text, out errorMessage, columnIndex)) { 181 lblPreviewReplaceMissingValues.Text = "Preview not possible yet - " + errorMessage; 182 } else { 183 btnApply.Enabled = true; 184 } 185 replaceWith = "\"" + replaceValue + "\""; 158 186 } else { 159 187 btnApply.Enabled = true; 160 188 } 161 189 if (btnApply.Enabled) { 162 int count = Content.SearchLogic.GetMissingValueIndices().Count; 163 lblPreviewReplaceMissingValues.Text = count + " cell" + (count > 1 || count == 0 ? "s" : "") 164 + " were detected with missing values which would be replaced with " + replaceValue; 190 var allIndices = Content.SearchLogic.GetMissingValueIndices(); 191 int count = allIndices[columnIndex].Count; 192 lblPreviewReplaceMissingValues.Text = count + " cell" + (count > 1 || count == 0 ? "s" : "") 193 + " were detected with missing values which would be replaced with " + replaceWith; 165 194 if (count > 0) { 166 195 lblPreviewReplaceMissingValues.Text += Environment.NewLine + Environment.NewLine + "Please press the button \"Apply Manipulation\" if you wish to perform the replacement."; … … 168 197 btnApply.Enabled = false; 169 198 } 170 } else {171 lblPreviewReplaceMissingValues.Text = "Preview not possible yet - please input the text which will be used as replacement.";172 199 } 173 200 } … … 203 230 break; 204 231 case 3: 232 lblPreviewReplaceMissingValues.Text = "missing values successfully replaced."; 233 btnApply.Enabled = false; 234 break; 235 case 4: 205 236 lblPreviewShuffle.Text = "dataset shuffled successfully."; 206 237 btnApply.Enabled = false; … … 232 263 233 264 void Content_Changed(object sender, DataPreprocessingChangedEventArgs e) { 234 switch (lstMethods.SelectedIndex){265 switch (lstMethods.SelectedIndex) { 235 266 case 0: 236 267 validateDeleteColumnsInfo();
Note: See TracChangeset
for help on using the changeset viewer.