diff --git a/EnvelopeGenerator.Web/Models/Annotation.cs b/EnvelopeGenerator.Web/Models/Annotation.cs index c730939f..58262e7b 100644 --- a/EnvelopeGenerator.Web/Models/Annotation.cs +++ b/EnvelopeGenerator.Web/Models/Annotation.cs @@ -1,6 +1,6 @@ namespace EnvelopeGenerator.Web.Models; -public record Annotation(string? HorBoundAnnotId = null, string? VerBoundAnnotId = null) +public record Annotation(string? HorBoundAnnotName = null, string? VerBoundAnnotName = null) { #region Layout internal double _marginX = default; diff --git a/EnvelopeGenerator.Web/Models/AnnotationParams.cs b/EnvelopeGenerator.Web/Models/AnnotationParams.cs index 864cef88..9df111f3 100644 --- a/EnvelopeGenerator.Web/Models/AnnotationParams.cs +++ b/EnvelopeGenerator.Web/Models/AnnotationParams.cs @@ -2,5 +2,30 @@ public class AnnotationParams { - public required Dictionary Annotations { get; init; } + private readonly Dictionary _annots = new(); + + public required Dictionary 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."); + } + } + } }