Changeset 6265
- Timestamp:
- 05/24/11 15:41:17 (14 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.ExternalEvaluation.Views/3.3/EvaluationCacheView.Designer.cs
r6169 r6265 27 27 this.hits_sizeTextBox = new System.Windows.Forms.TextBox(); 28 28 this.clearButton = new System.Windows.Forms.Button(); 29 this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); 30 this.saveButton = new System.Windows.Forms.Button(); 29 31 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 30 32 this.SuspendLayout(); … … 56 58 this.hits_sizeTextBox.Name = "hits_sizeTextBox"; 57 59 this.hits_sizeTextBox.ReadOnly = true; 58 this.hits_sizeTextBox.Size = new System.Drawing.Size(3 79, 20);60 this.hits_sizeTextBox.Size = new System.Drawing.Size(319, 20); 59 61 this.hits_sizeTextBox.TabIndex = 5; 60 62 // … … 71 73 this.clearButton.Click += new System.EventHandler(this.clearButton_Click); 72 74 // 75 // saveFileDialog 76 // 77 this.saveFileDialog.DefaultExt = "csv"; 78 this.saveFileDialog.Filter = "CSV Files|*.csv|All Files|*.*"; 79 this.saveFileDialog.RestoreDirectory = true; 80 this.saveFileDialog.Title = "Save Cache"; 81 // 82 // saveButton 83 // 84 this.saveButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 85 this.saveButton.Location = new System.Drawing.Point(384, 23); 86 this.saveButton.Name = "saveButton"; 87 this.saveButton.Size = new System.Drawing.Size(54, 23); 88 this.saveButton.TabIndex = 8; 89 this.saveButton.Text = "Save..."; 90 this.saveButton.UseVisualStyleBackColor = true; 91 this.saveButton.Click += new System.EventHandler(this.saveButton_Click); 92 // 73 93 // EvaluationCacheView 74 94 // … … 78 98 this.Controls.Add(this.hits_sizeLabel); 79 99 this.Controls.Add(this.clearButton); 100 this.Controls.Add(this.saveButton); 80 101 this.Name = "EvaluationCacheView"; 102 this.Controls.SetChildIndex(this.saveButton, 0); 81 103 this.Controls.SetChildIndex(this.clearButton, 0); 82 104 this.Controls.SetChildIndex(this.hits_sizeLabel, 0); … … 97 119 private System.Windows.Forms.TextBox hits_sizeTextBox; 98 120 private System.Windows.Forms.Button clearButton; 121 private System.Windows.Forms.SaveFileDialog saveFileDialog; 122 private System.Windows.Forms.Button saveButton; 99 123 } 100 124 } -
trunk/sources/HeuristicLab.Problems.ExternalEvaluation.Views/3.3/EvaluationCacheView.cs
r6183 r6265 3 3 using HeuristicLab.Core.Views; 4 4 using HeuristicLab.MainForm; 5 using System.Threading; 6 using System.IO; 7 using System.ComponentModel; 5 8 6 9 namespace HeuristicLab.Problems.ExternalEvaluation.Views { … … 55 58 base.SetEnabledStateOfControls(); 56 59 clearButton.Enabled = !ReadOnly && Content != null; 60 saveButton.Enabled = !ReadOnly && Content != null; 57 61 } 58 62 … … 62 66 } 63 67 #endregion 68 69 private void saveButton_Click(object sender, EventArgs e) { 70 if (saveFileDialog.ShowDialog() == DialogResult.OK) { 71 saveButton.Enabled = false; 72 BackgroundWorker worker = new BackgroundWorker(); 73 worker.DoWork += (s, a) => { 74 Content.Save((string)a.Argument); 75 }; 76 worker.RunWorkerCompleted += (s, a) => { 77 SetEnabledStateOfControls(); 78 }; 79 worker.RunWorkerAsync(saveFileDialog.FileName); 80 } 81 } 64 82 } 65 83 } -
trunk/sources/HeuristicLab.Problems.ExternalEvaluation.Views/3.3/EvaluationCacheView.resx
r6169 r6265 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>126 123 <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 127 124 <value>17, 17</value> 128 125 </metadata> 126 <metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 127 <value>230, 17</value> 128 </metadata> 129 129 </root> -
trunk/sources/HeuristicLab.Problems.ExternalEvaluation/3.3/EvaluationCache.cs
r6188 r6265 33 33 using HeuristicLab.Parameters; 34 34 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 35 using HeuristicLab.Analysis; 36 using System.IO; 37 using System.Globalization; 38 using System.Text.RegularExpressions; 35 39 namespace HeuristicLab.Problems.ExternalEvaluation { 36 40 … … 281 285 OnSizeChanged(); 282 286 } 287 283 288 private IEnumerable<KeyValuePair<string, double>> GetCacheValues() { 284 289 lock (cacheLock) { … … 286 291 } 287 292 } 293 288 294 private void SetCacheValues(IEnumerable<KeyValuePair<string, double>> value) { 289 295 lock (cacheLock) { … … 297 303 } 298 304 } 299 #endregion 300 301 } 305 306 public void Save(string filename) { 307 using (var writer = new StreamWriter(filename)) { 308 lock (cacheLock) { 309 foreach (var entry in list) { 310 writer.WriteLine(string.Format(CultureInfo.InvariantCulture, 311 "\"{0}\", {1}", 312 Regex.Replace(entry.Key, "\\s", "").Replace("\"", "\"\""), 313 entry.Value)); 314 } 315 } 316 writer.Close(); 317 } 318 } 319 #endregion 320 } 302 321 }
Note: See TracChangeset
for help on using the changeset viewer.