private void ChangeParent(ISolutionFolder oldParent, ISolutionFolder newParent) { ISolutionTreeNode?Node = Root.FindTreeNode(Path); if (Node != null) { ISolutionTreeNodeCollection OldChildrenCollection = (ISolutionTreeNodeCollection)oldParent.Children; OldChildrenCollection.Remove(Node); ISolutionTreeNodeCollection NewChildrenCollection = (ISolutionTreeNodeCollection)newParent.Children; NewChildrenCollection.Add(Node); NewChildrenCollection.Sort(); } }
/// <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(); } }
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(); } }