feat(AnnotationParams): Aktualisiert, um Standardwerte in Annots.init zu setzen.

This commit is contained in:
Developer 02 2025-03-20 10:23:33 +01:00
parent cbd71aa2b9
commit 8a6a11c1bc
3 changed files with 36 additions and 5 deletions

View File

@ -1,7 +1,13 @@
namespace EnvelopeGenerator.Web.Models; 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 #region Layout
internal double _marginX = default; internal double _marginX = default;

View File

@ -1,6 +1,6 @@
namespace EnvelopeGenerator.Web.Models; namespace EnvelopeGenerator.Web.Models;
public class AnnotationParams public class AnnotationParams: Annotation
{ {
private readonly Dictionary<string, Annotation> _annots = new(); private readonly Dictionary<string, Annotation> _annots = new();
@ -9,15 +9,31 @@ public class AnnotationParams
get => _annots; get => _annots;
init init
{ {
// set bound annotations _annots = value;
foreach (var name in _annots.Keys) 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 // horizontal
if (_annots[name].HorBoundAnnotName is string horBoundAnnotName) if (_annots[name].HorBoundAnnotName is string horBoundAnnotName)
if (_annots.TryGetValue(horBoundAnnotName, out var horBoundAnnot)) if (_annots.TryGetValue(horBoundAnnotName, out var horBoundAnnot))
_annots[name].HorBoundAnnot = horBoundAnnot; _annots[name].HorBoundAnnot = horBoundAnnot;
else else
throw new InvalidOperationException($"{horBoundAnnotName} added as bound anotation. However, it is not defined."); throw new InvalidOperationException($"{horBoundAnnotName} added as bound anotation. However, it is not defined.");
// vertical // vertical
if (_annots[name].VerBoundAnnotName is string verBoundAnnotName) if (_annots[name].VerBoundAnnotName is string verBoundAnnotName)
@ -25,6 +41,7 @@ public class AnnotationParams
_annots[name].VerBoundAnnot = verBoundAnnot; _annots[name].VerBoundAnnot = verBoundAnnot;
else else
throw new InvalidOperationException($"{verBoundAnnotName} added as bound anotation. However, it is not defined."); throw new InvalidOperationException($"{verBoundAnnotName} added as bound anotation. However, it is not defined.");
#endregion
} }
} }
} }

View File

@ -152,7 +152,15 @@
"MainPageTitle": null, "MainPageTitle": null,
"AnnotationParams": { "AnnotationParams": {
"Annotations": { "Annotations": {
"Signature": {
},
"City": {
},
"Date": {
}
} }
} }
} }