- Timestamp:
- 02/11/09 13:39:30 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/CEDMA-Refactoring-Ticket419/HeuristicLab.GP.StructureIdentification/StructIdProblemInjectorView.cs
r656 r1215 63 63 protected override void UpdateControls() { 64 64 base.UpdateControls(); 65 if (StructIdProblemInjector == null) {65 if (StructIdProblemInjector == null) { 66 66 importInstanceButton.Enabled = false; 67 67 } else { … … 73 73 74 74 private void importInstanceButton_Click(object sender, EventArgs e) { 75 if (openFileDialog.ShowDialog(this) == DialogResult.OK) {75 if (openFileDialog.ShowDialog(this) == DialogResult.OK) { 76 76 DatasetParser parser = new DatasetParser(); 77 77 bool success = false; … … 80 80 parser.Import(openFileDialog.FileName, true); 81 81 success = true; 82 } catch(DataFormatException ex) { 82 } 83 catch (DataFormatException ex) { 83 84 ShowWarningMessageBox(ex); 84 85 // not possible to parse strictly => clear and try to parse non-strict … … 87 88 success = true; 88 89 } 89 } catch(DataFormatException ex) { 90 } 91 catch (DataFormatException ex) { 90 92 // if the non-strict parsing also failed then show the exception 91 93 ShowErrorMessageBox(ex); 92 94 } 93 if (success) {95 if (success) { 94 96 Dataset dataset = (Dataset)StructIdProblemInjector.GetVariable("Dataset").Value; 95 97 dataset.Rows = parser.Rows; 96 98 dataset.Columns = parser.Columns; 97 dataset.VariableNames = parser.VariableNames; 99 for (int i = 0; i < parser.VariableNames.Length; i++) { 100 dataset.SetVariableName(i, parser.VariableNames[i]); 101 } 98 102 dataset.Name = parser.ProblemName; 99 103 dataset.Samples = new double[dataset.Rows * dataset.Columns]; … … 109 113 110 114 IVariable var = StructIdProblemInjector.GetVariable("AllowedFeatures"); 111 if (var != null) {115 if (var != null) { 112 116 ItemList<IntData> allowedFeatures = (ItemList<IntData>)var.Value; 113 117 allowedFeatures.Clear(); 114 118 List<int> nonInputVariables = parser.NonInputVariables; 115 for (int i = 0; i < dataset.Columns; i++) {116 if (!nonInputVariables.Contains(i)) allowedFeatures.Add(new IntData(i));119 for (int i = 0; i < dataset.Columns; i++) { 120 if (!nonInputVariables.Contains(i)) allowedFeatures.Add(new IntData(i)); 117 121 } 118 122 } … … 124 128 private void TrySetVariable(string name, int value) { 125 129 IVariable var = StructIdProblemInjector.GetVariable(name); 126 if (var != null) {130 if (var != null) { 127 131 ((IntData)var.Value).Data = value; 128 132 } … … 145 149 sb.Append("Sorry, but something went wrong!\n\n" + ex.Message + "\n\n" + ex.StackTrace); 146 150 147 while (ex.InnerException != null) {151 while (ex.InnerException != null) { 148 152 ex = ex.InnerException; 149 153 sb.Append("\n\n-----\n\n" + ex.Message + "\n\n" + ex.StackTrace);
Note: See TracChangeset
for help on using the changeset viewer.