public void RemoveChild(Topic child) { List <Topic> children = ChildNodes.ToList(); children.Remove(child); child._parent = null; child._previous = null; child._next = null; if (!children.Any()) { _firstChild = null; return; } _firstChild = children.First(); _firstChild._parent = this; _firstChild._previous = null; children.Last()._next = null; for (int i = 1; i < children.Count; i++) { children[i]._previous = children[i - 1]; } for (int i = 0; i < children.Count - 1; i++) { children[i]._next = children[i + 1]; } }
protected override DomObject SetNameCore(DomName name) { var newElement = OwnerDocument.CreateElement(name); newElement.Append(ChildNodes.ToList()); newElement.Attributes.AddRange(Attributes.ToList()); newElement.CopyAnnotationsFrom(AnnotationList); return(ReplaceWith(newElement)); }
internal IEnumerable <DomNode> UnwrapCore() { AssertCanUnwrap(); if (ChildNodes.Count == 0) { RemoveSelf(); return(Enumerable.Empty <DomNode>()); } var items = ChildNodes.ToList(); ReplaceWith(items); return(items); }
// Find the left most node(s) -- parent nodes. Perpare all the child nodes for finding the relationships between them private void Initialise(RealignStyle realignStyle = RealignStyle.Horizontal) { foreach (var nodeControl in _nodeControls) { var realignNode = new RealignNode(nodeControl); if (nodeControl.ParentNodes.Count == 0) { AddChild(realignNode); } else { _nodesNeedToBePlaced.Add(realignNode); } } //If no parent can be found, set the top left node to parent if (ChildNodes.Count == 0) { AddTopLeftNodeToParentNode(); } PlaceNodesToMap(realignStyle); ReCheckForIncorrectDepth(realignStyle); if (_isPartlyRealign) { var nodesToLoop = ChildNodes.ToList(); foreach (var realignNode in nodesToLoop) { if (!realignNode.HasChild) { ChildNodes.Remove(realignNode); } } } }