Compare commits

...

15 Commits

Author SHA1 Message Date
Developer 02
eb024acfa7 featAnnotation): Hinzufügen von Verhältnisanteilen, um die Konfiguration über das Verhältnis zu ermöglichen 2025-03-20 17:16:42 +01:00
Developer 02
210ce072f8 refactor(AnnotationParams): vereinfacht 2025-03-20 17:01:13 +01:00
Developer 02
036e1f68a8 refactor(Annotation): Default.set hinzugefügt, um Standardwerte zu setzen 2025-03-20 16:48:42 +01:00
Developer 02
0b87a3746a fix(Annotation): Aktualisiert, um MarginLeft und Top bei der Berechnung von HorBoundary und VerBoundary zu berücksichtigen 2025-03-20 15:52:21 +01:00
Developer 02
db84abf0e7 feat(Anmerkung): JsonIgnore-Attribut für nicht-clientbezogene Entitäten hinzugefügt 2025-03-20 14:58:41 +01:00
Developer 02
14be46d3d6 refactor(Annotation): Umbenennen von left in marginLeft, top in marginTop, posX in Left und posY in top für eine CSS-ähnlichere Benennung 2025-03-20 14:56:36 +01:00
Developer 02
78b5e3f5cc feat(Annotations): Konvertiere _annots von Dictionary zu IEnumerable.
- Zugehörige Index- und TryGet-Methoden hinzugefügt.
2025-03-20 14:44:57 +01:00
Developer 02
093e64de81 feat(Annotation): Hinzufügen der Eigenschaft Name 2025-03-20 14:27:58 +01:00
Developer 02
43db4e275b fix(Annotation): JsonIgnore-Attribut zu HorBoundAnnot und VerBoundAnnot hinzufügen 2025-03-20 12:46:57 +01:00
Developer 02
353f7698f4 feat(ConfigController): Erstellt, um Webanwendungen über den Server zu konfigurieren.
- GetAnnotationParams Endpunkt hinzufügen, um Annotationsdaten zu senden
2025-03-20 11:50:59 +01:00
Developer 02
d5b4ea46d3 feat(DefaultAnnotation): Hinzufügen der Möglichkeit, eine Annotation mit zentralen Standardwerten zu konfigurieren. 2025-03-20 11:39:40 +01:00
Developer 02
b6563d71b0 feat(Annotation): marginX in left und marginY in top umbenannt. 2025-03-20 10:27:53 +01:00
Developer 02
8a6a11c1bc feat(AnnotationParams): Aktualisiert, um Standardwerte in Annots.init zu setzen. 2025-03-20 10:23:33 +01:00
Developer 02
cbd71aa2b9 feat(AnnotationParams): Logik zur Initialisierung von gebundenen Annotationen hinzugefügt Annots.init 2025-03-20 09:41:51 +01:00
Developer 02
df019a7243 feat(AnnotationParams): Erstellt, um Annotationen über Appsettings zu konfigurieren. 2025-03-20 09:22:36 +01:00
5 changed files with 167 additions and 22 deletions

View File

@@ -0,0 +1,23 @@
using EnvelopeGenerator.Web.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
namespace EnvelopeGenerator.Web.Controllers;
[Route("api/[controller]")]
[ApiController]
public class ConfigController : ControllerBase
{
private readonly AnnotationParams _annotParams;
public ConfigController(IOptions<AnnotationParams> annotationParamsOptions)
{
_annotParams = annotationParamsOptions.Value;
}
[HttpGet("Annotations")]
public IActionResult GetAnnotationParams()
{
return Ok(_annotParams);
}
}

View File

@@ -1,58 +1,106 @@
namespace EnvelopeGenerator.Web.Models;
using System.Text.Json.Serialization;
public record Annotation(
string Id,
string? HorBoundAnnotId = null, string? VerBoundAnnotId = null)
namespace EnvelopeGenerator.Web.Models;
public record Annotation
{
#region Layout
internal double _marginX = default;
public required string Name { get; init; }
internal double _marginY = default;
#region Bound Annotation
[JsonIgnore]
public string? HorBoundAnnotName { get; init; }
[JsonIgnore]
public string? VerBoundAnnotName { get; init; }
#endregion
#region Layout
internal double _marginLeft = default;
internal double _marginTop = default;
internal double _width = default;
internal double _height = default;
public double MarginX
[JsonIgnore]
public double MarginLeft
{
get => _marginX;
init => _marginX = value;
get => _marginLeft;
init => _marginLeft = value;
}
public double MarginY
[JsonIgnore]
public double MarginLeftRatio { get; init; } = 1;
[JsonIgnore]
public double MarginTop
{
get => _marginY;
init => _marginY = value;
get => _marginTop;
init => _marginTop = value;
}
[JsonIgnore]
public double MarginTopRatio { get; init; } = 1;
public double Width
{
get => _width;
init => _width = value;
}
[JsonIgnore]
public double WidthRatio { get; init; } = 1;
public double Height
{
get => _height;
init => _height = value;
}
[JsonIgnore]
public double HeightRatio { get; init; } = 1;
#endregion
#region Pos
public double PosX => MarginX + (HorBoundAnnot?.HorBoundary ?? 0);
#region Position
public double Left => MarginLeft + (HorBoundAnnot?.HorBoundary ?? 0);
public double PosY => MarginY + (VerBoundAnnot?.VerBoundary ?? 0);
public double Top => MarginTop + (VerBoundAnnot?.VerBoundary ?? 0);
#endregion
#region Boundary
public double HorBoundary => MarginX + Width;
[JsonIgnore]
public double HorBoundary => Left + Width;
public double VerBoundary => MarginY + Height;
[JsonIgnore]
public double VerBoundary => Top + Height;
#endregion
#region BoundAnnot
public Annot? HorBoundAnnot { get; set; }
[JsonIgnore]
public Annotation? HorBoundAnnot { get; set; }
public Annot? VerBoundAnnot { get; set; }
[JsonIgnore]
public Annotation? VerBoundAnnot { get; set; }
#endregion
[JsonIgnore]
internal Annotation Default
{
set
{
// To set default value, annotation must have default (0) value but default must has non-default value
if (_marginLeft == default && value.MarginLeft != default)
_marginLeft = value.MarginLeft * MarginLeftRatio;
if (_marginTop == default && value.MarginTop != default)
_marginTop = value.MarginTop * MarginTopRatio;
if (_width == default && value.Width != default)
_width = value.Width * WidthRatio;
if (_height == default && value.Height != default)
_height = value.Height * HeightRatio;
}
}
};

View File

@@ -0,0 +1,53 @@
using System.Text.Json.Serialization;
namespace EnvelopeGenerator.Web.Models;
public class AnnotationParams
{
[JsonIgnore]
public Annotation? DefaultAnnotation { get; init; }
private readonly IEnumerable<Annotation> _annots = new List<Annotation>();
public Annotation this[string name] => _annots.First(a => a.Name == name);
public bool TryGet(string name, out Annotation annotation)
{
#pragma warning disable CS8601 // Possible null reference assignment.
annotation = _annots.FirstOrDefault(a => a.Name == name);
#pragma warning restore CS8601 // Possible null reference assignment.
return annotation is not null;
}
public required IEnumerable<Annotation> Annotations
{
get => _annots;
init
{
_annots = value;
if (DefaultAnnotation is not null)
foreach (var annot in _annots)
annot.Default = DefaultAnnotation;
foreach (var annot in _annots)
{
#region set bound annotations
// horizontal
if (annot.HorBoundAnnotName is string horBoundAnnotName)
if (TryGet(horBoundAnnotName, out var horBoundAnnot))
annot.HorBoundAnnot = horBoundAnnot;
else
throw new InvalidOperationException($"{horBoundAnnotName} added as bound anotation. However, it is not defined.");
// vertical
if (annot.VerBoundAnnotName is string verBoundAnnotName)
if (TryGet(verBoundAnnotName, out var verBoundAnnot))
annot.VerBoundAnnot = verBoundAnnot;
else
throw new InvalidOperationException($"{verBoundAnnotName} added as bound anotation. However, it is not defined.");
#endregion
}
}
}
}

View File

@@ -163,6 +163,8 @@ try
builder.ConfigureBySection<CustomImages>();
builder.ConfigureBySection<AnnotationParams>();
var app = builder.Build();
// Configure the HTTP request pipeline.

View File

@@ -149,5 +149,24 @@
"EnvelopeReceiverReadOnly": [ "TBSIG_ENVELOPE_RECEIVER_READ_ONLY_UPD" ],
"Receiver": []
},
"MainPageTitle": null
"MainPageTitle": null,
"AnnotationParams": {
"DefaultAnnotation": {
"Width": 1,
"Height": 0.5
},
"Annotations": [
{
"Name": "Signature"
},
{
"Name": "City",
"VerBoundAnnotName": "Signature"
},
{
"Name": "Date",
"VerBoundAnnotName": "City"
}
]
}
}