From 036e1f68a88ca6222c8b71f7a90d07d711bb6a71 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Thu, 20 Mar 2025 16:48:42 +0100 Subject: [PATCH] =?UTF-8?q?refactor(Annotation):=20Default.set=20hinzugef?= =?UTF-8?q?=C3=BCgt,=20um=20Standardwerte=20zu=20setzen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EnvelopeGenerator.Web/Models/Annotation.cs | 20 +++++++++++++++++ .../Models/AnnotationParams.cs | 22 ++++--------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/EnvelopeGenerator.Web/Models/Annotation.cs b/EnvelopeGenerator.Web/Models/Annotation.cs index 215ef046..448365ed 100644 --- a/EnvelopeGenerator.Web/Models/Annotation.cs +++ b/EnvelopeGenerator.Web/Models/Annotation.cs @@ -71,4 +71,24 @@ public record Annotation [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; + + if (_marginTop == default && value.MarginTop != default) + _marginTop = value.MarginTop; + + if (_width == default && value.Width != default) + _width = value.Width; + + if (_height == default && value.Height != default) + _height = value.Height; + } + } }; \ No newline at end of file diff --git a/EnvelopeGenerator.Web/Models/AnnotationParams.cs b/EnvelopeGenerator.Web/Models/AnnotationParams.cs index 0a81004b..68997f6e 100644 --- a/EnvelopeGenerator.Web/Models/AnnotationParams.cs +++ b/EnvelopeGenerator.Web/Models/AnnotationParams.cs @@ -29,26 +29,12 @@ public class AnnotationParams { _annots = value; + if (DefaultAnnotation is not null) + foreach (var annot in _annots) + annot.Default = DefaultAnnotation; + foreach (var name in Names) { - #region set default values - if(DefaultAnnotation is not null) - { - // To set default value, annotation must have default (0) value but default must has non-default value - if (this[name]._marginLeft == default && DefaultAnnotation.MarginLeft != default) - this[name]._marginLeft = DefaultAnnotation.MarginLeft; - - if (this[name]._marginTop == default && DefaultAnnotation.MarginTop != default) - this[name]._marginTop = DefaultAnnotation.MarginTop; - - if (this[name]._width == default && DefaultAnnotation.Width != default) - this[name]._width = DefaultAnnotation.Width; - - if (this[name]._height == default && DefaultAnnotation.Height != default) - this[name]._height = DefaultAnnotation.Height; - } - #endregion - #region set bound annotations // horizontal if (this[name].HorBoundAnnotName is string horBoundAnnotName)