Esempio n. 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;
        }
Esempio n. 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;
 }
Esempio n. 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;
        }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 8
0
        protected SolutionTreeNode(ISolutionFolder parent, ITreeNodePath path, ITreeNodeProperties properties)
        {
            this.Parent     = parent;
            this.Path       = path;
            this.Properties = properties;

            UpdateName();
            InitIsDirty();
        }
Esempio n. 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;
        }
Esempio n. 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;
        }
Esempio n. 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;
        }
Esempio n. 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;
        }
Esempio n. 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;
        }
Esempio n. 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();
            }
        }
Esempio n. 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;
        }
Esempio n. 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;
        }
Esempio n. 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;
        }
Esempio n. 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);
        }
Esempio n. 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();
            }
        }
Esempio n. 23
0
 protected AddRemoveSingleOperation(ISolutionRoot root, IFolderPath parentPath, ITreeNodePath path, ITreeNodeProperties properties)
     : base(root, CreateSinglePathTable(parentPath, path, properties))
 {
 }
Esempio n. 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;
        }
Esempio n. 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;
 }
Esempio n. 28
0
 public NodePastedCompletionArgs(ITreeNodePath NewPath, ITreeNodeProperties NewProperties)
 {
     this.NewPath       = NewPath;
     this.NewProperties = NewProperties;
 }
Esempio n. 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();
            }
        }