Exemplo n.º 1
0
        /// <summary>
        /// Walks up in the hierarchy and ensures that all parent folder nodes of 'node' are included in the project.
        /// </summary>
        /// <param name="node">Start hierarchy node.</param>
        internal static void EnsureParentFolderIncluded(HierarchyNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            // use stack to make sure all parent folders are included in the project.
            Stack <XFolderNode> stack = new Stack <XFolderNode>();

            // Find out the parent folder nodes if any.
            XFolderNode parentFolderNode = node.Parent as XFolderNode;

            while (parentFolderNode != null && parentFolderNode.IsNonMemberItem)
            {
                stack.Push(parentFolderNode);
                parentFolderNode.CreateDirectory(); // ensure that the folder is there on file system
                parentFolderNode = parentFolderNode.Parent as XSharpFolderNode;
            }

            // include all parent folders in the project.
            while (stack.Count > 0)
            {
                XFolderNode folderNode = stack.Pop();
                ((IProjectSourceNode)folderNode).IncludeInProject(false);
            }
        }
Exemplo n.º 2
0
        private static void AddNonMemberFileItems(XProjectNode project, IList <string> fileList)
        {
            Utilities.ArgumentNotNull("fileList", fileList);

            foreach (string fileKey in fileList)
            {
                HierarchyNode parentNode = project;
                string[]      pathItems  = fileKey.Split(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar });

                if (String.Equals(fileKey, project.ProjectFile, StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }

                XFolderNode topFolderNode = null;
                foreach (string fileOrDir in pathItems)
                {
                    string   childNodeId   = Path.Combine(parentNode.VirtualNodeName, fileOrDir);
                    FileInfo fileOrDirInfo = new FileInfo(Path.Combine(project.ProjectFolder, childNodeId));
                    if ((fileOrDirInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
                    {
                        break;
                    }

                    //HierarchyNode childNode = project.FindURL(fileOrDirInfo.FullName);
                    HierarchyNode childNode = parentNode.FindChild(childNodeId);
                    if (childNode == null)
                    {
                        if (topFolderNode == null)
                        {
                            topFolderNode = parentNode as XFolderNode;
                            if (topFolderNode != null && (!topFolderNode.IsNonMemberItem) && topFolderNode.IsExpanded)
                            {
                                topFolderNode = null;
                            }
                        }

                        ProjectElement element = new ProjectElement(project, null, true);
                        element.Rename(childNodeId);
                        element.SetMetadata(ProjectFileConstants.Name, childNodeId);
                        childNode = project.CreateFileNode(element);
                        parentNode.AddChild(childNode);
                        break;
                    }

                    parentNode = childNode;
                }

                if (topFolderNode != null)
                {
                    topFolderNode.CollapseFolder();
                }
            }
        }
Exemplo n.º 3
0
        private static void AddNonMemberFolderItems(XProjectNode project, IList <string> folderList)
        {
            if (folderList == null)
            {
                throw new ArgumentNullException("folderList");
            }

            foreach (string folderKey in folderList)
            {
                HierarchyNode parentNode    = project;
                string[]      folders       = folderKey.Split(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
                XFolderNode   topFolderNode = null;
                foreach (string folder in folders)
                {
                    string   childNodeId = Path.Combine(parentNode.VirtualNodeName, folder);
                    FileInfo folderInfo  = new FileInfo(Path.Combine(project.ProjectFolder, childNodeId));
                    if ((folderInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
                    {
                        break;
                    }

                    HierarchyNode childNode = parentNode.FindChild(childNodeId);
                    if (childNode == null)
                    {
                        if (topFolderNode == null)
                        {
                            topFolderNode = parentNode as XFolderNode;
                            if (topFolderNode != null && (!topFolderNode.IsNonMemberItem) && topFolderNode.IsExpanded)
                            {
                                topFolderNode = null;
                            }
                        }

                        ProjectElement element = new ProjectElement(project, null, true);
                        childNode = project.CreateFolderNode(childNodeId, element);
                        parentNode.AddChild(childNode);
                    }

                    parentNode = childNode;
                }

                if (topFolderNode != null)
                {
                    topFolderNode.CollapseFolder();
                }
            }
        }
        // =========================================================================================
        // Constructors
        // =========================================================================================

        /// <summary>
        /// Initializes a new instance of the <see cref="XSharpFolderNodeProperties"/> class.
        /// </summary>
        /// <param name="node">The node that contains the properties to expose via the Property Browser.</param>
        public XFolderNodeNonMemberProperties(XFolderNode node)
            : base(node)
        {
        }
Exemplo n.º 5
0
        // =========================================================================================
        // Constructors
        // =========================================================================================

        /// <summary>
        /// Initializes a new instance of the <see cref="XSharpFolderNodeProperties"/> class.
        /// </summary>
        /// <param name="node">The node that contains the properties to expose via the Property Browser.</param>
        public XFolderNodeProperties(XFolderNode node)
            : base(node)
        {
        }