private void tsbNewProject_Click(object sender, EventArgs e) { SaveFileDialog sfd = DialogFactory.Instance.GetCreateProjectDialog(); if (sfd.ShowDialog() == DialogResult.OK) { Novel8rProject pro = Novel8rProjectHandler.Instance.NewProject(sfd.FileName); if (pro != null) { presentFiles(pro); } MainPresenter.Instance.OpenPane(MainPresenter.DockedPaneKeys.Files); handleProjectModifiedStatus(); } }
public void OpenProject(string fileName) { Novel8rProject pro = Novel8rProjectHandler.Instance.LoadProject(fileName); if (pro != null) { presentFiles(pro); MainPresenter.Instance.OpenPane(MainPresenter.DockedPaneKeys.Files); handleProjectModifiedStatus(); updateRecentProject(fileName); } else { MessageBox.Show(string.Format("Project could not be loaded: \n{0}", fileName), DialogHelper.Instance.GetApplicationName()); } }
private void presentFiles(Novel8rProject pro) { _view.tvwProject.BeginUpdate(); _view.tvwProject.Nodes.Clear(); var pNode = new ProjectNode(pro.Name, pro.BaseDir); _view.tvwProject.Nodes.Add(pNode); foreach (Sql8rProjectFile file in pro.ProjectFiles) { string relName = file.Path.Replace(pNode.FolderObject.FullName, ""); if (relName.StartsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.OrdinalIgnoreCase)) { relName = relName.Substring(1, relName.Length - 1); } UltraTreeNode parentNode = pNode; if (relName.Contains(Path.DirectorySeparatorChar.ToString())) { IList <string> partlist = relName.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < partlist.Count - 1; i++) { string s = Path.Combine(pNode.FolderObject.FullName, partlist[i]); var di = new DirectoryInfo(s); var foNode = new FolderNode(di); if (!parentNode.Nodes.Exists(foNode.Key)) { parentNode.Nodes.Add(foNode); parentNode = foNode; } else { parentNode = parentNode.Nodes[foNode.Key]; } } } var fiNode = new FileNode(new FileInfo(file.Path)); parentNode.Nodes.Add(fiNode); } foreach (Sql8rProjectFolder folder in pro.ProjectFolders) { string relName = folder.Path.Replace(pNode.FolderObject.FullName, ""); if (relName.StartsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.OrdinalIgnoreCase)) { relName = relName.Substring(1, relName.Length - 1); } UltraTreeNode parentNode = pNode; if (relName.Contains(Path.DirectorySeparatorChar.ToString())) { IList <string> partlist = relName.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < partlist.Count - 1; i++) { string s = Path.Combine(pNode.FolderObject.FullName, partlist[i]); var di = new DirectoryInfo(s); var foNode = new FolderNode(di); if (!parentNode.Nodes.Exists(foNode.Key)) { parentNode.Nodes.Add(foNode); parentNode = foNode; } else { parentNode = parentNode.Nodes[foNode.Key]; } } } var parentFolderNode = new FolderNode(new DirectoryInfo(folder.Path)); if (!parentNode.Nodes.Exists(parentFolderNode.Key)) { parentNode.Nodes.Add(parentFolderNode); } } pNode.Expanded = true; pNode.Selected = true; _view.tvwProject.EndUpdate(); }