- Timestamp:
- 02/15/12 10:40:17 (13 years ago)
- Location:
- branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.Designer.cs
r7399 r7468 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this. btnImport= new System.Windows.Forms.Button();47 this.importButton = new System.Windows.Forms.Button(); 48 48 this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); 49 49 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); … … 60 60 // splitContainer.Panel2 61 61 // 62 this.splitContainer.Panel2.Controls.Add(this. btnImport);62 this.splitContainer.Panel2.Controls.Add(this.importButton); 63 63 // 64 64 // itemsGroupBox … … 76 76 // btnImport 77 77 // 78 this. btnImport.Location = new System.Drawing.Point(3, 4);79 this. btnImport.Name = "btnImport";80 this. btnImport.Size = new System.Drawing.Size(75, 23);81 this. btnImport.TabIndex = 7;82 this. btnImport.Text = "Import";83 this. btnImport.UseVisualStyleBackColor = true;84 this. btnImport.Click += new System.EventHandler(this.btnImport_Click);78 this.importButton.Location = new System.Drawing.Point(3, 4); 79 this.importButton.Name = "btnImport"; 80 this.importButton.Size = new System.Drawing.Size(75, 23); 81 this.importButton.TabIndex = 7; 82 this.importButton.Text = "Import"; 83 this.importButton.UseVisualStyleBackColor = true; 84 this.importButton.Click += new System.EventHandler(this.importButton_Click); 85 85 // 86 86 // openFileDialog … … 106 106 #endregion 107 107 108 private System.Windows.Forms.Button btnImport;108 private System.Windows.Forms.Button importButton; 109 109 private System.Windows.Forms.OpenFileDialog openFileDialog; 110 110 } -
branches/ChangeDatasetOfRegressionModel/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.cs
r7399 r7468 45 45 protected override void SetEnabledStateOfControls() { 46 46 base.SetEnabledStateOfControls(); 47 btnImport.Enabled = !Locked && !ReadOnly && Content != null;47 importButton.Enabled = !Locked && !ReadOnly && Content != null; 48 48 } 49 49 … … 62 62 #endregion 63 63 64 private void btnImport_Click(object sender, System.EventArgs e) { 65 if (openFileDialog.ShowDialog(this) == DialogResult.OK) { 66 object hlFile = null; 67 try { 68 hlFile = XmlParser.Deserialize(openFileDialog.FileName); 69 } 70 catch (Exception ex) { 71 ErrorHandling.ShowErrorDialog(this, ex); 72 } 64 private void importButton_Click(object sender, EventArgs e) { 65 if (openFileDialog.ShowDialog(this) != DialogResult.OK) return; 73 66 74 if (hlFile != null) { 75 IRegressionProblemData problemData = null; 76 if (hlFile is RegressionProblemData) { 77 problemData = (RegressionProblemData)hlFile; 78 } else if (hlFile is IRegressionProblem) { 79 problemData = ((IRegressionProblem)hlFile).ProblemData; 80 } else if (hlFile is IRegressionSolution) { 81 problemData = ((IRegressionSolution)hlFile).ProblemData; 82 } 67 object hlFile = null; 68 try { 69 hlFile = XmlParser.Deserialize(openFileDialog.FileName); 70 } 71 catch (Exception ex) { 72 ErrorHandling.ShowErrorDialog(this, ex); 73 return; 74 } 83 75 84 if (problemData == null) { 85 ErrorHandling.ShowErrorDialog(this, 86 new NullReferenceException("The problem data is null." + Environment.NewLine 87 + "The .hl-file is no RegressionProblemData or RegressionProblem.")); 88 } else { 89 StringBuilder message = new StringBuilder(); 90 if (!problemData.TargetVariable.Equals(Content.ProblemData.TargetVariable)) 91 message.AppendLine("The target variables are not matching. Old target variable: '" 92 + Content.ProblemData.TargetVariable 93 + "'. New targetvariable: '" + problemData.TargetVariable + "'"); 76 IRegressionProblemData problemData = null; 77 if (hlFile is IRegressionProblemData) { 78 problemData = (IRegressionProblemData)hlFile; 79 } else if (hlFile is IRegressionProblem) { 80 problemData = ((IRegressionProblem)hlFile).ProblemData; 81 } else if (hlFile is IRegressionSolution) { 82 problemData = ((IRegressionSolution)hlFile).ProblemData; 83 } 94 84 95 List<string> variables = problemData.InputVariables.Select(x => x.Value).ToList(); 85 if (problemData == null) { 86 ErrorHandling.ShowErrorDialog(this, 87 new NullReferenceException("The problem data is null." + Environment.NewLine 88 + "The .hl-file is no RegressionProblemData or RegressionProblem.")); 89 return; 90 } 96 91 97 foreach (var item in Content.ProblemData.InputVariables.CheckedItems) { 98 if (!variables.Contains(item.Value.Value)) 99 message.AppendLine("Input variable '" + item.Value.Value + "' is not in the new problem data."); 100 } 92 StringBuilder message = new StringBuilder(); 93 if (!problemData.TargetVariable.Equals(Content.ProblemData.TargetVariable)) 94 message.AppendLine("The target variables are not matching. Old target variable: '" 95 + Content.ProblemData.TargetVariable 96 + "'. New targetvariable: '" + problemData.TargetVariable + "'"); 101 97 102 if (message.Length != 0) 103 ErrorHandling.ShowErrorDialog(this, new Exception(message.ToString())); 104 else 105 Content.ProblemData = problemData; 106 } 107 } 98 List<string> variables = problemData.InputVariables.Select(x => x.Value).ToList(); 99 foreach (var item in Content.ProblemData.InputVariables.CheckedItems) { 100 if (!variables.Contains(item.Value.Value)) 101 message.AppendLine("Input variable '" + item.Value.Value + "' is not in the new problem data."); 108 102 } 103 104 if (message.Length != 0) 105 ErrorHandling.ShowErrorDialog(this, new Exception(message.ToString())); 106 else 107 Content.ProblemData = problemData; 108 109 109 } 110 110 }
Note: See TracChangeset
for help on using the changeset viewer.