/// <summary> /// This method just copies inheritable properties from /// another <see cref="TreeVertex"/>. /// </summary> /// <param name="n"></param> /// <remarks> /// The properties include: /// <see cref="Sorting"/> /// <see cref="Comparer"/> /// <see cref="Angle"/> /// <see cref="Alignment"/> /// <see cref="NodeIndent"/> /// <see cref="NodeIndentPastParent"/> /// <see cref="NodeSpacing"/> /// <see cref="LayerSpacing"/> /// <see cref="LayerSpacingParentOverlap"/> /// <see cref="Compaction"/> /// <see cref="BreadthLimit"/> /// <see cref="RowSpacing"/> /// <see cref="RowIndent"/> /// <see cref="CommentSpacing"/> /// <see cref="CommentMargin"/> /// <see cref="SetsPortSpot"/> /// <see cref="PortSpot"/> /// <see cref="SetsChildPortSpot"/> /// <see cref="ChildPortSpot"/> /// </remarks> public virtual void CopyInheritedPropertiesFrom(TreeVertex n) { if (n == null) { return; } this.InternalFlags = n.InternalFlags; this.Sorting = n.Sorting; this.Comparer = n.Comparer; this.Angle = n.Angle; this.Alignment = n.Alignment; this.NodeIndent = n.NodeIndent; this.NodeIndentPastParent = n.NodeIndentPastParent; this.NodeSpacing = n.NodeSpacing; this.LayerSpacing = n.LayerSpacing; this.LayerSpacingParentOverlap = n.LayerSpacingParentOverlap; this.Compaction = n.Compaction; this.BreadthLimit = n.BreadthLimit; this.RowSpacing = n.RowSpacing; this.RowIndent = n.RowIndent; this.CommentSpacing = n.CommentSpacing; this.CommentMargin = n.CommentMargin; this.PortSpot = n.PortSpot; this.ChildPortSpot = n.ChildPortSpot; }
private void AdjustRouteForAngleChange(TreeVertex parent, TreeVertex child) { double angle = TreeLayout.OrthoAngle(parent); double childangle = TreeLayout.OrthoAngle(child); if (angle == childangle) { return; } double layerspacing = TreeLayout.ComputeLayerSpacing(parent); Rect pb = parent.Node.Bounds; Rect cb = child.Node.Bounds; // but maybe an Angle change causes the child node not to be adjacent to the layer // separating it with the parent node; only need to do anything if that's the case if ((angle == 0 && cb.Left - pb.Right < layerspacing + 1) || (angle == 90 && cb.Top - pb.Bottom < layerspacing + 1) || (angle == 180 && pb.Left - cb.Right < layerspacing + 1) || (angle == 270 && pb.Top - cb.Bottom < layerspacing + 1)) { return; } Route s = this.Route; s.UpdatePoints(); bool bezier = s.Curve == LinkCurve.Bezier; bool ortho = s.Orthogonal; if (angle == 0) { double x = pb.Right + layerspacing / 2; if (bezier) // curved segments { if (s.PointsCount == 4) { double y = s.GetPoint(3).Y; s.SetPoint(1, new Point(x - 20, s.GetPoint(1).Y)); s.InsertPoint(2, new Point(x - 20, y)); s.InsertPoint(3, new Point(x, y)); s.InsertPoint(4, new Point(x + 20, y)); s.SetPoint(5, new Point(s.GetPoint(5).X, y)); } } else if (ortho) { if (s.PointsCount == 6) { s.SetPoint(2, new Point(x, s.GetPoint(2).Y)); s.SetPoint(3, new Point(x, s.GetPoint(3).Y)); } } else { if (s.PointsCount == 4) { s.InsertPoint(2, new Point(x, s.GetPoint(2).Y)); } else if (s.PointsCount == 3) { s.SetPoint(1, new Point(x, s.GetPoint(2).Y)); } else if (s.PointsCount == 2) { s.InsertPoint(1, new Point(x, s.GetPoint(1).Y)); } } } else if (angle == 90) { double y = pb.Bottom + layerspacing / 2; if (bezier) // curved segments { if (s.PointsCount == 4) { double x = s.GetPoint(3).X; s.SetPoint(1, new Point(s.GetPoint(1).X, y - 20)); s.InsertPoint(2, new Point(x, y - 20)); s.InsertPoint(3, new Point(x, y)); s.InsertPoint(4, new Point(x, y + 20)); s.SetPoint(5, new Point(x, s.GetPoint(5).Y)); } } else if (ortho) { if (s.PointsCount == 6) { s.SetPoint(2, new Point(s.GetPoint(2).X, y)); s.SetPoint(3, new Point(s.GetPoint(3).X, y)); } } else { if (s.PointsCount == 4) { s.InsertPoint(2, new Point(s.GetPoint(2).X, y)); } else if (s.PointsCount == 3) { s.SetPoint(1, new Point(s.GetPoint(2).X, y)); } else if (s.PointsCount == 2) { s.InsertPoint(1, new Point(s.GetPoint(1).X, y)); } } } else if (angle == 180) { double x = pb.Left - layerspacing / 2; if (bezier) // curved segments { if (s.PointsCount == 4) { double y = s.GetPoint(3).Y; s.SetPoint(1, new Point(x + 20, s.GetPoint(1).Y)); s.InsertPoint(2, new Point(x + 20, y)); s.InsertPoint(3, new Point(x, y)); s.InsertPoint(4, new Point(x - 20, y)); s.SetPoint(5, new Point(s.GetPoint(5).X, y)); } } else if (ortho) { if (s.PointsCount == 6) { s.SetPoint(2, new Point(x, s.GetPoint(2).Y)); s.SetPoint(3, new Point(x, s.GetPoint(3).Y)); } } else { if (s.PointsCount == 4) { s.InsertPoint(2, new Point(x, s.GetPoint(2).Y)); } else if (s.PointsCount == 3) { s.SetPoint(1, new Point(x, s.GetPoint(2).Y)); } else if (s.PointsCount == 2) { s.InsertPoint(1, new Point(x, s.GetPoint(1).Y)); } } } else if (angle == 270) { double y = pb.Top - layerspacing / 2; if (bezier) // curved segments { if (s.PointsCount == 4) { double x = s.GetPoint(3).X; s.SetPoint(1, new Point(s.GetPoint(1).X, y + 20)); s.InsertPoint(2, new Point(x, y + 20)); s.InsertPoint(3, new Point(x, y)); s.InsertPoint(4, new Point(x, y - 20)); s.SetPoint(5, new Point(x, s.GetPoint(5).Y)); } } else if (ortho) { if (s.PointsCount == 6) { s.SetPoint(2, new Point(s.GetPoint(2).X, y)); s.SetPoint(3, new Point(s.GetPoint(3).X, y)); } } else { if (s.PointsCount == 4) { s.InsertPoint(2, new Point(s.GetPoint(2).X, y)); } else if (s.PointsCount == 3) { s.SetPoint(1, new Point(s.GetPoint(2).X, y)); } else if (s.PointsCount == 2) { s.InsertPoint(1, new Point(s.GetPoint(1).X, y)); } } } }