Changeset 9933 for stable/HeuristicLab.Optimizer/3.3/FileManager.cs
- Timestamp:
- 09/03/13 15:55:36 (11 years ago)
- Location:
- stable
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 9849,9851,9865,9867-9868,9893-9896,9900-9901,9905,9907
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Optimizer/3.3/FileManager.cs
r9456 r9933 22 22 using System; 23 23 using System.Collections.Generic; 24 using System. Linq;24 using System.IO; 25 25 using System.Windows.Forms; 26 26 using HeuristicLab.Common; … … 98 98 SaveAs(view); 99 99 else { 100 ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).SetAppStartingCursor();101 Set EnabledStateOfContentViews(content, false);100 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().SetAppStartingCursor(); 101 SetSaveOperationProgressInContentViews(content, true); 102 102 ContentManager.SaveAsync(content, content.Filename, true, SavingCompleted); 103 103 } … … 123 123 124 124 if (saveFileDialog.ShowDialog() == DialogResult.OK) { 125 ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).SetAppStartingCursor();126 Set EnabledStateOfContentViews(content, false);125 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().SetAppStartingCursor(); 126 SetSaveOperationProgressInContentViews(content, true, saveFileDialog.FileName); 127 127 if (saveFileDialog.FilterIndex == 1) { 128 128 ContentManager.SaveAsync(content, saveFileDialog.FileName, false, SavingCompleted); … … 135 135 private static void SavingCompleted(IStorableContent content, Exception error) { 136 136 try { 137 SetEnabledStateOfContentViews(content, true);138 137 if (error != null) throw error; 139 138 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().UpdateTitle(); … … 143 142 } 144 143 finally { 145 ((MainForm.WindowsForms.MainForm)MainFormManager.MainForm).ResetAppStartingCursor(); 144 SetSaveOperationProgressInContentViews(content, false); 145 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().ResetAppStartingCursor(); 146 146 } 147 147 } 148 148 149 private static void Set EnabledStateOfContentViews(IStorableContent content, bool enabled) {149 private static void SetSaveOperationProgressInContentViews(IStorableContent content, bool showProgress, string fileName = null) { 150 150 HeuristicLab.MainForm.WindowsForms.MainForm mainForm = MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>(); 151 151 #region Mono Compatibility 152 152 // removed the InvokeRequired check because of Mono 153 153 mainForm.Invoke((Action)delegate { 154 var views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == content).ToList(); 155 views.ForEach(v => v.Enabled = enabled); 154 if (showProgress) { 155 mainForm.AddOperationProgressToContent(content, string.Format("Saving to file \"{0}\"...", Path.GetFileName(fileName ?? content.Filename))); 156 } else 157 mainForm.RemoveOperationProgressFromContent(content); 156 158 }); 157 159 #endregion
Note: See TracChangeset
for help on using the changeset viewer.