Changeset 2713 for trunk/sources/HeuristicLab.Optimizer/3.3/FileManager.cs
- Timestamp:
- 01/29/10 01:44:57 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimizer/3.3/FileManager.cs
r2708 r2713 32 32 #endregion 33 33 34 private static Dictionary<I ObjectView, FileInfo> files;34 private static Dictionary<IContentView, FileInfo> files; 35 35 private static NewItemDialog newItemDialog; 36 36 private static OpenFileDialog openFileDialog; … … 40 40 41 41 static FileManager() { 42 files = new Dictionary<I ObjectView, FileInfo>();42 files = new Dictionary<IContentView, FileInfo>(); 43 43 newItemDialog = null; 44 44 openFileDialog = null; … … 56 56 MessageBox.Show("There is no view for the new item. It cannot be displayed. ", "No View Available", MessageBoxButtons.OK, MessageBoxIcon.Error); 57 57 } else { 58 if (view is I ObjectView) {58 if (view is IContentView) { 59 59 view.Caption = "Item" + newDocumentsCounter.ToString() + ".hl"; 60 60 newDocumentsCounter++; … … 82 82 83 83 public static void Save() { 84 I ObjectView activeView = MainFormManager.MainForm.ActiveView as IObjectView;85 if ((activeView != null) && (CreatableAttribute.IsCreatable(activeView. Object.GetType()))) {84 IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; 85 if ((activeView != null) && (CreatableAttribute.IsCreatable(activeView.Content.GetType()))) { 86 86 Save(activeView); 87 87 } 88 88 } 89 private static void Save(I ObjectView view) {89 private static void Save(IContentView view) { 90 90 if ((!files.ContainsKey(view)) || (!File.Exists(files[view].Filename))) { 91 91 SaveAs(view); … … 99 99 100 100 public static void SaveAs() { 101 I ObjectView activeView = MainFormManager.MainForm.ActiveView as IObjectView;102 if ((activeView != null) && (CreatableAttribute.IsCreatable(activeView. Object.GetType()))) {101 IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; 102 if ((activeView != null) && (CreatableAttribute.IsCreatable(activeView.Content.GetType()))) { 103 103 SaveAs(activeView); 104 104 } 105 105 } 106 public static void SaveAs(I ObjectView view) {106 public static void SaveAs(IContentView view) { 107 107 if (saveFileDialog == null) { 108 108 saveFileDialog = new SaveFileDialog(); … … 135 135 public static void SaveAll() { 136 136 var views = from v in MainFormManager.MainForm.Views 137 where v is I ObjectView138 where CreatableAttribute.IsCreatable(((I ObjectView)v).Object.GetType())139 select v as I ObjectView;140 141 foreach (I ObjectView view in views) {137 where v is IContentView 138 where CreatableAttribute.IsCreatable(((IContentView)v).Content.GetType()) 139 select v as IContentView; 140 141 foreach (IContentView view in views) { 142 142 Save(view); 143 143 } … … 146 146 // NOTE: This event is fired by the main form. It is registered in HeuristicLabOptimizerApplication. 147 147 internal static void ViewClosed(object sender, ViewEventArgs e) { 148 I ObjectView view = e.View as IObjectView;148 IContentView view = e.View as IContentView; 149 149 if (view != null) files.Remove(view); 150 150 } … … 159 159 } 160 160 161 private static void SaveItemAsync(I ObjectView view, string filename, int compression) {161 private static void SaveItemAsync(IContentView view, string filename, int compression) { 162 162 ThreadPool.QueueUserWorkItem( 163 163 new WaitCallback( … … 166 166 DisableView(view); 167 167 SetWaitingCursor(); 168 XmlGenerator.Serialize(view. Object, filename, compression);168 XmlGenerator.Serialize(view.Content, filename, compression); 169 169 Invoke(delegate() { 170 170 view.Caption = Path.GetFileName(filename); … … 191 191 IItem item = (IItem)XmlParser.Deserialize(filename); 192 192 Invoke(delegate() { 193 I ObjectView view = MainFormManager.CreateDefaultView(item) as IObjectView;193 IContentView view = MainFormManager.CreateDefaultView(item) as IContentView; 194 194 if (view == null) { 195 195 MessageBox.Show("There is no view for the loaded item. It cannot be displayed. ", "No View Available", MessageBoxButtons.OK, MessageBoxIcon.Error);
Note: See TracChangeset
for help on using the changeset viewer.