From ea6ee11a4e9e09aa81fc38b19c5e7d1fb3a1b833 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Wed, 23 Apr 2025 15:31:35 +0200 Subject: [PATCH] feat(Hintergrund): Erstellen, um den Hintergrund von Anmerkungen mit der Eigenschaft MarginRatio zu konfigurieren. - verschiebt Anmerkungen nach --- .../Controllers/ConfigController.cs | 2 +- .../Models/{ => Annotation}/Annotation.cs | 2 +- .../{ => Annotation}/AnnotationParams.cs | 19 +++++++++++++------ .../Models/Annotation/Background.cs | 6 ++++++ EnvelopeGenerator.Web/Program.cs | 1 + EnvelopeGenerator.Web/appsettings.json | 3 +++ 6 files changed, 25 insertions(+), 8 deletions(-) rename EnvelopeGenerator.Web/Models/{ => Annotation}/Annotation.cs (97%) rename EnvelopeGenerator.Web/Models/{ => Annotation}/AnnotationParams.cs (76%) create mode 100644 EnvelopeGenerator.Web/Models/Annotation/Background.cs diff --git a/EnvelopeGenerator.Web/Controllers/ConfigController.cs b/EnvelopeGenerator.Web/Controllers/ConfigController.cs index edf4859f..fc6f5efd 100644 --- a/EnvelopeGenerator.Web/Controllers/ConfigController.cs +++ b/EnvelopeGenerator.Web/Controllers/ConfigController.cs @@ -1,4 +1,4 @@ -using EnvelopeGenerator.Web.Models; +using EnvelopeGenerator.Web.Models.Annotation; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; diff --git a/EnvelopeGenerator.Web/Models/Annotation.cs b/EnvelopeGenerator.Web/Models/Annotation/Annotation.cs similarity index 97% rename from EnvelopeGenerator.Web/Models/Annotation.cs rename to EnvelopeGenerator.Web/Models/Annotation/Annotation.cs index 6db0265a..ace9f811 100644 --- a/EnvelopeGenerator.Web/Models/Annotation.cs +++ b/EnvelopeGenerator.Web/Models/Annotation/Annotation.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace EnvelopeGenerator.Web.Models; +namespace EnvelopeGenerator.Web.Models.Annotation; public record Annotation { diff --git a/EnvelopeGenerator.Web/Models/AnnotationParams.cs b/EnvelopeGenerator.Web/Models/Annotation/AnnotationParams.cs similarity index 76% rename from EnvelopeGenerator.Web/Models/AnnotationParams.cs rename to EnvelopeGenerator.Web/Models/Annotation/AnnotationParams.cs index 052968e1..59ad9a89 100644 --- a/EnvelopeGenerator.Web/Models/AnnotationParams.cs +++ b/EnvelopeGenerator.Web/Models/Annotation/AnnotationParams.cs @@ -1,13 +1,20 @@ using System.Text.Json.Serialization; -namespace EnvelopeGenerator.Web.Models; +namespace EnvelopeGenerator.Web.Models.Annotation; public class AnnotationParams { + public AnnotationParams() + { + _annotationDictionaryInitor = new(() => _annots.ToDictionary(a => a.Name.ToLower(), a => a)); + } + + public Background? Background { get; init; } + [JsonIgnore] public Annotation? DefaultAnnotation { get; init; } - private readonly IEnumerable _annots = new List(); + private readonly List _annots = new List(); public Annotation this[string name] => _annots.First(a => a.Name == name); @@ -24,7 +31,7 @@ public class AnnotationParams get => _annots; init { - _annots = value; + _annots = value.ToList(); if (DefaultAnnotation is not null) foreach (var annot in _annots) @@ -48,10 +55,10 @@ public class AnnotationParams throw new InvalidOperationException($"{verBoundAnnotName} added as bound anotation. However, it is not defined."); #endregion } - - AnnotationDictionary = _annots.ToDictionary(a => a.Name.ToLower(), a => a); } } - public Dictionary AnnotationDictionary { get; private init; } = new(); + private readonly Lazy> _annotationDictionaryInitor; + + public Dictionary AnnotationDictionary => _annotationDictionaryInitor.Value; } diff --git a/EnvelopeGenerator.Web/Models/Annotation/Background.cs b/EnvelopeGenerator.Web/Models/Annotation/Background.cs new file mode 100644 index 00000000..57220365 --- /dev/null +++ b/EnvelopeGenerator.Web/Models/Annotation/Background.cs @@ -0,0 +1,6 @@ +namespace EnvelopeGenerator.Web.Models.Annotation; + +public class Background +{ + public int Margin { get; init; } +} diff --git a/EnvelopeGenerator.Web/Program.cs b/EnvelopeGenerator.Web/Program.cs index 8a2f7fc1..9448b5e4 100644 --- a/EnvelopeGenerator.Web/Program.cs +++ b/EnvelopeGenerator.Web/Program.cs @@ -15,6 +15,7 @@ using DigitalData.EmailProfilerDispatcher; using EnvelopeGenerator.Infrastructure; using EnvelopeGenerator.Web.Sanitizers; using EnvelopeGenerator.Application.Contracts.Services; +using EnvelopeGenerator.Web.Models.Annotation; var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger(); logger.Info("Logging initialized!"); diff --git a/EnvelopeGenerator.Web/appsettings.json b/EnvelopeGenerator.Web/appsettings.json index 136c48a8..380644e5 100644 --- a/EnvelopeGenerator.Web/appsettings.json +++ b/EnvelopeGenerator.Web/appsettings.json @@ -151,6 +151,9 @@ }, "MainPageTitle": null, "AnnotationParams": { + "Background": { + "Margin": 0.20 + }, "DefaultAnnotation": { "Width": 1, "Height": 0.5,