Changeset 1921
- Timestamp:
- 05/27/09 18:12:38 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.AdvancedOptimizationFrontend/3.3/MainForm.Designer.cs
r1529 r1921 103 103 this.exitToolStripMenuItem}); 104 104 this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; 105 this.fileToolStripMenuItem.Size = new System.Drawing.Size(3 5, 20);105 this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); 106 106 this.fileToolStripMenuItem.Text = "&File"; 107 107 // … … 109 109 // 110 110 this.newToolStripMenuItem.Name = "newToolStripMenuItem"; 111 this.newToolStripMenuItem.Size = new System.Drawing.Size(1 91, 22);111 this.newToolStripMenuItem.Size = new System.Drawing.Size(187, 22); 112 112 this.newToolStripMenuItem.Text = "&New"; 113 113 // … … 116 116 this.openToolStripMenuItem.Name = "openToolStripMenuItem"; 117 117 this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); 118 this.openToolStripMenuItem.Size = new System.Drawing.Size(1 91, 22);118 this.openToolStripMenuItem.Size = new System.Drawing.Size(187, 22); 119 119 this.openToolStripMenuItem.Text = "&Open..."; 120 120 this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click); … … 125 125 this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; 126 126 this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); 127 this.saveToolStripMenuItem.Size = new System.Drawing.Size(1 91, 22);127 this.saveToolStripMenuItem.Size = new System.Drawing.Size(187, 22); 128 128 this.saveToolStripMenuItem.Text = "&Save"; 129 129 this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click); … … 133 133 this.saveAsToolStripMenuItem.Enabled = false; 134 134 this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem"; 135 this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(1 91, 22);135 this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(187, 22); 136 136 this.saveAsToolStripMenuItem.Text = "Save &As..."; 137 137 this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click); … … 143 143 this.saveAllToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) 144 144 | System.Windows.Forms.Keys.S))); 145 this.saveAllToolStripMenuItem.Size = new System.Drawing.Size(1 91, 22);145 this.saveAllToolStripMenuItem.Size = new System.Drawing.Size(187, 22); 146 146 this.saveAllToolStripMenuItem.Text = "Save Al&l"; 147 147 this.saveAllToolStripMenuItem.Click += new System.EventHandler(this.saveAllToolStripMenuItem_Click); … … 151 151 this.closeToolStripMenuItem.Enabled = false; 152 152 this.closeToolStripMenuItem.Name = "closeToolStripMenuItem"; 153 this.closeToolStripMenuItem.Size = new System.Drawing.Size(1 91, 22);153 this.closeToolStripMenuItem.Size = new System.Drawing.Size(187, 22); 154 154 this.closeToolStripMenuItem.Text = "&Close"; 155 155 this.closeToolStripMenuItem.Click += new System.EventHandler(this.closeToolStripMenuItem_Click); … … 159 159 this.closeAllToolStripMenuItem.Enabled = false; 160 160 this.closeAllToolStripMenuItem.Name = "closeAllToolStripMenuItem"; 161 this.closeAllToolStripMenuItem.Size = new System.Drawing.Size(1 91, 22);161 this.closeAllToolStripMenuItem.Size = new System.Drawing.Size(187, 22); 162 162 this.closeAllToolStripMenuItem.Text = "Clos&e All"; 163 163 this.closeAllToolStripMenuItem.Click += new System.EventHandler(this.closeAllToolStripMenuItem_Click); … … 166 166 // 167 167 this.toolStripMenuItem1.Name = "toolStripMenuItem1"; 168 this.toolStripMenuItem1.Size = new System.Drawing.Size(18 8, 6);168 this.toolStripMenuItem1.Size = new System.Drawing.Size(184, 6); 169 169 // 170 170 // exitToolStripMenuItem 171 171 // 172 172 this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; 173 this.exitToolStripMenuItem.Size = new System.Drawing.Size(1 91, 22);173 this.exitToolStripMenuItem.Size = new System.Drawing.Size(187, 22); 174 174 this.exitToolStripMenuItem.Text = "E&xit"; 175 175 this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); … … 180 180 this.availableOperatorsToolStripMenuItem}); 181 181 this.viewToolStripMenuItem.Name = "viewToolStripMenuItem"; 182 this.viewToolStripMenuItem.Size = new System.Drawing.Size(4 1, 20);182 this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20); 183 183 this.viewToolStripMenuItem.Text = "&View"; 184 184 // … … 186 186 // 187 187 this.availableOperatorsToolStripMenuItem.Name = "availableOperatorsToolStripMenuItem"; 188 this.availableOperatorsToolStripMenuItem.Size = new System.Drawing.Size(1 92, 22);188 this.availableOperatorsToolStripMenuItem.Size = new System.Drawing.Size(186, 22); 189 189 this.availableOperatorsToolStripMenuItem.Text = "Available &Operators..."; 190 190 this.availableOperatorsToolStripMenuItem.Click += new System.EventHandler(this.availableOperatorsToolStripMenuItem_Click); … … 195 195 this.collectGarbageToolStripMenuItem}); 196 196 this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem"; 197 this.toolsToolStripMenuItem.Size = new System.Drawing.Size(4 4, 20);197 this.toolsToolStripMenuItem.Size = new System.Drawing.Size(48, 20); 198 198 this.toolsToolStripMenuItem.Text = "&Tools"; 199 199 // … … 201 201 // 202 202 this.collectGarbageToolStripMenuItem.Name = "collectGarbageToolStripMenuItem"; 203 this.collectGarbageToolStripMenuItem.Size = new System.Drawing.Size(1 61, 22);203 this.collectGarbageToolStripMenuItem.Size = new System.Drawing.Size(158, 22); 204 204 this.collectGarbageToolStripMenuItem.Text = "Collect &Garbage"; 205 205 this.collectGarbageToolStripMenuItem.Click += new System.EventHandler(this.collectGarbageToolStripMenuItem_Click); … … 210 210 this.aboutToolStripMenuItem}); 211 211 this.helpToolStripMenuItem.Name = "helpToolStripMenuItem"; 212 this.helpToolStripMenuItem.Size = new System.Drawing.Size(4 0, 20);212 this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20); 213 213 this.helpToolStripMenuItem.Text = "&Help"; 214 214 // … … 216 216 // 217 217 this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem"; 218 this.aboutToolStripMenuItem.Size = new System.Drawing.Size(1 14, 22);218 this.aboutToolStripMenuItem.Size = new System.Drawing.Size(107, 22); 219 219 this.aboutToolStripMenuItem.Text = "&About"; 220 220 this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click); … … 238 238 this.saveFileDialog.DefaultExt = "hl"; 239 239 this.saveFileDialog.FileName = "item"; 240 this.saveFileDialog.Filter = "HeuristicLab files|*.hl|All files|*.*";240 this.saveFileDialog.Filter = "HeuristicLab archives|*.hl|Compressed HeuristicLab archives|*.hl|All files|*.*"; 241 241 this.saveFileDialog.Title = "Save file as ..."; 242 242 // -
trunk/sources/HeuristicLab.AdvancedOptimizationFrontend/3.3/MainForm.cs
r1853 r1921 184 184 else { 185 185 editor.Filename = task.filename; 186 editor.SaveFinished += new EventHandler(SaveFinished); 186 187 PluginManager.ControlManager.ShowControl(editor); 187 188 } … … 193 194 } 194 195 } 196 195 197 private void Save(EditorForm form) { 196 198 if (form.Editor.Filename == null) 197 199 SaveAs(form); 198 200 else { 201 Cursor = Cursors.AppStarting; 199 202 lock (locker) runningTasks++; 200 Cursor = Cursors.AppStarting;201 ((Control)form.Editor).Enabled = false;202 203 EnableDisableItems(); 203 Task task = new Task(form.Editor.Filename, form.Editor.Item, form.Editor); 204 ThreadPool.QueueUserWorkItem(new WaitCallback(AsynchronousSave), task); 204 form.Editor.Save(); 205 205 } 206 206 } 207 207 private void SaveAs(EditorForm form) { 208 if (form.Editor.Compressed) 209 saveFileDialog.FilterIndex = 2; 210 else 211 saveFileDialog.FilterIndex = 1; 212 208 213 if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { 209 214 form.Editor.Filename = saveFileDialog.FileName; 215 form.Editor.Compressed = saveFileDialog.FilterIndex == 2; 210 216 Save(form); 211 217 } 212 213 } 214 private void AsynchronousSave(object state) { 215 Task task = (Task)state; 216 try { 217 PersistenceManager.Save(task.storable, task.filename); 218 } catch (Exception e) { 219 MessageBox.Show(String.Format( 220 "Sorry couldn't save file \"{0}\".\n The following exception occurred: {1}", 221 task.filename, e.ToString()), 222 "Reader Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 223 } 224 SaveFinished(task); 225 } 226 private void SaveFinished(Task task) { 218 } 219 private void SaveFinished(object sender, EventArgs e) { 227 220 if (InvokeRequired) 228 Invoke(new TaskFinishedDelegate(SaveFinished), task);221 Invoke(new EventHandler(SaveFinished), sender, e); 229 222 else { 230 ((Control)task.editor).Enabled = true;231 223 EnableDisableItems(); 232 224 lock (locker) { … … 255 247 MessageBox.Show("The selected item doesn't provide an editor.", "Editor Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 256 248 } else { 249 editor.SaveFinished += new EventHandler(SaveFinished); 257 250 PluginManager.ControlManager.ShowControl(editor); 258 251 EnableDisableItems(); -
trunk/sources/HeuristicLab.Core/3.3/EditorBase.cs
r1529 r1921 26 26 using System.Data; 27 27 using System.Text; 28 using System.Threading; 28 29 using System.Windows.Forms; 29 30 … … 49 50 50 51 /// <summary> 52 /// Gets or sets, if the contained item should be compressed. 53 /// </summary> 54 public bool Compressed { get; set; } 55 56 /// <summary> 51 57 /// Initializes a new instance of <see cref="EditorBase"/> with the caption "Editor". 52 58 /// </summary> … … 54 60 InitializeComponent(); 55 61 Caption = "Editor"; 62 } 63 64 /// <summary> 65 /// Asynchronously saves the contained object to a file. 66 /// </summary> 67 /// <remarks>The filename to save the contained item to is given by <see cref="Filename"/>.</remarks> 68 public void Save() { 69 Enabled = false; 70 ThreadPool.QueueUserWorkItem((o) => { 71 try { 72 if (Compressed) 73 PersistenceManager.SaveCompressed(Item, Filename); 74 else 75 PersistenceManager.Save(Item, Filename); 76 } catch (Exception e) { 77 MessageBox.Show(String.Format( 78 "Sorry couldn't save file \"{0}\".\n The following exception occurred: {1}", 79 Filename, e.ToString()), 80 "Reader Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 81 } finally { 82 Invoke(new Action(() => Enabled = true)); 83 OnSaveFinished(); 84 } 85 }); 56 86 } 57 87 … … 79 109 FilenameChanged(this, new EventArgs()); 80 110 } 111 112 /// <summary> 113 /// Occurs after a save operation is finished. 114 /// </summary> 115 public event EventHandler SaveFinished; 116 117 /// <summary> 118 /// Fires a new <c>SaveFinished</c> event. 119 /// </summary> 120 protected virtual void OnSaveFinished() { 121 SaveFinished(this, new EventArgs()); 122 } 81 123 } 82 124 } -
trunk/sources/HeuristicLab.Core/3.3/Interfaces/IEditor.cs
r776 r1921 36 36 37 37 /// <summary> 38 /// Gets or sets, it the contained item should be compressed. 39 /// </summary> 40 bool Compressed { get; set; } 41 42 /// <summary> 43 /// Saves the contained object to a file. 44 /// </summary> 45 /// <remarks>The filename to save the contained item to is given by <see cref="Filename"/>.</remarks> 46 void Save(); 47 48 /// <summary> 38 49 /// Occurs when the filename was changed. 39 50 /// </summary> 40 51 event EventHandler FilenameChanged; 52 53 /// <summary> 54 /// Occurs after a save operation is finished. 55 /// </summary> 56 event EventHandler SaveFinished; 41 57 } 42 58 }
Note: See TracChangeset
for help on using the changeset viewer.