49 lines
1.8 KiB
C#

namespace EnvelopeGenerator.Web.Models;
public class AnnotationParams: Annotation
{
private readonly Dictionary<string, Annotation> _annots = new();
public required Dictionary<string, Annotation> Annots
{
get => _annots;
init
{
_annots = value;
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
if (_annots[name].HorBoundAnnotName is string horBoundAnnotName)
if (_annots.TryGetValue(horBoundAnnotName, out var horBoundAnnot))
_annots[name].HorBoundAnnot = horBoundAnnot;
else
throw new InvalidOperationException($"{horBoundAnnotName} added as bound anotation. However, it is not defined.");
// vertical
if (_annots[name].VerBoundAnnotName is string verBoundAnnotName)
if (_annots.TryGetValue(verBoundAnnotName, out var verBoundAnnot))
_annots[name].VerBoundAnnot = verBoundAnnot;
else
throw new InvalidOperationException($"{verBoundAnnotName} added as bound anotation. However, it is not defined.");
#endregion
}
}
}
}