예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PathGroup"/> class.
        /// </summary>
        /// <param name="pathTable">The table of items in the group.</param>
        /// <param name="groupParentPath">The specified parent path.</param>
        public PathGroup(IReadOnlyDictionary <ITreeNodePath, IPathConnection> pathTable, IFolderPath groupParentPath)
        {
            if (groupParentPath == null)
            {
                throw new ArgumentNullException(nameof(groupParentPath));
            }
            if (pathTable == null)
            {
                throw new ArgumentNullException(nameof(pathTable));
            }

            Debug.Assert(HasNullCommonParent(pathTable));

            Dictionary <ITreeNodePath, IPathConnection> PathTable = new Dictionary <ITreeNodePath, IPathConnection>();

            foreach (KeyValuePair <ITreeNodePath, IPathConnection> Entry in pathTable)
            {
                ITreeNodePath       Path           = Entry.Key;
                IPathConnection     PathConnection = Entry.Value;
                IFolderPath?        ParentPath     = PathConnection.ParentPath;
                ITreeNodeProperties Properties     = PathConnection.Properties;
                bool IsExpanded = PathConnection.IsExpanded;

                if (ParentPath == null)
                {
                    ParentPath = GroupParentPath;
                }

                PathTable.Add(Path, new PathConnection(ParentPath, Properties, IsExpanded));
            }

            this.PathTable  = PathTable;
            GroupParentPath = groupParentPath;
        }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NodeRenamedEventContext"/> class.
 /// </summary>
 /// <param name="path">The path to the renamed node.</param>
 /// <param name="newName">The new name.</param>
 /// <param name="isUndoRedo">True if the operation can be undone.</param>
 /// <param name="rootProperties">The properties of the root object.</param>
 public NodeRenamedEventContext(ITreeNodePath path, string newName, bool isUndoRedo, IRootProperties rootProperties)
 {
     Path           = path;
     NewName        = newName;
     IsUndoRedo     = isUndoRedo;
     RootProperties = rootProperties;
 }
예제 #3
0
        public PathGroup(IReadOnlyDictionary <ITreeNodePath, IPathConnection> pathTable, IFolderPath groupParentPath)
        {
            Assert.ValidateReference(pathTable);
            Assert.ValidateReference(groupParentPath);
            Assert.CheckCondition(HasNullCommonParent(pathTable));

            Dictionary <ITreeNodePath, IPathConnection> PathTable = new Dictionary <ITreeNodePath, IPathConnection>();

            foreach (KeyValuePair <ITreeNodePath, IPathConnection> Entry in pathTable)
            {
                ITreeNodePath       Path           = Entry.Key;
                IPathConnection     PathConnection = Entry.Value;
                IFolderPath         ParentPath     = PathConnection.ParentPath;
                ITreeNodeProperties Properties     = PathConnection.Properties;
                bool IsExpanded = PathConnection.IsExpanded;

                if (ParentPath == null)
                {
                    ParentPath = GroupParentPath;
                }

                PathTable.Add(Path, new PathConnection(ParentPath, Properties, IsExpanded));
            }

            this.PathTable       = PathTable;
            this.GroupParentPath = GroupParentPath;
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NodeMovedEventContext"/> class.
 /// </summary>
 /// <param name="path">The moved node path.</param>
 /// <param name="newParentPath">The path to the new parent.</param>
 /// <param name="isUndoRedo">True if the operation can be undone.</param>
 /// <param name="rootProperties">The properties of the root object.</param>
 public NodeMovedEventContext(ITreeNodePath path, IFolderPath newParentPath, bool isUndoRedo, IRootProperties rootProperties)
 {
     Path           = path;
     NewParentPath  = newParentPath;
     IsUndoRedo     = isUndoRedo;
     RootProperties = rootProperties;
 }
예제 #5
0
        public virtual ISolutionTreeNode FindTreeNode(ITreeNodePath path)
        {
            if (path == null)
            {
                return(null);
            }

            if (path.IsEqual(Path))
            {
                return(this);
            }

            foreach (ISolutionTreeNode Child in Children)
            {
                if (path.IsEqual(Child.Path))
                {
                    return(Child);
                }

                ISolutionFolder AsFolder;
                if ((AsFolder = Child as ISolutionFolder) != null)
                {
                    ISolutionTreeNode TreeNode = AsFolder.FindTreeNode(path);
                    if (TreeNode != null)
                    {
                        return(TreeNode);
                    }
                }
            }

            return(null);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SolutionTreeNode"/> class.
        /// </summary>
        /// <param name="parent">The parent folder.</param>
        /// <param name="path">The node path.</param>
        /// <param name="properties">The node properties.</param>
        protected SolutionTreeNode(ISolutionFolder?parent, ITreeNodePath path, ITreeNodeProperties properties)
        {
            Parent     = parent;
            Path       = path;
            Properties = properties;

            UpdateName();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="NodePastedEventContext"/> class.
 /// </summary>
 /// <param name="path">The path to the pasted node.</param>
 /// <param name="parentPath">The path to the parent.</param>
 /// <param name="pathTable">The table of children.</param>
 /// <param name="updatedParentTable">The table of updated parent in children.</param>
 /// <param name="rootProperties">The properties of the root object.</param>
 /// <param name="isUndoRedo">True if the operation can be undone.</param>
 public NodePastedEventContext(ITreeNodePath path, IFolderPath parentPath, IReadOnlyDictionary <ITreeNodePath, IPathConnection> pathTable, Dictionary <ITreeNodePath, IFolderPath> updatedParentTable, IRootProperties rootProperties, bool isUndoRedo)
 {
     Path               = path;
     ParentPath         = parentPath;
     PathTable          = pathTable;
     UpdatedParentTable = updatedParentTable;
     RootProperties     = rootProperties;
     IsUndoRedo         = isUndoRedo;
 }
예제 #8
0
        protected SolutionTreeNode(ISolutionFolder parent, ITreeNodePath path, ITreeNodeProperties properties)
        {
            this.Parent     = parent;
            this.Path       = path;
            this.Properties = properties;

            UpdateName();
            InitIsDirty();
        }
예제 #9
0
        public RenameOperation(ISolutionRoot root, ITreeNodePath path, string newName)
            : base(root)
        {
            Assert.ValidateReference(path);
            Assert.ValidateReference(newName);

            this.Path    = path;
            this.OldName = Path.FriendlyName;
            this.NewName = newName;
        }
예제 #10
0
        public MoveOperation(ISolutionRoot root, ITreeNodePath path, ISolutionFolder oldParent, ISolutionFolder newParent)
            : base(root)
        {
            Assert.ValidateReference(path);
            Assert.ValidateReference(oldParent);
            Assert.ValidateReference(newParent);

            this.Path      = path;
            this.OldParent = oldParent;
            this.NewParent = newParent;
        }
예제 #11
0
        public NameChangedEventArgs(RoutedEvent routedEvent, ITreeNodePath path, string oldName, string newName, bool isUndoRedo)
            : base(routedEvent)
        {
            Assert.ValidateReference(path);
            Assert.ValidateReference(oldName);
            Assert.ValidateReference(newName);

            this.Path       = path;
            this.OldName    = oldName;
            this.NewName    = newName;
            this.IsUndoRedo = isUndoRedo;
        }
예제 #12
0
        public MovedEventArgs(RoutedEvent routedEvent, ITreeNodePath path, IFolderPath oldParentPath, IFolderPath newParentPath, bool isUndoRedo)
            : base(routedEvent)
        {
            Assert.ValidateReference(path);
            Assert.ValidateReference(oldParentPath);
            Assert.ValidateReference(newParentPath);

            this.Path          = path;
            this.OldParentPath = oldParentPath;
            this.NewParentPath = newParentPath;
            this.IsUndoRedo    = isUndoRedo;
        }
예제 #13
0
        public PathGroup(ITreeNodePath path, IFolderPath parentPath, ITreeNodeProperties properties)
        {
            Assert.ValidateReference(path);
            Assert.ValidateReference(parentPath);
            Assert.ValidateReference(properties);

            Dictionary <ITreeNodePath, IPathConnection> SinglePathTable = new Dictionary <ITreeNodePath, IPathConnection>();

            SinglePathTable.Add(path, new PathConnection(parentPath, properties, false));

            PathTable       = SinglePathTable;
            GroupParentPath = parentPath;
        }
예제 #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RenameOperation"/> class.
        /// </summary>
        /// <param name="root">The root path.</param>
        /// <param name="path">The path of the renamed item.</param>
        /// <param name="newName">The new name.</param>
        public RenameOperation(ISolutionRoot root, ITreeNodePath path, string newName)
            : base(root)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (newName == null)
            {
                throw new ArgumentNullException(nameof(newName));
            }

            this.Path    = path;
            this.OldName = Path.FriendlyName;
            this.NewName = newName;
        }
        /// <summary>
        /// Removes a table of paths.
        /// </summary>
        /// <param name="pathTable">The table of paths.</param>
        protected virtual void Remove(IReadOnlyDictionary <ITreeNodePath, IPathConnection> pathTable)
        {
            if (pathTable == null)
            {
                throw new ArgumentNullException(nameof(pathTable));
            }

            IReadOnlyDictionary <IFolderPath, ISolutionFolder> FlatFolderTable = Root.FlatFolderChildren;
            List <ISolutionTreeNodeCollection> ModifiedCollectionList          = new List <ISolutionTreeNodeCollection>();

            foreach (KeyValuePair <ITreeNodePath, IPathConnection> Entry in pathTable)
            {
                ITreeNodePath   Path       = Entry.Key;
                IPathConnection Connection = Entry.Value;
                IFolderPath?    ParentPath = Connection.ParentPath;

                if (ParentPath != null)
                {
                    ISolutionFolder             ParentFolder       = FlatFolderTable[ParentPath];
                    ISolutionTreeNodeCollection ChildrenCollection = (ISolutionTreeNodeCollection)ParentFolder.Children;

                    foreach (ISolutionTreeNode Child in (IEnumerable <ISolutionTreeNode>)ChildrenCollection)
                    {
                        if (Child.Path.IsEqual(Path))
                        {
                            ChildrenCollection.Remove(Child);
                            break;
                        }
                    }

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

            foreach (ISolutionTreeNodeCollection ChildrenCollection in ModifiedCollectionList)
            {
                ChildrenCollection.Sort();
            }
        }
예제 #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MoveOperation"/> class.
        /// </summary>
        /// <param name="root">The root path.</param>
        /// <param name="path">The path to the moved node.</param>
        /// <param name="oldParent">The old parent.</param>
        /// <param name="newParent">The new parent.</param>
        public MoveOperation(ISolutionRoot root, ITreeNodePath path, ISolutionFolder oldParent, ISolutionFolder newParent)
            : base(root)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (oldParent == null)
            {
                throw new ArgumentNullException(nameof(oldParent));
            }
            if (newParent == null)
            {
                throw new ArgumentNullException(nameof(newParent));
            }

            this.Path      = path;
            this.OldParent = oldParent;
            this.NewParent = newParent;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="NameChangedEventArgs"/> class.
        /// </summary>
        /// <param name="routedEvent">The event that occured.</param>
        /// <param name="path">The changed item path.</param>
        /// <param name="oldName">The old name.</param>
        /// <param name="newName">The new name.</param>
        /// <param name="isUndoRedo">True if the operation is part of a undo or redo operation.</param>
        public NameChangedEventArgs(RoutedEvent routedEvent, ITreeNodePath path, string oldName, string newName, bool isUndoRedo)
            : base(routedEvent)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (oldName == null)
            {
                throw new ArgumentNullException(nameof(oldName));
            }
            if (newName == null)
            {
                throw new ArgumentNullException(nameof(newName));
            }

            Path       = path;
            OldName    = oldName;
            NewName    = newName;
            IsUndoRedo = isUndoRedo;
        }
예제 #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MovedEventArgs"/> class.
        /// </summary>
        /// <param name="routedEvent">The event that occured.</param>
        /// <param name="path">The moved item path.</param>
        /// <param name="oldParentPath">Path to the old parent.</param>
        /// <param name="newParentPath">Path to the new parent.</param>
        /// <param name="isUndoRedo">True if the operation is part of a undo or redo operation.</param>
        public MovedEventArgs(RoutedEvent routedEvent, ITreeNodePath path, IFolderPath oldParentPath, IFolderPath newParentPath, bool isUndoRedo)
            : base(routedEvent)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (oldParentPath == null)
            {
                throw new ArgumentNullException(nameof(oldParentPath));
            }
            if (newParentPath == null)
            {
                throw new ArgumentNullException(nameof(newParentPath));
            }

            Path          = path;
            OldParentPath = oldParentPath;
            NewParentPath = newParentPath;
            IsUndoRedo    = isUndoRedo;
        }
예제 #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PathGroup"/> class.
        /// </summary>
        /// <param name="path">The single member of the group.</param>
        /// <param name="parentPath">The parent path.</param>
        /// <param name="properties">Properties of the associated item.</param>
        public PathGroup(ITreeNodePath path, IFolderPath parentPath, ITreeNodeProperties properties)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (parentPath == null)
            {
                throw new ArgumentNullException(nameof(parentPath));
            }
            if (properties == null)
            {
                throw new ArgumentNullException(nameof(properties));
            }

            Dictionary <ITreeNodePath, IPathConnection> SinglePathTable = new Dictionary <ITreeNodePath, IPathConnection>();

            SinglePathTable.Add(path, new PathConnection(parentPath, properties, false));

            PathTable       = SinglePathTable;
            GroupParentPath = parentPath;
        }
예제 #20
0
        protected virtual void Remove(IReadOnlyDictionary <ITreeNodePath, IPathConnection> pathTable)
        {
            Assert.ValidateReference(pathTable);

            IReadOnlyDictionary <IFolderPath, ISolutionFolder> FlatFolderTable = Root.FlatFolderChildren;
            List <ISolutionTreeNodeCollection> ModifiedCollectionList          = new List <ISolutionTreeNodeCollection>();

            foreach (KeyValuePair <ITreeNodePath, IPathConnection> Entry in pathTable)
            {
                ITreeNodePath   Path       = Entry.Key;
                IPathConnection Connection = Entry.Value;
                IFolderPath     ParentPath = Connection.ParentPath;

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

                foreach (ISolutionTreeNode Child in ChildrenCollection)
                {
                    if (Child.Path.IsEqual(Path))
                    {
                        ChildrenCollection.Remove(Child);
                        break;
                    }
                }

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

            foreach (ISolutionTreeNodeCollection ChildrenCollection in ModifiedCollectionList)
            {
                ChildrenCollection.Sort();
            }
        }
        /// <summary>
        /// Notifies handlers that the operation is completed.
        /// </summary>
        /// <param name="dispatcher">The window dispatcher.</param>
        /// <param name="newPath">The path to the new node.</param>
        /// <param name="newProperties">The properties of the new node.</param>
        public virtual void NotifyCompletedAsync(Dispatcher dispatcher, ITreeNodePath newPath, ITreeNodeProperties newProperties)
        {
            INodePastedCompletionArgs CompletionArgs = new NodePastedCompletionArgs(newPath, newProperties);

            NotifyEventCompletedAsync(dispatcher, CompletionArgs);
        }
예제 #22
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();
            }
        }
예제 #23
0
 protected AddRemoveSingleOperation(ISolutionRoot root, IFolderPath parentPath, ITreeNodePath path, ITreeNodeProperties properties)
     : base(root, CreateSinglePathTable(parentPath, path, properties))
 {
 }
예제 #24
0
 private static IReadOnlyDictionary <ITreeNodePath, IPathConnection> CreateSinglePathTable(IFolderPath parentPath, ITreeNodePath path, ITreeNodeProperties properties)
 {
     return(new Dictionary <ITreeNodePath, IPathConnection>()
     {
         { path, new PathConnection(parentPath, properties, false) }
     });
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="AddSingleOperation"/> class.
        /// </summary>
        /// <param name="root">The root path.</param>
        /// <param name="destinationFolderPath">The destination folder path.</param>
        /// <param name="newPath">The path of the added item.</param>
        /// <param name="newProperties">The properties of the added item.</param>
        protected AddSingleOperation(ISolutionRoot root, IFolderPath destinationFolderPath, ITreeNodePath newPath, ITreeNodeProperties newProperties)
            : base(root, destinationFolderPath, newPath, newProperties)
        {
            if (destinationFolderPath == null)
            {
                throw new ArgumentNullException(nameof(destinationFolderPath));
            }

            this.DestinationFolderPath = destinationFolderPath;
        }
예제 #26
0
        protected AddSingleOperation(ISolutionRoot root, IFolderPath destinationFolderPath, ITreeNodePath newPath, ITreeNodeProperties newProperties)
            : base(root, destinationFolderPath, newPath, newProperties)
        {
            Assert.ValidateReference(destinationFolderPath);

            this.DestinationFolderPath = destinationFolderPath;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="NodePastedCompletionArgs"/> class.
 /// </summary>
 /// <param name="newPath">The new node path.</param>
 /// <param name="newProperties">The new node properties.</param>
 public NodePastedCompletionArgs(ITreeNodePath newPath, ITreeNodeProperties newProperties)
 {
     NewPath       = newPath;
     NewProperties = newProperties;
 }
예제 #28
0
 public NodePastedCompletionArgs(ITreeNodePath NewPath, ITreeNodeProperties NewProperties)
 {
     this.NewPath       = NewPath;
     this.NewProperties = NewProperties;
 }
예제 #29
0
 /// <summary>
 /// Checks if two paths are the same.
 /// </summary>
 /// <param name="other">The other path.</param>
 /// <returns>True if they are the same; otherwise, false.</returns>
 public bool IsEqual(ITreeNodePath other)
 {
     return(false);
 }
        /// <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();
            }
        }