void ExecuteCommandSaveProject(object o) { try { var si = new SaveItem(); si.Layer = HeightmapPresenter.HeightmapLayer; si.World = FieldPresenter.World; var sPath = MasterView.GetSaveFilePath(); SaveLoadManager.Save(si, sPath); MasterView.ShowInfoOKMessage("Saved"); } catch (XmlException xe) { MasterView.ShowErrorOKMessage("Not saved due to xml error: " + xe.Message); } catch (InvalidOperationException ioe) { MasterView.ShowErrorOKMessage("Not saved due to Invalid Operation: " + ioe.Message); } catch (IOException ie) { MasterView.ShowErrorOKMessage("Not saved due to IO error: " + ie.Message); } catch (Exception e) { MasterView.ShowErrorOKMessage("Not saved due to: " + e.Message); } }
void ExecuteCommandLoadProject(object o) { try { var path = MasterView.GetLoadFilePath(); var si = SaveLoadManager.Load(path); World = si.World; FieldPresenter.UnselectField(); //HeightmapPresenter = si.Layer; MasterView.RefreshView(); MasterView.ShowInfoOKMessage("Loaded"); } catch (XmlException xe) { MasterView.ShowErrorOKMessage("Not loaded due to xml error: " + xe.Message); } catch (InvalidOperationException ioe) { MasterView.ShowErrorOKMessage("Not loaded due to Invalid Operation: " + ioe.Message); } catch (IOException ie) { MasterView.ShowErrorOKMessage("Not loaded due to IO error: " + ie.Message); } catch (Exception e) { MasterView.ShowErrorOKMessage("Not loaded due to: " + e.Message); } }
void ExecuteCommandExportToTxt(object o) { if (HeightmapPresenter.HeightmapLayer == null) { MasterView.ShowErrorOKMessage("No heightmap rendered yet"); return; } try { IExportManager exportMgr = new ExportManager(); var path = MasterView.GetSaveFilePath(); var layer = this.HeightmapPresenter.HeightmapLayer; exportMgr.ExportToFile(path, layer, MinHeight, MaxHeight); MasterView.ShowInfoOKMessage("Exported"); } catch (IOException e) { MasterView.ShowErrorOKMessage(e.Message); } }