diff --git a/EnvelopeGenerator.Web/Models/Annotation.cs b/EnvelopeGenerator.Web/Models/Annotation.cs index 58262e7b..4032fca4 100644 --- a/EnvelopeGenerator.Web/Models/Annotation.cs +++ b/EnvelopeGenerator.Web/Models/Annotation.cs @@ -1,7 +1,13 @@ namespace EnvelopeGenerator.Web.Models; -public record Annotation(string? HorBoundAnnotName = null, string? VerBoundAnnotName = null) +public class Annotation { + #region Bound Annotation + public string? HorBoundAnnotName { get; init; } + + public string? VerBoundAnnotName { get; init; } + #endregion + #region Layout internal double _marginX = default; diff --git a/EnvelopeGenerator.Web/Models/AnnotationParams.cs b/EnvelopeGenerator.Web/Models/AnnotationParams.cs index 9df111f3..4886a67a 100644 --- a/EnvelopeGenerator.Web/Models/AnnotationParams.cs +++ b/EnvelopeGenerator.Web/Models/AnnotationParams.cs @@ -1,6 +1,6 @@ namespace EnvelopeGenerator.Web.Models; -public class AnnotationParams +public class AnnotationParams: Annotation { private readonly Dictionary _annots = new(); @@ -9,15 +9,31 @@ public class AnnotationParams get => _annots; init { - // set bound annotations + _annots = value; + foreach (var name in _annots.Keys) { + #region set default values + if (_annots[name]._marginX == default) + _annots[name]._marginX = MarginX; + + if (_annots[name]._marginY == default) + _annots[name]._marginY = MarginY; + + if (_annots[name]._width == default) + _annots[name]._width = Width; + + if (_annots[name]._height == default) + _annots[name]._height = Height; + #endregion + + #region set bound annotations // 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."); + else + throw new InvalidOperationException($"{horBoundAnnotName} added as bound anotation. However, it is not defined."); // vertical if (_annots[name].VerBoundAnnotName is string verBoundAnnotName) @@ -25,6 +41,7 @@ public class AnnotationParams _annots[name].VerBoundAnnot = verBoundAnnot; else throw new InvalidOperationException($"{verBoundAnnotName} added as bound anotation. However, it is not defined."); + #endregion } } } diff --git a/EnvelopeGenerator.Web/appsettings.json b/EnvelopeGenerator.Web/appsettings.json index 994141a1..3bf5e281 100644 --- a/EnvelopeGenerator.Web/appsettings.json +++ b/EnvelopeGenerator.Web/appsettings.json @@ -152,7 +152,15 @@ "MainPageTitle": null, "AnnotationParams": { "Annotations": { + "Signature": { + }, + "City": { + + }, + "Date": { + + } } } }