feat(Hintergrund): Locate add, um die Position des Hintergrunds anhand anderer Anmerkungen zu berechnen.

- Standort des Hintergrunds zu Anmerkungen hinzugefügt
This commit is contained in:
Developer 02
2025-04-23 18:13:46 +02:00
parent e72ea534e5
commit d75da655d2
4 changed files with 57 additions and 19 deletions

View File

@@ -20,4 +20,29 @@ public record Background : IAnnotation
public double Left { get; set; }
public double Top { get; set; }
public void Locate(IEnumerable<IAnnotation> annotations)
{
// set Top
if (annotations.MinBy(a => a.Top)?.Top is double minTop)
Top = minTop;
// set Left
if (annotations.MinBy(a => a.Left)?.Left is double minLeft)
Left = minLeft;
// set Width
if(annotations.MaxBy(a => a.GetRight())?.GetRight() is double maxRight)
Width = maxRight - Left;
// set Height
if (annotations.MaxBy(a => a.GetBottom())?.GetBottom() is double maxBottom)
Height = maxBottom - Top;
// add margins
Top -= Margin;
Left -= Margin;
Width += Margin * 2;
Height += Margin * 2;
}
}