Changeset 4245 for trunk/sources/HeuristicLab.Optimizer/3.3
- Timestamp:
- 08/17/10 16:42:58 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimizer/3.3/FileManager.cs
r4068 r4245 21 21 22 22 using System; 23 using System.Linq; 23 24 using System.Windows.Forms; 24 25 using HeuristicLab.Common; … … 42 43 if (newItemDialog.ShowDialog() == DialogResult.OK) { 43 44 IView view = MainFormManager.MainForm.ShowContent(newItemDialog.Item); 44 if (view == null) MessageBox.Show("There is no view for the new item. It cannot be displayed.", "No View Available", MessageBoxButtons.OK, MessageBoxIcon.Error); 45 if (view == null) 46 ErrorHandling.ShowErrorDialog("There is no view for the new item. It cannot be displayed.", new InvalidOperationException("No View Available")); 45 47 } 46 48 } … … 66 68 try { 67 69 if (error != null) throw error; 68 Invoke(delegate() { 69 IView view = MainFormManager.MainForm.ShowContent(content); 70 if (view == null) MessageBox.Show("There is no view for the loaded item. It cannot be displayed.", "No View Available", MessageBoxButtons.OK, MessageBoxIcon.Error); 71 }); 70 IView view = MainFormManager.MainForm.ShowContent(content); 71 if (view == null) 72 ErrorHandling.ShowErrorDialog("There is no view for the loaded item. It cannot be displayed.", new InvalidOperationException("No View Available")); 72 73 } 73 74 catch (Exception ex) { … … 87 88 private static void Save(IContentView view) { 88 89 IStorableContent content = view.Content as IStorableContent; 89 if (!view.Locked && (content != null)) {90 if (!view.Locked && content != null) { 90 91 if (string.IsNullOrEmpty(content.Filename)) 91 92 SaveAs(view); 92 93 else { 93 94 ((OptimizerMainForm)MainFormManager.MainForm).SetAppStartingCursor(); 95 var views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == content).ToList(); 96 views.ForEach(v => v.ReadOnly = true); 97 views.ForEach(v => v.Locked = true); 94 98 ContentManager.SaveAsync(content, content.Filename, true, SavingCompleted); 95 99 } … … 104 108 public static void SaveAs(IContentView view) { 105 109 IStorableContent content = view.Content as IStorableContent; 106 if (!view.Locked && (content != null)) {110 if (!view.Locked && content != null) { 107 111 if (saveFileDialog == null) { 108 112 saveFileDialog = new SaveFileDialog(); … … 116 120 if (saveFileDialog.ShowDialog() == DialogResult.OK) { 117 121 ((OptimizerMainForm)MainFormManager.MainForm).SetAppStartingCursor(); 122 var views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == content).ToList(); 123 views.ForEach(v => v.ReadOnly = true); 124 views.ForEach(v => v.Locked = true); 118 125 if (saveFileDialog.FilterIndex == 1) { 119 126 ContentManager.SaveAsync(content, saveFileDialog.FileName, false, SavingCompleted); … … 126 133 private static void SavingCompleted(IStorableContent content, Exception error) { 127 134 try { 135 var views = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v.Content == content).ToList(); 136 views.ForEach(v => v.ReadOnly = false); 137 views.ForEach(v => v.Locked = false); 128 138 if (error != null) throw error; 129 Invoke(delegate() { 130 ((OptimizerMainForm)MainFormManager.MainForm).UpdateTitle(); 131 }); 139 MainFormManager.GetMainForm<OptimizerMainForm>().UpdateTitle(); 132 140 } 133 141 catch (Exception ex) { … … 138 146 } 139 147 } 140 141 private static void Invoke(Action a) {142 Form form = MainFormManager.MainForm as Form;143 if (form.InvokeRequired)144 form.Invoke(a);145 else146 a.Invoke();147 }148 148 } 149 149 }
Note: See TracChangeset
for help on using the changeset viewer.