From a7b980bd2896c328db44dcdda579372fac7290ec Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Fri, 21 Mar 2025 14:13:49 +0100 Subject: [PATCH] refactor(Annotation): Aktualisiert, um null anstelle von Standard zu verwenden --- EnvelopeGenerator.Web/Models/Annotation.cs | 58 +++++++--------------- EnvelopeGenerator.Web/appsettings.json | 6 ++- 2 files changed, 21 insertions(+), 43 deletions(-) diff --git a/EnvelopeGenerator.Web/Models/Annotation.cs b/EnvelopeGenerator.Web/Models/Annotation.cs index fd54b68f..6db0265a 100644 --- a/EnvelopeGenerator.Web/Models/Annotation.cs +++ b/EnvelopeGenerator.Web/Models/Annotation.cs @@ -15,65 +15,41 @@ public record Annotation #endregion #region Layout - internal double _marginLeft = default; - - internal double _marginTop = default; - - internal double _width = default; - - internal double _height = default; - [JsonIgnore] - public double MarginLeft - { - get => _marginLeft; - init => _marginLeft = value; - } + public double? MarginLeft { get; set; } [JsonIgnore] public double MarginLeftRatio { get; init; } = 1; [JsonIgnore] - public double MarginTop - { - get => _marginTop; - init => _marginTop = value; - } + public double? MarginTop { get; set; } [JsonIgnore] public double MarginTopRatio { get; init; } = 1; - public double Width - { - get => _width; - init => _width = value; - } + public double? Width { get; set; } [JsonIgnore] public double WidthRatio { get; init; } = 1; - public double Height - { - get => _height; - init => _height = value; - } + public double? Height { get; set; } [JsonIgnore] public double HeightRatio { get; init; } = 1; #endregion #region Position - public double Left => MarginLeft + (HorBoundAnnot?.HorBoundary ?? 0); + public double Left => (MarginLeft ?? 0) + (HorBoundAnnot?.HorBoundary ?? 0); - public double Top => MarginTop + (VerBoundAnnot?.VerBoundary ?? 0); + public double Top => (MarginTop ?? 0) + (VerBoundAnnot?.VerBoundary ?? 0); #endregion #region Boundary [JsonIgnore] - public double HorBoundary => Left + Width; + public double HorBoundary => Left + (Width ?? 0); [JsonIgnore] - public double VerBoundary => Top + Height; + public double VerBoundary => Top + (Height ?? 0); #endregion #region BoundAnnot @@ -89,18 +65,18 @@ public record Annotation { 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; + // To set null value, annotation must have null (0) value but null must has non-null value + if (MarginLeft == null && value.MarginLeft != null) + MarginLeft = value.MarginLeft * MarginLeftRatio; - if (_marginTop == default && value.MarginTop != default) - _marginTop = value.MarginTop * MarginTopRatio; + if (MarginTop == null && value.MarginTop != null) + MarginTop = value.MarginTop * MarginTopRatio; - if (_width == default && value.Width != default) - _width = value.Width * WidthRatio; + if (Width == null && value.Width != null) + Width = value.Width * WidthRatio; - if (_height == default && value.Height != default) - _height = value.Height * HeightRatio; + if (Height == null && value.Height != null) + Height = value.Height * HeightRatio; } } }; \ No newline at end of file diff --git a/EnvelopeGenerator.Web/appsettings.json b/EnvelopeGenerator.Web/appsettings.json index d62f2cc0..c9db9ee2 100644 --- a/EnvelopeGenerator.Web/appsettings.json +++ b/EnvelopeGenerator.Web/appsettings.json @@ -153,11 +153,13 @@ "AnnotationParams": { "DefaultAnnotation": { "Width": 1, - "Height": 0.5 + "Height": 0.5, + "MarginTop": 1 }, "Annotations": [ { - "Name": "Signature" + "Name": "Signature", + "MarginTop": 0 }, { "Name": "City",