示例#1
0
 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);
     }
 }
示例#2
0
 private void RemoveChildNodes(ProjectTreeNode node, bool onlyCollapsed = false)
 {
     ProjectTreeNode[] projectTreeNodes = node.Nodes.OfType <ProjectTreeNode>().ToArray();
     foreach (ProjectTreeNode childNode in projectTreeNodes)
     {
         RemoveNode(childNode, onlyCollapsed);
     }
 }
示例#3
0
        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);
                }
            }
        }
示例#4
0
        public IProjectFile FindFile(string fileSystemPath)
        {
            ProjectTreeNode treeNode = _nodes.FirstOrDefault(x => x.FileSystemPath.Equals(fileSystemPath, StringComparison.OrdinalIgnoreCase));

            if (treeNode == null)
            {
                return(null);
            }
            treeNode.EnsureVisible();
            treeViewSolution.SelectedNode = treeNode;
            return(treeNode.ProjectItem as IProjectFile);
        }
示例#5
0
        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);
        }
示例#6
0
        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();
            }
        }
示例#7
0
 public void ExpandTreeNodes(IEnumerable <string> fileSystemPaths)
 {
     if (fileSystemPaths == null)
     {
         return;
     }
     foreach (string fileSystemPath in fileSystemPaths)
     {
         string          path     = fileSystemPath;
         ProjectTreeNode treeNode =
             _nodes.FirstOrDefault(x => x.FileSystemPath.Equals(path, StringComparison.OrdinalIgnoreCase));
         if (treeNode == null)
         {
             continue;
         }
         treeNode.Expand();
     }
 }
示例#8
0
        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;
        }
示例#9
0
        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);
        }
示例#10
0
        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;
            }
        }