feat(AnnotationParams): Logik zur Initialisierung von gebundenen Annotationen hinzugefügt Annots.init
This commit is contained in:
parent
df019a7243
commit
cbd71aa2b9
@ -1,6 +1,6 @@
|
|||||||
namespace EnvelopeGenerator.Web.Models;
|
namespace EnvelopeGenerator.Web.Models;
|
||||||
|
|
||||||
public record Annotation(string? HorBoundAnnotId = null, string? VerBoundAnnotId = null)
|
public record Annotation(string? HorBoundAnnotName = null, string? VerBoundAnnotName = null)
|
||||||
{
|
{
|
||||||
#region Layout
|
#region Layout
|
||||||
internal double _marginX = default;
|
internal double _marginX = default;
|
||||||
|
|||||||
@ -2,5 +2,30 @@
|
|||||||
|
|
||||||
public class AnnotationParams
|
public class AnnotationParams
|
||||||
{
|
{
|
||||||
public required Dictionary<string, Annotation> Annotations { get; init; }
|
private readonly Dictionary<string, Annotation> _annots = new();
|
||||||
|
|
||||||
|
public required Dictionary<string, Annotation> Annots
|
||||||
|
{
|
||||||
|
get => _annots;
|
||||||
|
init
|
||||||
|
{
|
||||||
|
// set bound annotations
|
||||||
|
foreach (var name in _annots.Keys)
|
||||||
|
{
|
||||||
|
// horizontal
|
||||||
|
if (_annots[name].HorBoundAnnotName is string horBoundAnnotName)
|
||||||
|
if (_annots.TryGetValue(horBoundAnnotName, out var horBoundAnnot))
|
||||||
|
_annots[name].HorBoundAnnot = horBoundAnnot;
|
||||||
|
else
|
||||||
|
throw new InvalidOperationException($"{horBoundAnnotName} added as bound anotation. However, it is not defined.");
|
||||||
|
|
||||||
|
// vertical
|
||||||
|
if (_annots[name].VerBoundAnnotName is string verBoundAnnotName)
|
||||||
|
if (_annots.TryGetValue(verBoundAnnotName, out var verBoundAnnot))
|
||||||
|
_annots[name].VerBoundAnnot = verBoundAnnot;
|
||||||
|
else
|
||||||
|
throw new InvalidOperationException($"{verBoundAnnotName} added as bound anotation. However, it is not defined.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user