public void OnCustomBusinessLogic(object sender, EventArgs e) { // Retrieve the project object. TreeNode tnProject = treProject.SelectedNode; RaveProject proj = (RaveProject)tnProject.Tag; OpenFileDialog frm = new OpenFileDialog(); frm.Title = "Select Riverscapes Business Logic XML"; frm.InitialDirectory = proj.ProjectFile.DirectoryName; frm.Filter = "Riverscapes Business Logic XML files (*.xml)|*.xml"; if (frm.ShowDialog() == DialogResult.OK) { // Remove all the existing child nodes tnProject.Nodes.Clear(); // Re-load the project tree using the selected business logic TreeNode nodProject = proj.LoadTree(tnProject, new System.IO.FileInfo(frm.FileName)); if (nodProject is TreeNode) { AssignContextMenus(nodProject); } } }
public void OnWarehouse(object sender, EventArgs e) { RaveProject proj = (RaveProject)treProject.SelectedNode.Tag; Uri warehouseURL = proj.WarehouseReference; if (warehouseURL is Uri) { System.Diagnostics.Process.Start(warehouseURL.ToString()); } }
public void OnMetaData(object sender, EventArgs e) { RaveProject proj = (RaveProject)treProject.SelectedNode.Tag; MetaData.frmMetaData frm = new MetaData.frmMetaData("Riverscapes Project", proj.MetDataNode); //frm.MetaDataItems.Insert(0, new MetaData.MetaDataItem("Project Name", proj.Name)); //frm.MetaDataItems.Insert(1, new MetaData.MetaDataItem("Project Type", proj.ProjectType)); frm.MetaDataItems.Insert(2, new MetaData.MetaDataItem("Project File", proj.ProjectFile.FullName)); frm.ShowDialog(); }
public void OnRefreshProject(object sender, EventArgs e) { // Retrieve the project object. TreeNode tnProject = treProject.SelectedNode; RaveProject proj = (RaveProject)tnProject.Tag; // Load the project into this same node proj.LoadProjectIntoNode(tnProject); if (tnProject is TreeNode) { AssignContextMenus(tnProject); } }
public void LoadProject(FileInfo projectFile) { // Detect if project is already in tree and simply select the node and return; foreach (TreeNode rootNod in treProject.Nodes) { if (rootNod.Tag is RaveProject && RaveProject.IsSame((RaveProject)rootNod.Tag, projectFile)) { treProject.SelectedNode = rootNod; rootNod.Expand(); return; } } RaveProject newProject = new RaveProject(projectFile); TreeNode tnProject = newProject.LoadNewProject(treProject, cmsProject); tnProject.Text = GetUniqueProjectName(newProject, tnProject.Text); // Load default project view if (Properties.Settings.Default.LoadDefaultProjectView) { try { // Find the default project view among all the tree nodes List <TreeNode> allNodes = new List <TreeNode>(); foreach (TreeNode node in tnProject.Nodes) { RaveProject.GetAllNodes(allNodes, node); } TreeNode nodDefault = allNodes.FirstOrDefault(x => x.Tag is ProjectTree.ProjectView && ((ProjectTree.ProjectView)x.Tag).IsDefaultView); if (nodDefault is TreeNode) { AddChildrenToMap(nodDefault); } } catch (Exception ex) { // Loading the default project view is optional. Do nothing in production System.Diagnostics.Debug.Assert(false, ex.Message); } } AssignContextMenus(tnProject); }
public void LoadProject(FileInfo projectFile) { // Detect if project is already in tree and simply select the node and return; foreach (TreeNode rootNod in treProject.Nodes) { if (rootNod.Tag is RaveProject && RaveProject.IsSame((RaveProject)rootNod.Tag, projectFile)) { treProject.SelectedNode = rootNod; rootNod.Expand(); return; } } RaveProject newProject = new RaveProject(projectFile); TreeNode tnProject = newProject.LoadNewProject(treProject); AssignContextMenus(tnProject); }
/// <summary> /// Get a unique name for a project suitable for use in project tree /// </summary> /// <param name="originalName">The name of the project from the XML</param> /// <returns>If a project with the same name exists in the project tree /// already then this method will return the original name plus a unique suffix</returns> private string GetUniqueProjectName(RaveProject proj, string originalName) { int occurences = 0; foreach (TreeNode nod in treProject.Nodes) { if (nod.Tag is RaveProject && nod.Tag != proj) { if (nod.Text.StartsWith(originalName)) { occurences++; } } } if (occurences > 0) { return(string.Format("{0} Copy {1}", originalName, occurences)); } else { return(originalName); } }
public static bool IsSame(RaveProject proj1, FileInfo projectFile) { return(string.Compare(proj1.ProjectFile.FullName, projectFile.FullName) == 0); }