예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SolutionFolder"/> class.
        /// </summary>
        /// <param name="parent">The parent folder path.</param>
        /// <param name="path">The folder path.</param>
        /// <param name="properties">The folder properties.</param>
        public SolutionFolder(ISolutionFolder parent, IFolderPath path, IFolderProperties properties)
            : base(parent, path, properties)
        {
            if (parent == null)
            {
                return;
            }

            ChildrenInternal = new SolutionTreeNodeCollection(this, parent.NodeComparer);
        }
예제 #2
0
 public AddFolderOperation(ISolutionRoot root, IFolderPath destinationFolderPath, IFolderPath newPath, IFolderProperties newProperties)
     : base(root, destinationFolderPath, newPath, newProperties)
 {
 }
예제 #3
0
        protected virtual void Add(IReadOnlyDictionary <ITreeNodePath, IPathConnection> pathTable)
        {
            Assert.ValidateReference(pathTable);

            ClearExpandedFolders();

            List <ISolutionTreeNodeCollection> ModifiedCollectionList = new List <ISolutionTreeNodeCollection>();

            List <ITreeNodePath> PathList = new List <ITreeNodePath>();

            foreach (KeyValuePair <ITreeNodePath, IPathConnection> Entry in pathTable)
            {
                PathList.Add(Entry.Key);
            }

            while (PathList.Count > 0)
            {
                IReadOnlyDictionary <IFolderPath, ISolutionFolder> FlatFolderTable = Root.FlatFolderChildren;

                int i = 0;
                while (i < PathList.Count)
                {
                    ITreeNodePath   Path       = PathList[i];
                    IPathConnection Connection = pathTable[Path];
                    IFolderPath     ParentPath = Connection.ParentPath;

                    if (FlatFolderTable.ContainsKey(ParentPath))
                    {
                        PathList.RemoveAt(i);

                        ISolutionFolder             ParentFolder       = FlatFolderTable[ParentPath];
                        ISolutionTreeNodeCollection ChildrenCollection = (ISolutionTreeNodeCollection)ParentFolder.Children;

                        IFolderPath AsFolderPath;
                        IItemPath   AsItemPath;

                        if ((AsFolderPath = Path as IFolderPath) != null)
                        {
                            IFolderProperties Properties = (IFolderProperties)Connection.Properties;

                            ISolutionFolder NewFolder = CreateSolutionFolder(ParentFolder, AsFolderPath, Properties);
                            ChildrenCollection.Add(NewFolder);

                            if (Connection.IsExpanded)
                            {
                                AddExpandedFolder(NewFolder);
                            }
                        }

                        else if ((AsItemPath = Path as IItemPath) != null)
                        {
                            IItemProperties Properties = (IItemProperties)Connection.Properties;

                            ISolutionItem NewItem = CreateSolutionItem(ParentFolder, AsItemPath, Properties);
                            ChildrenCollection.Add(NewItem);
                        }

                        else
                        {
                            Assert.InvalidExecutionPath();
                        }

                        if (!ModifiedCollectionList.Contains(ChildrenCollection))
                        {
                            ModifiedCollectionList.Add(ChildrenCollection);
                        }
                    }
                    else
                    {
                        i++;
                    }
                }
            }

            foreach (ISolutionTreeNodeCollection ChildrenCollection in ModifiedCollectionList)
            {
                ChildrenCollection.Sort();
            }
        }
예제 #4
0
        protected virtual ISolutionFolder CreateSolutionFolder(ISolutionFolder parentFolder, IFolderPath path, IFolderProperties properties)
        {
            Assert.ValidateReference(parentFolder);
            Assert.ValidateReference(path);
            Assert.ValidateReference(properties);

            return(new SolutionFolder(parentFolder, path, properties));
        }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SolutionFolder"/> class.
 /// </summary>
 /// <param name="path">The folder path.</param>
 /// <param name="properties">The folder properties.</param>
 /// <param name="nodeComparer">The node comparer.</param>
 public SolutionFolder(IFolderPath path, IFolderProperties properties, IComparer <ITreeNodePath> nodeComparer)
     : base(null, path, properties)
 {
     ChildrenInternal = new SolutionTreeNodeCollection(this, nodeComparer);
 }
예제 #6
0
 public FolderCreatedCompletionArgs(IFolderPath NewFolderPath, IFolderProperties NewFolderProperties)
 {
     this.NewFolderPath       = NewFolderPath;
     this.NewFolderProperties = NewFolderProperties;
 }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FolderCreatedCompletionArgs"/> class.
 /// </summary>
 /// <param name="newFolderPath">The created folder path.</param>
 /// <param name="newFolderProperties">The created folder properties.</param>
 public FolderCreatedCompletionArgs(IFolderPath newFolderPath, IFolderProperties newFolderProperties)
 {
     NewFolderPath       = newFolderPath;
     NewFolderProperties = newFolderProperties;
 }
예제 #8
0
        /// <summary>
        /// Notifies handlers that the operation is completed.
        /// </summary>
        /// <param name="dispatcher">The window dispatcher.</param>
        /// <param name="newFolderPath">The new folder path.</param>
        /// <param name="newFolderProperties">The new folder properties.</param>
        public virtual void NotifyCompletedAsync(Dispatcher dispatcher, IFolderPath newFolderPath, IFolderProperties newFolderProperties)
        {
            IFolderCreatedCompletionArgs CompletionArgs = new FolderCreatedCompletionArgs(newFolderPath, newFolderProperties);

            NotifyEventCompletedAsync(dispatcher, CompletionArgs);
        }
        /// <summary>
        /// Creates a folder in a solution.
        /// </summary>
        /// <param name="parentFolder">The parent folder.</param>
        /// <param name="path">The folder path.</param>
        /// <param name="properties">The folder properties.</param>
        /// <returns>The created folder.</returns>
        protected virtual ISolutionFolder CreateSolutionFolder(ISolutionFolder parentFolder, IFolderPath path, IFolderProperties properties)
        {
            if (parentFolder == null)
            {
                throw new ArgumentNullException(nameof(parentFolder));
            }
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            return(new SolutionFolder(parentFolder, path, properties));
        }
        /// <summary>
        /// Adds a table of path.
        /// </summary>
        /// <param name="pathTable">The table to add.</param>
        protected virtual void Add(IReadOnlyDictionary <ITreeNodePath, IPathConnection> pathTable)
        {
            if (pathTable == null)
            {
                throw new ArgumentNullException(nameof(pathTable));
            }

            ClearExpandedFolders();

            List <ISolutionTreeNodeCollection> ModifiedCollectionList = new List <ISolutionTreeNodeCollection>();

            List <ITreeNodePath> PathList = new List <ITreeNodePath>();

            foreach (KeyValuePair <ITreeNodePath, IPathConnection> Entry in pathTable)
            {
                PathList.Add(Entry.Key);
            }

            while (PathList.Count > 0)
            {
                IReadOnlyDictionary <IFolderPath, ISolutionFolder> FlatFolderTable = Root.FlatFolderChildren;

                int i = 0;
                while (i < PathList.Count)
                {
                    ITreeNodePath   Path       = PathList[i];
                    IPathConnection Connection = pathTable[Path];
                    IFolderPath?    ParentPath = Connection.ParentPath;

                    if (ParentPath != null && FlatFolderTable.ContainsKey(ParentPath))
                    {
                        PathList.RemoveAt(i);

                        ISolutionFolder             ParentFolder       = FlatFolderTable[ParentPath];
                        ISolutionTreeNodeCollection ChildrenCollection = (ISolutionTreeNodeCollection)ParentFolder.Children;
                        bool IsHandled = false;

                        switch (Path)
                        {
                        case IFolderPath AsFolderPath:
                            IFolderProperties FolderProperties = (IFolderProperties)Connection.Properties;

                            ISolutionFolder NewFolder = CreateSolutionFolder(ParentFolder, AsFolderPath, FolderProperties);
                            ChildrenCollection.Add(NewFolder);

                            if (Connection.IsExpanded)
                            {
                                AddExpandedFolder(NewFolder);
                            }

                            IsHandled = true;
                            break;

                        case IItemPath AsItemPath:
                            IItemProperties ItemProperties = (IItemProperties)Connection.Properties;

                            ISolutionItem NewItem = CreateSolutionItem(ParentFolder, AsItemPath, ItemProperties);
                            ChildrenCollection.Add(NewItem);

                            IsHandled = true;
                            break;
                        }

                        Debug.Assert(IsHandled);

                        if (!ModifiedCollectionList.Contains(ChildrenCollection))
                        {
                            ModifiedCollectionList.Add(ChildrenCollection);
                        }
                    }
                    else
                    {
                        i++;
                    }
                }
            }

            foreach (ISolutionTreeNodeCollection ChildrenCollection in ModifiedCollectionList)
            {
                ChildrenCollection.Sort();
            }
        }