private void UpdateInfos() { _Direction = ((Vector)P2 - (Vector)P1).Normalized; _Equation = Line.FromPoints((Vector)P1, (Vector)P2); _Bounds = RectangleM.FromLTRB( Measure.Min(P1.X, P2.X), Measure.Max(P1.Y, P2.Y), Measure.Max(P1.X, P2.X), Measure.Min(P1.Y, P2.Y)); _Length = Measure.FromNormalizedValue(((Vector)P2 - (Vector)P1).Length, P1.Unit ?? P2.Unit); isDirty = false; }
public RectangleM GetLayoutBounds() { if (VisualElements.Count == 0) { return(RectangleM.Empty); } if (!_CachedBounds.IsEmpty) { return(_CachedBounds); } Measure minX = Measure.Zero; Measure maxX = Measure.Zero; Measure minY = Measure.Zero; Measure maxY = Measure.Zero; foreach (var elem in VisualElements) { if (elem.Bounds.IsEmpty) { continue; } if (elem.Bounds.Left < minX) { minX = elem.Bounds.Left; } if (elem.Bounds.Bottom < minY) { minY = elem.Bounds.Bottom; } if (elem.Bounds.Right > maxX) { maxX = elem.Bounds.Right; } if (elem.Bounds.Top > maxY) { maxY = elem.Bounds.Top; } } _CachedBounds = RectangleM.FromLTRB(minX, maxY, maxX, minY); return(_CachedBounds); }