public void Projects_Are_Sorted_By_Priority_In_Tree()
        {
            var fixture   = new Fixture();
            var treeView  = new TreeView();
            var treeUtils = new TreeUtils(treeView);
            var projects  = new List <ProjectTreeNode>();
            var projectWithLowPriorityAndTitleStartingWithA = new ProjectTreeNode(fixture.Create <string>(), "ABC",
                                                                                  fixture.Create <DateTime>().ToString(), ProjectPriority.Low.DisplayName, 0);
            var projectWithLowPriorityAndTitleStartingWithB = new ProjectTreeNode(fixture.Create <string>(), "BC",
                                                                                  fixture.Create <DateTime>().ToString(), ProjectPriority.Low.DisplayName, 0);
            var projectWithMediumPriority = new ProjectTreeNode(fixture.Create <string>(), fixture.Create <string>(),
                                                                fixture.Create <DateTime>().ToString(), ProjectPriority.Medium.DisplayName, 0);
            var projectWithNoPriority = new ProjectTreeNode(fixture.Create <string>(), fixture.Create <string>(),
                                                            fixture.Create <DateTime>().ToString(), ProjectPriority.None.DisplayName, 0);

            projects.Add(projectWithLowPriorityAndTitleStartingWithA);
            projects.Add(projectWithLowPriorityAndTitleStartingWithB);
            projects.Add(projectWithMediumPriority);
            projects.Add(projectWithNoPriority);

            treeUtils.PopulateTreeByProjectPriority(projects);

            TreeNodeCollection nodes = treeView.Nodes;

            Assert.That(nodes[0].Text, Is.EqualTo(projectWithMediumPriority.Title));
            Assert.That(nodes[1].Text, Is.EqualTo(projectWithLowPriorityAndTitleStartingWithA.Title));
            Assert.That(nodes[2].Text, Is.EqualTo(projectWithLowPriorityAndTitleStartingWithB.Title));
            Assert.That(nodes[3].Text, Is.EqualTo(projectWithNoPriority.Title));
        }
        private void LoadProjects(ProjectInfo project)
        {
            var workspace = GetProjectWorkspace(project);

            if (workspace == null)
            {
                workspace = new ProjectTreeNode(project);
                Projects.Add(workspace);

                var contentFolder = Path.Combine(project.ProjectFolderPath, "Content");
                if (Directory.Exists(contentFolder))
                {
                    workspace.Content = new MainContentTreeNode(workspace, ContentFolderType.Content, contentFolder);
                    workspace.Content.Folder.ParentFolder = workspace.Folder;
                }

                var sourceFolder = Path.Combine(project.ProjectFolderPath, "Source");
                if (Directory.Exists(sourceFolder))
                {
                    workspace.Source = new MainContentTreeNode(workspace, ContentFolderType.Source, sourceFolder);
                    workspace.Source.Folder.ParentFolder = workspace.Folder;
                }
            }

            foreach (var reference in project.References)
            {
                LoadProjects(reference.Project);
            }
        }
Exemple #3
0
        //得到当前工程树中的未分配根节点
        private ProjectTreeNode getUnassignedNode()
        {
            Document doc  = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            var      tree = Project.Instance.GetProjectTree(doc);

            var unassignedNode = tree.Find((node) =>
            {
                if (node.Path == "未分配")
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            });

            if (unassignedNode == null)
            {
                unassignedNode = new ProjectTreeNode("未分配", null);
                tree.Add(unassignedNode);
            }

            return(unassignedNode);
        }
Exemple #4
0
        private bool IsNodeVisible(ProjectTreeNode projectNode)
        {
            if (SelectedView == NavigationViewMode.All)
            {
                return(true);
            }

            var rootNode       = projectNode.RootNode ?? projectNode;
            var collectionNode = rootNode as ProjectCollectionNode;

            switch (SelectedView)
            {
            case NavigationViewMode.All:
                break;

            case NavigationViewMode.Surfaces:
                return(collectionNode != null && collectionNode.Collection == CurrentProject.Surfaces);

            case NavigationViewMode.Collisions:
                return(collectionNode != null && collectionNode.Collection == CurrentProject.Collisions);

            case NavigationViewMode.Connections:
                return(collectionNode != null && collectionNode.Collection == CurrentProject.Connections);

            case NavigationViewMode.Bones:
                return(collectionNode != null && collectionNode.Collection == CurrentProject.Bones);

            case NavigationViewMode.Meshes:
                return(collectionNode != null && collectionNode.Collection == CurrentProject.Meshes);
            }

            return(false);
        }
Exemple #5
0
        private ProjectTreeNode GetFirstVisibleParentNode(ProjectTreeNode projectNode)
        {
            if (!IsNodeVisible(projectNode))
            {
                return(projectNode);
            }

            var treeViewItem = ProjectTreeView.ModelToItem(projectNode);

            if (treeViewItem != null)
            {
                return(projectNode);
            }

            while (projectNode?.Parent != null)
            {
                treeViewItem = ProjectTreeView.ModelToItem(projectNode.Parent);
                if (treeViewItem != null)
                {
                    return(projectNode.Parent);
                }

                projectNode = projectNode.Parent;
            }

            return(projectNode);
        }
Exemple #6
0
        private TreeListNode getTreeListNode(ProjectTreeNode node)
        {
            List <ProjectTreeNode> tree = treeList1.DataSource as List <ProjectTreeNode>;
            //之前的当前工作面在treelist中的节点索引值
            int index = tree.IndexOf(node);

            return(treeList1.GetNodeByVisibleIndex(index));
        }
Exemple #7
0
 //改变一个节点时,更改它的所有子节点的父节点路径值
 private void changeParentNode(ProjectTreeNode pNode)
 {
     foreach (var child in pNode.Children)
     {
         child.SetParentNode(pNode);
         changeParentNode(child);
     }
 }
        public async Task <long> AddProjectTreeNode(ProjectTreeNode projectTreeNode)
        {
            var ae = await _context.ProjectTree.AddAsync(projectTreeNode);

            await _context.SaveChangesAsync();

            return(ae.Entity.ProjectTreeNodeID);
        }
        private void _ProjectTree_ItemDrag(object sender, ItemDragEventArgs e)
        {
            ProjectTreeNode node = ((ProjectTreeNode)e.Item);

            if (node.NodeType != ProjectTreeNode.NodeTypes.Invalid && node.NodeType != ProjectTreeNode.NodeTypes.Project)
            {
                DoDragDrop(e.Item, DragDropEffects.Move);
            }
        }
Exemple #10
0
        //点击右键菜单“添加”触发
        private void t1AddChild_ItemClick(object sender, EventArgs e)
        {
            var tree      = treeList1.DataSource as List <ProjectTreeNode>;
            var focusNode = treeList1.FocusedNode;
            var pNode     = getProjectNode(focusNode);

            string halfName = "";

            if (focusNode.Level == 0)
            {
                halfName = "水平";
            }
            else if (focusNode.Level == 1)
            {
                halfName = "采区";
            }
            else if (focusNode.Level == 2)
            {
                halfName = "工作面";
            }

            //准备一个初始化的名字
            int    i    = 1;
            string name = "";

            while (true)
            {
                var tmp = pNode.Children.Find((node) =>
                {
                    if (node.Name == halfName + i.ToString())
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                });
                if (tmp != null)
                {
                    i++;
                }
                else
                {
                    name = halfName + i.ToString();
                    break;
                }
            }

            ProjectTreeNode newNode = new ProjectTreeNode(name, pNode);

            pNode.Children.Add(newNode);
            tree.Add(newNode);
            treeList1.RefreshDataSource();

            focusNode.Expand();
        }
 private List <ProjectTreeNode> LoadAllProjectTreeNodeChilds(ProjectTreeNode ptn)
 {
     ptn.Childs = _context.ProjectTree.Where(e => e.ParentProjectTreeNodeID == ptn.ProjectTreeNodeID).ToList();
     foreach (var c in ptn.Childs)
     {
         c.Childs = LoadProjectTreeNodeChilds(c);
     }
     return(ptn.Childs.ToList());
 }
        private void LoadProjectTreeNodeEntitys(ProjectTreeNode ptn, ref List <string> entNames)
        {
            entNames.Add(ptn.Name);
            ptn.Childs = LoadProjectTreeNodeChilds(ptn);

            foreach (var c in ptn.Childs)
            {
                entNames.Add(c.Name);
                LoadProjectTreeNodeEntitys(c, ref entNames);
            }
        }
        void AddDefaultProjectNode()
        {
            _ProjectTree.Nodes.Clear();
            LoadProjectImageList();
            ProjectTreeNode node = new ProjectTreeNode();

            node.NodeType = ProjectTreeNode.NodeTypes.Invalid;
            node.SetImage(ProjectTreeNode.NodeTypes.Project);
            node.Text = "<no project loaded>";
            _ProjectTree.Nodes.Add(node);
        }
 private ProjectTreeNode FindDefaultRunProjectFile()
 {
     foreach (TreeNode node in _ProjectTree.Nodes)
     {
         ProjectTreeNode foundNode = FindDefaultRunProjectFile(node);
         if (foundNode != null)
         {
             return(foundNode);
         }
     }
     return(null);
 }
 private void SetAttributeValue(ProjectTreeNode node, string propertyName, string value)
 {
     if (propertyName == "Name")
     {
         node.Text = value;
     }
     else if (propertyName == "Type")
     {
         node.NodeType         = (ProjectTreeNode.NodeTypes)Enum.Parse(typeof(ProjectTreeNode.NodeTypes), value);
         node.ImageKey         = ProjectTreeNode.GetNodeTypeImageKey(node.NodeType);
         node.SelectedImageKey = node.ImageKey;
     }
 }
        ProjectTreeNode AddExstingDirectory(DirectoryInfo source, DirectoryInfo target, ProjectTreeNode parentNode, bool recursive)
        {
            ProjectTreeNode node = null;

            string targetName = target.Name;

            foreach (ProjectTreeNode child in parentNode.Nodes)
            {
                if (child.Text.ToLower() == targetName.ToLower())
                {
                    node = child;
                    break;
                }
            }

            if (node == null)
            {
                node = parentNode.AddFolder(targetName);
            }

            // Check if the target directory exists, if not, create it.
            if (Directory.Exists(target.FullName) == false)
            {
                Directory.CreateDirectory(target.FullName);
            }

            // Copy each file into it’s new directory.
            foreach (FileInfo fi in source.GetFiles())
            {
                string targetFile = Path.Combine(target.ToString(), fi.Name);

                node.AddFile(fi.Name);

                if (!System.IO.File.Exists(targetFile))
                {
                    fi.CopyTo(targetFile, false);
                }
            }

            if (recursive)
            {
                // Copy each subdirectory using recursion.
                foreach (DirectoryInfo diSourceSubDir in source.GetDirectories())
                {
                    DirectoryInfo nextTargetSubDir = target.CreateSubdirectory(diSourceSubDir.Name);
                    AddExstingDirectory(diSourceSubDir, nextTargetSubDir, node, recursive);
                }
            }

            return(node);
        }
 public bool SaveProjectFile()
 {
     if (IsProjectOpen())
     {
         ProjectTreeNode projectNode = GetProjectNode();
         XmlTextWriter   textWriter  = new XmlTextWriter(ProjectFileName, System.Text.Encoding.ASCII);
         textWriter.WriteStartDocument();
         textWriter.WriteStartElement("Project");
         SaveNodes(_ProjectTree.Nodes, textWriter);
         textWriter.WriteEndElement();
         textWriter.Close();
     }
     return(true);
 }
Exemple #18
0
        //设置当前的工作面
        public void setCurrentSurface(Document doc, ProjectTreeNode node)
        {
            string          projectID   = GetDwgId(doc);
            ProjectTreeNode workingNode = null;

            currentWorkingSurfaces.TryGetValue(projectID, out workingNode);
            if (workingNode == null)
            {
                currentWorkingSurfaces.Add(projectID, node);
            }
            else
            {
                currentWorkingSurfaces[projectID] = node;
            }
        }
Exemple #19
0
        //获取当前的工作面
        public ProjectTreeNode getCurrentSurface(Document doc)
        {
            string          projectID   = GetDwgId(doc);
            ProjectTreeNode workingNode = null;

            currentWorkingSurfaces.TryGetValue(projectID, out workingNode);
            if (workingNode == null)
            {
                return(null);
            }
            else
            {
                return(currentWorkingSurfaces[projectID]);
            }
        }
Exemple #20
0
        //删除隐藏的工作面
        public bool remmoveHiddenSurface(Document doc, ProjectTreeNode node)
        {
            string projectID = GetDwgId(doc);
            List <ProjectTreeNode> hiddenNodes = null;

            hiddenWorkingSurfaces.TryGetValue(projectID, out hiddenNodes);
            if (hiddenNodes == null)
            {
                return(false);
            }
            else
            {
                return(hiddenWorkingSurfaces[projectID].Remove(node));
            }
        }
 private void SaveNodes(TreeNodeCollection nodesCollection, XmlTextWriter textWriter)
 {
     for (int i = 0; i < nodesCollection.Count; i++)
     {
         ProjectTreeNode node = (ProjectTreeNode)nodesCollection[i];
         textWriter.WriteStartElement("node");
         textWriter.WriteAttributeString("Name", node.Text);
         textWriter.WriteAttributeString("Type", node.NodeType.ToString());
         if (node.Nodes.Count > 0)
         {
             SaveNodes(node.Nodes, textWriter);
         }
         textWriter.WriteEndElement();
     }
 }
Exemple #22
0
        public void RefreshNavigationNode(ProjectTreeNode node)
        {
            if (IsRefreshingAll)
            {
                return;
            }

            ExecuteOnThread(() =>
            {
                if (IsRefreshingAll)
                {
                    return;
                }
                ProjectTreeView.RefreshObject(node);
            });
        }
Exemple #23
0
        private void LoadTreeView()
        {
            using (new Wait())
            {
                ToggleUI(false);

                ProjectTreeNode projectNode = new ProjectTreeNode(ProjectContext.Project);

                projectTreeview.Nodes.Clear();
                projectNode.TemplateGenerateClicked += new TemplateTreeNode.GenerateEventHandler((s, e) => GenerateTemplate(((TemplateTreeNode)s).Template, e.AutoGenerate));
                projectNode.NewConnectionClicked    += ProjectNode_NewConnectionClicked;
                projectNode.ConnectionDeleteClicked += ProjectNode_ConnectionDeleteClicked;
                projectTreeview.Nodes.Add(projectNode);

                ToggleUI(true);
            }
        }
        public void Project_Does_Already_Exist()
        {
            using (var session = DocumentStore.OpenSession())
            {
                var projectId       = Fixture.Create <ProjectId>();
                var projectTreeNode = new ProjectTreeNode(projectId, _title, Fixture.Create <DateTime>().ToShortDateString(),
                                                          ProjectPriority.Low.DisplayName, 0);
                session.Store(projectTreeNode);
                session.SaveChanges();
            }

            var  doesProjectWithTitleExistQuery = new DoesProjectWithTitleExistQuery(_title);
            var  projectQueryService            = new ProjectQueryService();
            bool doesProjectExist = projectQueryService.Handle(doesProjectWithTitleExistQuery);

            Assert.That(doesProjectExist, Is.True);
        }
        private ProjectTreeNode FindDefaultRunProjectFile(TreeNode node)
        {
            if (((ProjectTreeNode)node).IsStartupObject)
            {
                return((ProjectTreeNode)node);
            }

            foreach (ProjectTreeNode n in node.Nodes)
            {
                ProjectTreeNode foundNode = FindDefaultRunProjectFile(n);
                if (foundNode != null)
                {
                    return(foundNode);
                }
            }
            return(null);
        }
        private TreeNode Wrap(Project project)
        {
            TreeNode tn = new ProjectTreeNode(project);

            foreach (File f in project.Files)
            {
                if (f is Folder)
                {
                    tn.Nodes.Add(this.Wrap(f as Folder));
                }
                else
                {
                    tn.Nodes.Add(new FileTreeNode(f));
                }
            }
            return(tn);
        }
Exemple #27
0
        //设置隐藏的工作面
        public void setHiddenSurface(Document doc, ProjectTreeNode node)
        {
            string projectID = GetDwgId(doc);
            List <ProjectTreeNode> hiddenNodes = null;

            hiddenWorkingSurfaces.TryGetValue(projectID, out hiddenNodes);
            if (hiddenNodes == null)
            {
                var nodes = new List <ProjectTreeNode>();
                nodes.Add(node);
                hiddenWorkingSurfaces.Add(projectID, nodes);
            }
            else
            {
                hiddenWorkingSurfaces[projectID].Add(node);
            }
        }
Exemple #28
0
 //得到某个节点的所有子叶节点
 private void getLeafNodes(ProjectTreeNode node, List <ProjectTreeLeafNode> ls)
 {
     if (node == null)
     {
         return;
     }
     if (node is ProjectTreeLeafNode)
     {
         ls.Add(node as ProjectTreeLeafNode);
     }
     else
     {
         foreach (var cNode in node.Children)
         {
             getLeafNodes(cNode, ls);
         }
     }
 }
Exemple #29
0
        public void Projects_With_Same_Priority_Are_Sorted_On_Title()
        {
            var    fixture   = new Fixture();
            var    sorter    = new Sorter();
            string deadline  = DateTime.UtcNow.ToString();
            var    node1     = new ProjectTreeNode(fixture.Create <string>(), "abc", deadline, ProjectPriority.None.DisplayName, 0);
            var    node2     = new ProjectTreeNode(fixture.Create <string>(), "abb", deadline, ProjectPriority.Medium.DisplayName, 0);
            var    node3     = new ProjectTreeNode(fixture.Create <string>(), "aad", deadline, ProjectPriority.High.DisplayName, 0);
            var    treeNodes = new List <ProjectTreeNode> {
                node1, node2, node3
            };

            var sortedTreeNodes = sorter.ByPriority(treeNodes);

            Assert.That(sortedTreeNodes[0].Title, Is.EqualTo("aad"));
            Assert.That(sortedTreeNodes[1].Title, Is.EqualTo("abb"));
            Assert.That(sortedTreeNodes[2].Title, Is.EqualTo("abc"));
        }
        public void Can_Retrieve_All_Projects()
        {
            var fixture = new Fixture();

            using (var session = DocumentStore.OpenSession())
            {
                string id = fixture.Create <Guid>().ToString();
                var    projectTreeNode = new ProjectTreeNode(id, fixture.Create <string>(), fixture.Create <DateTime>().ToShortDateString(),
                                                             ProjectPriority.Medium.DisplayName, 0);
                session.Store(projectTreeNode);
                session.SaveChanges();
            }

            var projectTreeViewQueryHandler         = new ProjectTreeViewQueryHandler();
            var allProjectTreeNodesQuery            = new AllProjectTreeNodesQuery();
            List <ProjectTreeNode> projectTreeNodes = projectTreeViewQueryHandler.Handle(allProjectTreeNodesQuery);

            Assert.That(projectTreeNodes.Count, Is.EqualTo(1));
        }
Exemple #31
0
 private void AddNewItem(ProjectTreeNode parentNode, ProjectItem newItem)
 {
     TreeNodeCollection nodes = parentNode.Nodes;
     if ((nodes.Count == 1) && (nodes[0].GetType() == typeof(TreeNode)))
     {
         parentNode.Expand();
         this._treeView.SelectedNode = newItem.ItemNode;
     }
     else
     {
         ProjectTreeNode node = this.CreateProjectTreeNode(newItem, newItem is FolderProjectItem);
         IComparer projectItemComparer = newItem.Project.ProjectItemComparer;
         if (projectItemComparer == null)
         {
             nodes.Add(node);
         }
         else
         {
             int index = 0;
             while (index < nodes.Count)
             {
                 if (projectItemComparer.Compare(newItem, ((ProjectTreeNode) nodes[index]).ProjectItem) < 0)
                 {
                     break;
                 }
                 index++;
             }
             nodes.Insert(index, node);
         }
         this._treeView.SelectedNode = node;
     }
     this._treeView.SelectedNode.EnsureVisible();
 }
        /// <summary>
        /// Create the project tree.
        /// Add the project file and directory on path to node TreeNode.
        /// </summary>
        /// <param name="node">The current TreeNode.</param>
        /// <param name="path">The current path.</param>
        public void CreateProjectTreeView(TreeNode node, string path)
        {
            if (!Directory.Exists(path))
                return;

            if (node == null)
            {
                node = new ProjectTreeNode(path);
                PrjTreeView.Nodes.Add(node);
                node.Expand();
            }

            // Check project.xml and load.
            try
            {
                SetProjectNode(node, path);
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.ToString());
                return;
            }

            // Create Directory node.
            string[] dirs = Directory.GetDirectories(path);
            foreach (string dir in dirs)
            {
                if (Util.IsIgnoredDir(dir) || Util.IsHidden(dir))
                    continue;

                ProjectTreeNode childNode = new ProjectTreeNode(dir);
                node.Nodes.Add(childNode);

                CreateProjectTreeView(childNode, dir);
            }
        }
 private bool IsCompositChildNode(ProjectTreeNode treeNode)
 {
     ProjectTreeNode node = treeNode;
     while (node != null && node.Parent != null)
     {
         if (node.ProjectItem is CompositFile) return true;
         node = node.Parent as ProjectTreeNode;
     }
     return false;
 }
        /// <summary>
        /// Event to click the node by mouse.
        /// </summary>
        /// <param name="sender">TreeView.</param>
        /// <param name="e">TreeNodeMouseClickEventArgs.</param>
        private void NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            TreeView tView = (TreeView)sender;
            m_selectedNode = (ProjectTreeNode)tView.GetNodeAt(e.X, e.Y);
            tView.SelectedNode = m_selectedNode;

            // Reset selected project if project is null.
            if (m_selectedNode.Project == null)
                ResetSelectedProject();
            else
                SetSelectedProject();
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 /// <param name="path"></param>
 private void SetProjectNode(TreeNode node, string path)
 {
     string prjXMLFileName = Path.Combine(path, Constants.fileProjectXML);
     string prjInfoFileName = Path.Combine(path, Constants.fileProjectInfo);
     if (File.Exists(prjXMLFileName))
     {
         if (!IsExistModelFile(path))
             return;
         TreeNode childNode = new ProjectTreeNode(prjXMLFileName);
         node.Nodes.Add(childNode);
     }
     else if (File.Exists(prjInfoFileName))
     {
         if (!IsExistModelFile(path))
             return;
         TreeNode childNode = new ProjectTreeNode(prjInfoFileName);
         node.Nodes.Add(childNode);
     }
     // Create eml node.
     else if (path.Length < 248)
     {
         string[] files = Directory.GetFiles(path, "*.eml");
         foreach (string file in files)
         {
             TreeNode childNode = new ProjectTreeNode(file);
             node.Nodes.Add(childNode);
         }
     }
 }
Exemple #36
0
 private void OpenNode(ProjectTreeNode node)
 {
     DocumentProjectItem projectItem = (DocumentProjectItem) node.ProjectItem;
     try
     {
         projectItem.Project.OpenProjectItem(projectItem, false, DocumentViewType.Default);
     }
     catch (Exception)
     {
     }
 }
        private void RefreshCompositFileNode(ProjectTreeNode projectTreeNode)
        {
            if (projectTreeNode == null) return;
            if (!Directory.Exists(projectTreeNode.FileSystemPath)) return;
            if (InvokeRequired)
            {
                BeginInvoke(new Action<ProjectTreeNode>(RefreshCompositFileNode), projectTreeNode);
                return;
            }

            ProjectTreeNode childNode;

            string fileSystemPath = projectTreeNode.FolderPath;
            foreach (string subFolder in Directory.GetDirectories(fileSystemPath))
            {
                childNode =
                    projectTreeNode.Nodes.OfType<ProjectTreeNode>().FirstOrDefault(
                        x => x.FileSystemPath.Equals(subFolder, StringComparison.OrdinalIgnoreCase));
                if (childNode == null)
                {
                    childNode =
                        new ProjectTreeNode(new ProjectFolder(subFolder, true, projectTreeNode.ProjectItem.Project),
                                            _iconManager);
                    _nodes.Add(childNode);
                    projectTreeNode.Nodes.Add(childNode);
                }
            }
            foreach (string file in Directory.GetFiles(fileSystemPath))
            {
                childNode =
                    projectTreeNode.Nodes.OfType<ProjectTreeNode>().FirstOrDefault(
                        x => x.FileSystemPath.Equals(file, StringComparison.OrdinalIgnoreCase));

                if (childNode == null)
                {
                    string extension = (Path.GetExtension(file) ?? "").ToUpperInvariant();
                    IProjectFile projectFile;
                    if (CrcsProject.BinaryExtensions.Contains(extension) || FileUtility.IsBinary(file))
                    {
                        projectFile = new BinaryFile(file, true, null);
                    }
                    else
                    {
                        projectFile = new TextFile(file, true, null);
                    }
                    childNode = new ProjectTreeNode(projectFile, _iconManager);
                    _nodes.Add(childNode);
                    projectTreeNode.Nodes.Add(childNode);
                }
            }
        }
Exemple #38
0
 private void OnDragDropTreeView(object sender, DragEventArgs e)
 {
     Point p = new Point(e.X, e.Y);
     p = this._treeView.PointToClient(p);
     ProjectTreeNode nodeAt = this._treeView.GetNodeAt(p) as ProjectTreeNode;
     e.Effect = nodeAt.ProjectItem.Project.HandleProjectItemDragDrop(nodeAt.ProjectItem, e.Data);
     if (e.Effect != DragDropEffects.None)
     {
         if (this._dragNode != null)
         {
             this._dropNode = nodeAt;
         }
         else
         {
             this.RefreshNode(nodeAt);
         }
     }
 }
Exemple #39
0
 private void AddFolder(ProjectTreeNode node)
 {
     FolderProjectItem projectItem = (FolderProjectItem) node.ProjectItem;
     FolderProjectItem newItem = null;
     try
     {
         newItem = projectItem.AddFolder();
     }
     catch (Exception exception)
     {
         ((IMxUIService) base.ServiceProvider.GetService(typeof(IMxUIService))).ReportError(exception.Message, "Add Folder", false);
     }
     if (newItem != null)
     {
         this.AddNewItem(node, newItem);
     }
 }
 public void SetSolution(CrcsSolution solution)
 {
     treeViewSolution.Nodes.Clear();
     _nodes.Clear();
     _solution = solution;
     if (solution == null)
     {
         _solutionNode = null;
         return;
     }
     _solutionNode = new ProjectTreeNode(_solution);
     _nodes.Add(_solutionNode);
     var propNode = new TreeNode("Properties", 6, 6) {Tag = _solution};
     _solutionNode.Nodes.Add(propNode);
     treeViewSolution.Nodes.Add(_solutionNode);
     _solution.TreeNode = _solutionNode;
 }
Exemple #41
0
 private void DeleteNode(ProjectTreeNode node)
 {
     ProjectItem projectItem = node.ProjectItem;
     if (projectItem is RootProjectItem)
     {
         IProjectManager manager = (IProjectManager) this.GetService(typeof(IProjectManager));
         if (manager != null)
         {
             manager.CloseProject(projectItem.Project);
         }
     }
     else
     {
         IMxUIService service = (IMxUIService) base.ServiceProvider.GetService(typeof(IMxUIService));
         if (service.ShowMessage("Are you sure you want to delete '" + projectItem.Caption + "'?", "Delete Workspace Item", MessageBoxIcon.Question, MessageBoxButtons.YesNo, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
         {
             if (projectItem.Delete())
             {
                 ProjectTreeNode parent = (ProjectTreeNode) node.Parent;
                 if (parent != null)
                 {
                     parent.Nodes.Remove(node);
                 }
                 else
                 {
                     this._treeView.Nodes.Remove(node);
                 }
             }
             else
             {
                 service.ReportError("Unable to delete '" + projectItem.Caption + ".'\r\nCheck that the document or folder can be deleted.", "Delete Workspace Item", true);
             }
         }
     }
 }
 private void RemoveNode(ProjectTreeNode node, bool onlyCollapsed = false)
 {
     if (node == null) return;
     if (!onlyCollapsed || !node.IsExpanded)
     {
         if (_nodes.Contains(node)) _nodes.Remove(node);
         if (node.TreeView != null) node.Remove();
         if (node.ProjectItem != null) node.ProjectItem.TreeNode = null;
     }
     if (node.Nodes.Count > 0) RemoveChildNodes(node, onlyCollapsed);
 }
Exemple #43
0
 private void OnItemDragTreeView(object sender, ItemDragEventArgs e)
 {
     ProjectTreeNode item = (ProjectTreeNode) e.Item;
     if (item.ProjectItem.IsDragSource)
     {
         ProjectTreeNode parent = (ProjectTreeNode) item.Parent;
         try
         {
             this._dragNode = item;
             DragDropEffects effects = base.DoDragDrop(item.ProjectItem.GetDataObject(), DragDropEffects.Move | DragDropEffects.Copy);
             if (this._dropNode != null)
             {
                 if (effects == DragDropEffects.Move)
                 {
                     parent.Nodes.Remove(item);
                 }
                 this.RefreshNode(this._dropNode);
             }
         }
         finally
         {
             this._dragNode = null;
             this._dropNode = null;
         }
     }
 }
 private void RemoveChildNodes(ProjectTreeNode node, bool onlyCollapsed = false)
 {
     ProjectTreeNode[] projectTreeNodes = node.Nodes.OfType<ProjectTreeNode>().ToArray();
     foreach (ProjectTreeNode childNode in projectTreeNodes)
     {
         RemoveNode(childNode, onlyCollapsed);
     }
 }
Exemple #45
0
 private void RefreshNode(ProjectTreeNode node)
 {
     ProjectItem projectItem = node.ProjectItem;
     projectItem.Refresh();
     try
     {
         this._treeView.BeginUpdate();
         if (node.IsExpanded || (node.Nodes.Count == 0))
         {
             node.Nodes.Clear();
             ProjectItemCollection childItems = projectItem.ChildItems;
             if ((childItems != null) && (childItems.Count != 0))
             {
                 foreach (ProjectItem item2 in childItems)
                 {
                     ProjectTreeNode node2 = this.CreateProjectTreeNode(item2, true);
                     node.Nodes.Add(node2);
                 }
             }
         }
         node.Expand();
     }
     finally
     {
         this._treeView.EndUpdate();
     }
 }
        public override void Refresh()
        {
            if (_solution == null || _solutionNode == null) return;
            if (InvokeRequired)
            {
                BeginInvoke(new Action(Refresh));
                return;
            }
            base.Refresh();

            ProjectTreeNode projectTreeNode;
            _solutionNode.Text = _solution.Name;
            foreach (CrcsProject proj in _solution.Projects)
            {
                projectTreeNode = proj.TreeNode;
                if (projectTreeNode == null)
                {
                    projectTreeNode = new ProjectTreeNode(proj);
                    _nodes.Add(projectTreeNode);
                    var propNode = new TreeNode("Properties", 6, 6) {Tag = proj};
                    projectTreeNode.Nodes.Add(propNode);
                    _solutionNode.Nodes.Add(projectTreeNode);
                    proj.TreeNode = projectTreeNode;
                }
                projectTreeNode.RefreshIcon();
                RefreshProjectNode(projectTreeNode);
            }
            foreach (string missingProj in _solution.MissingProjects)
            {
                if (ProjectNodes.FirstOrDefault(x => x.FileSystemPath == missingProj) != null) continue;
                projectTreeNode = new ProjectTreeNode(new MissingItem(missingProj, true, null), _iconManager);
                _nodes.Add(projectTreeNode);
                _solutionNode.Nodes.Add(projectTreeNode);
            }
            if (!_solutionNode.IsExpanded)
            {
                _solutionNode.Expand();
            }
        }
 public CrcsProject GetProject(ProjectTreeNode treeNode)
 {
     ProjectTreeNode node = treeNode;
     if (node == null) return null;
     CrcsProject proj = null;
     while (node.Parent != null)
     {
         proj = node.ProjectItem as CrcsProject;
         if (proj != null) return proj;
         node = node.Parent as ProjectTreeNode;
     }
     return proj;
 }
        public void RefreshProjectNode(ProjectTreeNode rootNode)
        {
            if (rootNode == null) return;
            if (!Directory.Exists(rootNode.ParentFolder)) return;
            if (InvokeRequired)
            {
                BeginInvoke(new Action<ProjectTreeNode>(RefreshProjectNode), rootNode);
                return;
            }

            CrcsProject rsproj = GetProject(rootNode);
            var folderStack = new Stack<ProjectTreeNode>();
            folderStack.Push(rootNode);
            int index = 1;
            while (folderStack.Count > 0)
            {
                ProjectTreeNode childNode;
                ProjectTreeNode node = folderStack.Pop();

                string fileSystemPath = node.FolderPath;
                foreach (string subFolder in Directory.GetDirectories(fileSystemPath))
                {
                    if (FolderUtility.IsSystemFolder(subFolder)) continue;
                    string name = Path.GetFileName(subFolder);
                    if (name == ".rsproj") continue;
                    bool isFolderIncluded = rsproj.IsFolderIncluded(subFolder);

                    childNode = node.Nodes.OfType<ProjectTreeNode>().FirstOrDefault(x => x.Text == name);
                    if (!isFolderIncluded && !ShowExcludedItems)
                    {
                        if (childNode != null) RemoveNode(childNode);
                        continue;
                    }
                    if (childNode == null)
                    {
                        childNode = new ProjectTreeNode(new ProjectFolder(subFolder, isFolderIncluded, rsproj),
                                                        _iconManager);
                        _nodes.Add(childNode);
                        node.Nodes.Insert(index, childNode);
                    }
                    else
                    {
                        childNode.IsIncluded = isFolderIncluded;
                        childNode.RefreshIcon();
                    }
                    index++;
                    folderStack.Push(childNode);
                }
                foreach (IProjectItem projectFile in rsproj.GetProjectFiles(fileSystemPath))
                {
                    childNode = projectFile.TreeNode;

                    if (!projectFile.IsIncluded && (!ShowExcludedItems || projectFile.IsDeleted || !projectFile.Exists))
                    {
                        if (childNode != null) RemoveNode(childNode);
                        if (!projectFile.IsIncluded && !projectFile.Exists) rsproj.RemoveMissingItem(projectFile.FileSystemPath);
                        continue;
                    }
                    if (childNode == null)
                    {
                        childNode = new ProjectTreeNode(projectFile, _iconManager);
                        _nodes.Add(childNode);
                        node.Nodes.Insert(index, childNode);
                    }
                    else
                    {
                        if (!projectFile.IsIncluded)
                        {
                            RemoveChildNodes(childNode);
                        }
                        childNode.RefreshIcon();
                    }
                    index++;
                    if (!projectFile.IsIncluded) continue;
                    var compositFile = projectFile as CompositFile;
                    if (compositFile == null) continue;
            //                    compositFile.TreeNode.Collapse();
                    if (compositFile.IsDeCompiled)
                    {
                        if (compositFile.ClassesTreeNode == null)
                        {
                            var projectTreeNode =
                                new ProjectTreeNode(new ProjectFolder(compositFile.ClassesFolder, true, rsproj),
                                                    _iconManager);
                            _nodes.Add(projectTreeNode);
                            childNode.Nodes.Add(projectTreeNode);
                        }
                        else
                        {
                            foreach (ProjectTreeNode cstChild in compositFile.ClassesTreeNode.Nodes)
                            {
                                RemoveNode(cstChild, true);
                            }
                        }
                    }
                    else if (compositFile.ClassesTreeNode != null)
                    {
                        RemoveNode(compositFile.ClassesTreeNode);
                    }
                    var apkFile = projectFile as ApkFile;
                    if (apkFile == null) continue;
                    if (apkFile.IsDeCoded)
                    {
                        if (apkFile.ResourceTreeNode == null)
                        {
                            var projectTreeNode =
                                new ProjectTreeNode(new ProjectFolder(apkFile.ResourceFolder, true, rsproj),
                                                    _iconManager);
                            _nodes.Add(projectTreeNode);
                            childNode.Nodes.Add(projectTreeNode);
                        }
                        else
                        {
                            foreach (ProjectTreeNode rstChild in apkFile.ResourceTreeNode.Nodes)
                            {
                                RemoveNode(rstChild, true);
                            }
                        }
                    }
                    else if (apkFile.ResourceTreeNode != null)
                    {
                        RemoveNode(apkFile.ResourceTreeNode);
                    }
                }
                index = 0;
            }
        }