Changeset 1921 for trunk/sources/HeuristicLab.Core/3.3/EditorBase.cs
- Timestamp:
- 05/27/09 18:12:38 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.