Changeset 7309
- Timestamp:
- 01/10/12 17:36:58 (13 years ago)
- Location:
- branches/RegressionBenchmarks/HeuristicLab.Problems.DataAnalysis.Views/3.4
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RegressionBenchmarks/HeuristicLab.Problems.DataAnalysis.Views/3.4/DataAnalysisProblemView.Designer.cs
r7290 r7309 47 47 this.ImportButton = new System.Windows.Forms.Button(); 48 48 this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); 49 this.BenchmarkComboBox = new System.Windows.Forms.ComboBox();50 49 this.LoadButton = new System.Windows.Forms.Button(); 51 50 this.BenchmarkTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); 51 this.ExportButton = new System.Windows.Forms.Button(); 52 this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); 52 53 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 53 54 this.BenchmarkTableLayoutPanel.SuspendLayout(); … … 56 57 // parameterCollectionView 57 58 // 58 this.parameterCollectionView.Location = new System.Drawing.Point(3, 80);59 this.parameterCollectionView.Size = new System.Drawing.Size(490, 2 54);59 this.parameterCollectionView.Location = new System.Drawing.Point(3, 56); 60 this.parameterCollectionView.Size = new System.Drawing.Size(490, 278); 60 61 this.parameterCollectionView.TabIndex = 4; 61 62 // … … 74 75 this.ImportButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 75 76 | System.Windows.Forms.AnchorStyles.Right))); 76 this.ImportButton.Location = new System.Drawing.Point(3, 24);77 this.ImportButton.Location = new System.Drawing.Point(3, 3); 77 78 this.ImportButton.Name = "ImportButton"; 78 this.ImportButton.Size = new System.Drawing.Size( 487, 23);79 this.ImportButton.Size = new System.Drawing.Size(158, 21); 79 80 this.ImportButton.TabIndex = 3; 80 this.ImportButton.Text = "Import from CSV file";81 this.ImportButton.Text = "Import ProblemData from CSV file"; 81 82 this.ImportButton.UseVisualStyleBackColor = true; 82 83 this.ImportButton.Click += new System.EventHandler(this.ImportButton_Click); … … 85 86 // 86 87 this.openFileDialog.Filter = "CSV files|*.csv|Text files|*.txt|All files|*.*"; 87 this.openFileDialog.Title = "Import data..."; 88 // 89 // BenchmarkComboBox 90 // 91 this.BenchmarkComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 92 | System.Windows.Forms.AnchorStyles.Right))); 93 this.BenchmarkComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 94 this.BenchmarkComboBox.FormattingEnabled = true; 95 this.BenchmarkComboBox.Location = new System.Drawing.Point(3, 3); 96 this.BenchmarkComboBox.Name = "BenchmarkComboBox"; 97 this.BenchmarkComboBox.Size = new System.Drawing.Size(240, 21); 98 this.BenchmarkComboBox.TabIndex = 5; 88 this.openFileDialog.Title = "Import ProblemData..."; 99 89 // 100 90 // LoadButton … … 102 92 this.LoadButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 103 93 | System.Windows.Forms.AnchorStyles.Right))); 104 this.LoadButton.Location = new System.Drawing.Point( 249, 2);94 this.LoadButton.Location = new System.Drawing.Point(167, 2); 105 95 this.LoadButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 3); 106 96 this.LoadButton.Name = "LoadButton"; 107 this.LoadButton.Size = new System.Drawing.Size( 241, 23);97 this.LoadButton.Size = new System.Drawing.Size(158, 23); 108 98 this.LoadButton.TabIndex = 6; 109 this.LoadButton.Text = " Load";99 this.LoadButton.Text = "Generate Benchmark ProblemData"; 110 100 this.LoadButton.UseVisualStyleBackColor = true; 111 this.LoadButton.Click += new System.EventHandler(this. loadButton_Click);101 this.LoadButton.Click += new System.EventHandler(this.LoadButton_Click); 112 102 // 113 103 // BenchmarkTableLayoutPanel … … 115 105 this.BenchmarkTableLayoutPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 116 106 | System.Windows.Forms.AnchorStyles.Right))); 117 this.BenchmarkTableLayoutPanel.ColumnCount = 2;118 this.BenchmarkTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));119 this.BenchmarkTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));120 this.BenchmarkTableLayoutPanel.Co ntrols.Add(this.BenchmarkComboBox, 0, 0);107 this.BenchmarkTableLayoutPanel.ColumnCount = 3; 108 this.BenchmarkTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); 109 this.BenchmarkTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); 110 this.BenchmarkTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); 121 111 this.BenchmarkTableLayoutPanel.Controls.Add(this.LoadButton, 1, 0); 122 this.BenchmarkTableLayoutPanel.Location = new System.Drawing.Point(0, 51); 112 this.BenchmarkTableLayoutPanel.Controls.Add(this.ImportButton, 0, 0); 113 this.BenchmarkTableLayoutPanel.Controls.Add(this.ExportButton, 2, 0); 114 this.BenchmarkTableLayoutPanel.Location = new System.Drawing.Point(0, 26); 123 115 this.BenchmarkTableLayoutPanel.Name = "BenchmarkTableLayoutPanel"; 124 116 this.BenchmarkTableLayoutPanel.RowCount = 1; 125 this.BenchmarkTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));117 this.BenchmarkTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); 126 118 this.BenchmarkTableLayoutPanel.Size = new System.Drawing.Size(493, 28); 127 119 this.BenchmarkTableLayoutPanel.TabIndex = 7; 120 // 121 // ExportButton 122 // 123 this.ExportButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 124 | System.Windows.Forms.AnchorStyles.Right))); 125 this.ExportButton.Location = new System.Drawing.Point(331, 3); 126 this.ExportButton.Name = "ExportButton"; 127 this.ExportButton.Size = new System.Drawing.Size(159, 22); 128 this.ExportButton.TabIndex = 7; 129 this.ExportButton.Text = "Export ProblemData to CSV file"; 130 this.ExportButton.UseVisualStyleBackColor = true; 131 this.ExportButton.Click += new System.EventHandler(this.ExportButton_Click); 132 // 133 // saveFileDialog 134 // 135 this.saveFileDialog.Filter = "CSV files|*.csv|All files|*.*"; 136 this.saveFileDialog.Title = "Save ProblemData..."; 128 137 // 129 138 // DataAnalysisProblemView … … 131 140 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 132 141 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 133 this.Controls.Add(this.ImportButton);134 142 this.Controls.Add(this.BenchmarkTableLayoutPanel); 135 143 this.Name = "DataAnalysisProblemView"; 136 144 this.Size = new System.Drawing.Size(493, 334); 137 145 this.Controls.SetChildIndex(this.BenchmarkTableLayoutPanel, 0); 138 this.Controls.SetChildIndex(this.ImportButton, 0);139 146 this.Controls.SetChildIndex(this.parameterCollectionView, 0); 140 147 this.Controls.SetChildIndex(this.infoLabel, 0); … … 152 159 private System.Windows.Forms.Button ImportButton; 153 160 private System.Windows.Forms.OpenFileDialog openFileDialog; 154 private System.Windows.Forms.ComboBox BenchmarkComboBox;155 161 private System.Windows.Forms.Button LoadButton; 156 162 private System.Windows.Forms.TableLayoutPanel BenchmarkTableLayoutPanel; 163 private System.Windows.Forms.Button ExportButton; 164 private System.Windows.Forms.SaveFileDialog saveFileDialog; 157 165 } 158 166 } -
branches/RegressionBenchmarks/HeuristicLab.Problems.DataAnalysis.Views/3.4/DataAnalysisProblemView.cs
r7290 r7309 21 21 22 22 using System; 23 using System. Collections.Generic;24 using System. Linq;23 using System.IO; 24 using System.Text; 25 25 using System.Windows.Forms; 26 using HeuristicLab.Common;27 26 using HeuristicLab.MainForm; 28 27 using HeuristicLab.Optimization.Views; … … 33 32 [Content(typeof(IDataAnalysisProblem), true)] 34 33 public partial class DataAnalysisProblemView : ProblemView { 34 35 private BenchmarkGeneratorDialog problemDataSelectorDialog; 36 35 37 public DataAnalysisProblemView() { 36 38 InitializeComponent(); … … 46 48 ImportButton.Enabled = !Locked && !ReadOnly && Content != null; 47 49 LoadButton.Enabled = !Locked && !ReadOnly && Content != null; 48 BenchmarkComboBox.Enabled = !Locked && !ReadOnly && Content != null;50 ExportButton.Enabled = !Locked && !ReadOnly && Content != null; 49 51 } 50 52 … … 60 62 } 61 63 62 private void loadButton_Click(object sender, EventArgs e) { 63 if (BenchmarkComboBox.SelectedItem != null) 64 Content.ProblemData = ((IDataAnalysisBenchmarkProblemDataGenerator)BenchmarkComboBox.SelectedItem).GenerateProblemData(); 64 private void LoadButton_Click(object sender, EventArgs e) { 65 if (problemDataSelectorDialog == null) { 66 problemDataSelectorDialog = new BenchmarkGeneratorDialog(Content); 67 } 68 if (problemDataSelectorDialog.ShowDialog(this) == DialogResult.OK) { 69 try { 70 Content.ProblemData = problemDataSelectorDialog.ProblemData; 71 } 72 catch (Exception ex) { 73 ErrorHandling.ShowErrorDialog(this, ex); 74 } 75 } 65 76 } 66 77 67 protected override void OnContentChanged() { 68 base.OnContentChanged(); 69 BenchmarkComboBox.Items.Clear(); 70 BenchmarkComboBox.Items.AddRange(GetBenchmarkProblemDataGenerators().OrderBy(b => b.Name, new NaturalStringComparer()).ToArray()); 71 if (BenchmarkComboBox.Items.Count > 0) 72 BenchmarkComboBox.SelectedIndex = 0; 78 private void ExportButton_Click(object sender, EventArgs e) { 79 if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { 80 try { 81 ExportProblemData(Content.ProblemData.Dataset, saveFileDialog.FileName); 82 } 83 catch (Exception ex) { 84 ErrorHandling.ShowErrorDialog(this, ex); 85 } 86 } 73 87 } 74 88 75 protected IEnumerable<IDataAnalysisBenchmarkProblemDataGenerator> GetBenchmarkProblemDataGenerators() { 76 if (Content is IRegressionProblem) 77 return ApplicationManager.Manager.GetInstances<IRegressionBenchmarkProblemDataGenerator>(); 78 else if (Content is IClassificationProblem) 79 return ApplicationManager.Manager.GetInstances<IClassificationBenchmarkProblemDataGenerator>(); 80 else if (Content is IClusteringProblem) 81 return ApplicationManager.Manager.GetInstances<IClusteringBenchmarkProblemDataGenerator>(); 82 return new List<IDataAnalysisBenchmarkProblemDataGenerator>(); 89 private void ExportProblemData(Dataset dataset, string file) { 90 StringBuilder strBuilder = new StringBuilder(); 91 92 foreach (var variable in dataset.VariableNames) { 93 strBuilder.Append(variable + ";"); 94 } 95 strBuilder.Remove(strBuilder.Length - 1, 1); 96 strBuilder.AppendLine(); 97 98 for (int i = 0; i < dataset.Rows; i++) { 99 for (int j = 0; j < dataset.Columns; j++) { 100 strBuilder.Append(dataset.GetValue(i, j) + ";"); 101 } 102 strBuilder.Remove(strBuilder.Length - 1, 1); 103 strBuilder.AppendLine(); 104 } 105 106 using (StreamWriter writer = new StreamWriter(file)) { 107 writer.Write(strBuilder); 108 } 83 109 } 84 110 } -
branches/RegressionBenchmarks/HeuristicLab.Problems.DataAnalysis.Views/3.4/DataAnalysisProblemView.resx
r7127 r7309 121 121 <value>107, 17</value> 122 122 </metadata> 123 <metadata name="errorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 124 <value>107, 17</value> 125 </metadata> 123 126 <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 124 127 <value>17, 17</value> … … 127 130 <value>230, 17</value> 128 131 </metadata> 132 <metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 133 <value>363, 17</value> 134 </metadata> 129 135 </root>
Note: See TracChangeset
for help on using the changeset viewer.