//-------------------------------------------------------------------------------------------------- public Model CreateModelAs(string baseDirectory = null) { var dlg = new SaveFileDialog() { Title = "Create Model...", CheckPathExists = true, Filter = "Macad3D Models|*." + Model.FileExtension, DefaultExt = Model.FileExtension, }; if (!(baseDirectory is null)) { dlg.InitialDirectory = baseDirectory; } var result = dlg.ShowDialog(Application.Current.MainWindow); if (!(result ?? false)) { return(null); } var relativeFilePath = dlg.FileName; var model = NewModel(); if (model.SaveToFile(relativeFilePath)) { return(model); } else { ErrorDialogs.CannotSaveFile(dlg.FileName); } return(null); }
//-------------------------------------------------------------------------------------------------- public bool SaveModelAs() { var dlg = new SaveFileDialog() { Title = "Saving Model...", CheckPathExists = true, Filter = "Macad3D Models|*." + Model.FileExtension, DefaultExt = Model.FileExtension }; var result = dlg.ShowDialog(Application.Current.MainWindow); if (result ?? false) { var relativeFilePath = dlg.FileName; var model = InteractiveContext.Current.Document; if (model.SaveToFile(relativeFilePath)) { AddToMruList(model.FilePath); return(true); } else { ErrorDialogs.CannotSaveFile(dlg.FileName); } } return(false); }
//-------------------------------------------------------------------------------------------------- public bool SaveModelAs() { var dlg = new SaveFileDialog() { Title = "Saving Model...", InitialDirectory = Path.GetDirectoryName(InteractiveContext.Current.Document.FilePath), FileName = Path.GetFileName(InteractiveContext.Current.Document.FilePath), CheckPathExists = true, Filter = "Macad3D Models|*." + Model.FileExtension, DefaultExt = Model.FileExtension }; var result = dlg.ShowDialog(Application.Current.MainWindow); if (result ?? false) { var filePath = dlg.FileName; if (PathUtils.GetExtensionWithoutPoint(filePath).ToLower() != Model.FileExtension) { filePath += "." + Model.FileExtension; } var model = InteractiveContext.Current.Document; if (model.SaveToFile(filePath)) { AddToMruList(model.FilePath); return(true); } else { ErrorDialogs.CannotSaveFile(dlg.FileName); } } return(false); }
//-------------------------------------------------------------------------------------------------- public bool SaveModel() { var model = InteractiveContext.Current.Document; if (model.FilePath.IsNullOrEmpty()) { return(SaveModelAs()); } else { if (model.Save()) { AddToMruList(model.FilePath); return(true); } ErrorDialogs.CannotSaveFile(model.FilePath); } return(false); }