/// <summary> /// Creates a new project into root folder. /// </summary> private void CreateNewProject() { string MAPWfile = ""; try { string projectFolder = Path.Combine(Model.ProjectLocation, model.NewProjectName); if (model.NewProjectName == null || model.NewProjectName == "") { throw new Exception(); } if (!Directory.Exists(projectFolder)) { Directory.CreateDirectory(projectFolder); } MAPWfile = Path.Combine(projectFolder, model.NewProjectName + ".MAPW"); settingsService.Data = new SettingsDataModel() { RootFolderPath = Path.GetDirectoryName(MAPWfile), DepositType = Model.DepositType }; settingsService.SaveSettings(MAPWfile); // Save only the root path and the deposittype into projects json file. viewModelLocator.SettingsViewModel.WriteLogText("Project '" + model.NewProjectName + "' created into directory: " + projectFolder, "Success"); } catch (Exception ex) { logger.Error(ex, "Failed to create a new project"); dialogService.ShowNotification("Failed to create a new project.", "Error"); viewModelLocator.SettingsViewModel.WriteLogText("Failed to create a new project.", "Error"); } OpenProject(MAPWfile); // Open the created project. newProjectDialog.Close(); }
void c_NewProject(object sender, EventArgs e) { NewProjectDialog newProjectDialogWindow = new NewProjectDialog(); NewProjectEventArgs args = (NewProjectEventArgs)e; var newProjectViewModel = new NewProjectViewModel(args.Project); EventHandler handler = null; handler = delegate { newProjectViewModel.RequestClose -= handler; newProjectDialogWindow.Close(); if (newProjectViewModel.Saved) { viewModel.CreateMainClassWorkspace(); } }; newProjectViewModel.RequestClose += handler; newProjectDialogWindow.DataContext = newProjectViewModel; newProjectDialogWindow.ShowDialog(); }