コード例 #1
0
ファイル: ProjectNodes.cs プロジェクト: masums/Crow
 public void AddChild(ProjectNode pn)
 {
     childNodes.Add(pn);
     pn.Parent = this;
 }
コード例 #2
0
ファイル: ProjectNodes.cs プロジェクト: masums/Crow
 public void RemoveChild(ProjectNode pn)
 {
     pn.Parent = null;
     childNodes.Remove(pn);
 }
コード例 #3
0
        void populateTreeNodes()
        {
            ProjectNode root = new ProjectNode(this, ItemType.VirtualGroup, RootNamespace);
            ProjectNode refs = new ProjectNode(this, ItemType.ReferenceGroup, "References");

            root.AddChild(refs);

            /*Console.ForegroundColor = ConsoleColor.Green;
             * Console.WriteLine ($"Evaluated Globals properties for {DisplayName}");
             * foreach (ProjectProperty item in project.AllEvaluatedProperties.OrderBy(p=>p.Name)) {
             *      Console.ForegroundColor = ConsoleColor.White;
             *      Console.Write ($"\t{item.Name,-40} = ");
             *      Console.ForegroundColor = ConsoleColor.Gray;
             *      Console.WriteLine ($"{item.EvaluatedValue}");
             * }*/


            foreach (ProjectItem pn in project.AllEvaluatedItems)
            {
                switch (pn.ItemType)
                {
                case "ProjectReferenceTargets":
                    Commands.Add(new Crow.Command(new Action(() => Compile(pn.EvaluatedInclude)))
                    {
                        Caption = pn.EvaluatedInclude,
                    });
                    break;

                case "Reference":
                case "PackageReference":
                case "ProjectReference":
                    refs.AddChild(new ProjectItemNode(this, pn));
                    break;

                case "Compile":
                case "None":
                case "EmbeddedResource":
                    ProjectNode curNode = root;
                    try {
                        string file     = pn.EvaluatedInclude.Replace('\\', '/');
                        string treePath = file;
                        if (pn.HasMetadata("Link"))
                        {
                            treePath = project.ExpandString(pn.GetMetadataValue("Link"));
                        }
                        string [] folds = treePath.Split('/');
                        for (int i = 0; i < folds.Length - 1; i++)
                        {
                            ProjectNode nextNode = curNode.Childs.OfType <ProjectNode>().FirstOrDefault(n => n.DisplayName == folds [i] && n.Type == ItemType.VirtualGroup);
                            if (nextNode == null)
                            {
                                nextNode = new ProjectNode(this, ItemType.VirtualGroup, folds [i]);
                                curNode.AddChild(nextNode);
                            }
                            curNode = nextNode;
                        }
                        ProjectItemNode pi = new ProjectItemNode(this, pn);

                        switch (Path.GetExtension(file))
                        {
                        case ".cs":
                            pi = new CSProjectItem(pi);
                            break;

                        case ".crow":
                        case ".template":
                        case ".goml":
                        case ".itemp":
                        case ".imtl":
                            pi = new ImlProjectItem(pi);
                            break;

                        case ".style":
                            pi = new StyleProjectItem(pi);
                            break;

                        default:
                            pi = new ProjectFileNode(pi);
                            break;
                        }
                        curNode.AddChild(pi);
                    } catch (Exception ex) {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine(ex);
                        Console.ResetColor();
                    }

                    break;
                }
            }
            root.SortChilds();
            foreach (var item in root.Childs)
            {
                Childs.Add(item);
                item.Parent = this;
            }


            IsLoaded = true;
        }