Esempio n. 1
0
        private AntTreeNode GetBuildTargetNode(XmlNode node, string defaultTarget)
        {
            XmlAttribute nameAttr = node.Attributes["name"];
            String targetName = (nameAttr != null) ? nameAttr.InnerText : "";

            XmlAttribute descrAttr = node.Attributes["description"];
            String description = (descrAttr != null) ? descrAttr.InnerText : "";

            AntTreeNode targetNode;
            if (targetName == defaultTarget)
            {
                targetNode = new AntTreeNode(targetName, ICON_PUBLIC_TARGET);
                targetNode.NodeFont = new Font(
                    treeView.Font.Name,
                    treeView.Font.Size,
                    FontStyle.Bold);
            }
            else if (description.Length > 0)
            {
                targetNode = new AntTreeNode(targetName, ICON_PUBLIC_TARGET);
            }
            else
            {
                targetNode = new AntTreeNode(targetName, ICON_INTERNAL_TARGET);
            }

            targetNode.Target = targetName;
            targetNode.ToolTipText = description;
            return targetNode;
        }
Esempio n. 2
0
        private TreeNode GetBuildFileNode(string file)
        {
            XmlDocument xml = new XmlDocument();
            xml.Load(file);

            XmlAttribute defTargetAttr = xml.DocumentElement.Attributes["default"];
            String defaultTarget = (defTargetAttr != null) ? defTargetAttr.InnerText : "";

            XmlAttribute nameAttr = xml.DocumentElement.Attributes["name"];
            String projectName = (nameAttr != null) ? nameAttr.InnerText : file;

            XmlAttribute descrAttr = xml.DocumentElement.Attributes["description"];
            String description = (descrAttr != null) ? descrAttr.InnerText : "";

            if (projectName.Length == 0)
            projectName = file;

            AntTreeNode rootNode = new AntTreeNode(projectName, ICON_FILE);
            rootNode.File = file;
            rootNode.Target = defaultTarget;
            rootNode.ToolTipText = description;

            XmlNodeList nodes = xml.DocumentElement.ChildNodes;
            int nodeCount = nodes.Count;
            for (int i = 0; i < nodeCount; i++)
            {
                XmlNode child = nodes[i];
                if (child.Name == "target")
                {
                    // skip private targets
                    XmlAttribute targetNameAttr = child.Attributes["name"];
                    if (targetNameAttr != null)
                    {
                        String targetName = targetNameAttr.InnerText;
                        if (!String.IsNullOrEmpty(targetName) && (targetName[0] == '-'))
                        {
                            continue;
                        }
                    }

                    AntTreeNode targetNode = GetBuildTargetNode(child, defaultTarget);
                    targetNode.File = file;
                    rootNode.Nodes.Add(targetNode);
                }
            }

            rootNode.Expand();
            return rootNode;
        }