public void PerformNewProject() { if (!IsClosed) { return; } string documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string initial = Path.Combine(documents, "SEWorkbench"); bool success = false; try { // TODO Move all IO to a separate class Directory.CreateDirectory(initial); Views.NewProjectDialog view = new Views.NewProjectDialog() { ProjectLocation = initial, }; Nullable <bool> result = view.ShowDialog(); if (result != null && result.Value == true) { string name = view.ProjectName; string filename = String.Format("{0}.seproj", name); string fullpath = Path.Combine(initial, name, filename); Directory.CreateDirectory(Path.GetDirectoryName(fullpath)); ProjectViewModel project = new ViewModels.ProjectViewModel(null); ProjectItem root = new ProjectItem() { Name = name, Type = Models.ProjectItemType.Root, Path = fullpath, Project = project, }; root.Children.Add(new ProjectItem() { Name = "References", Type = ProjectItemType.References }); SetRootItem(root); success = true; } } catch (Exception ex) { MessageBox.ShowError("Unable to create new project", ex); return; } finally { if (success) { CreateNewProjectTemplate(); SaveProject(); RaiseProjectCreated(); } } }
public void PerformNewProject() { if (!IsClosed) { return; } string documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); string initial = Path.Combine(documents, "SEWorkbench"); bool success = false; try { // TODO Move all IO to a separate class Directory.CreateDirectory(initial); Views.NewProjectDialog view = new Views.NewProjectDialog() { ProjectLocation = initial, }; Nullable<bool> result = view.ShowDialog(); if (result != null && result.Value == true) { string name = view.ProjectName; string filename = String.Format("{0}.seproj", name); string fullpath = Path.Combine(initial, name, filename); Directory.CreateDirectory(Path.GetDirectoryName(fullpath)); ProjectViewModel project = new ViewModels.ProjectViewModel(null); ProjectItem root = new ProjectItem() { Name = name, Type = Models.ProjectItemType.Root, Path = fullpath, Project = project, }; root.Children.Add(new ProjectItem() { Name = "References", Type = ProjectItemType.References }); SetRootItem(root); success = true; } } catch (Exception ex) { MessageBox.ShowError("Unable to create new project", ex); return; } finally { if (success) { CreateNewProjectTemplate(); SaveProject(); RaiseProjectCreated(); } } }