Replaced all EnvelopeGenerator.GeneratorAPI namespaces with EnvelopeGenerator.API across controllers, models, extensions, middleware, and annotation-related files. Updated using/import statements and namespace declarations accordingly. Added wwwroot folder to project file. Minor code adjustments made for consistency. This unifies API naming for improved clarity and maintainability.
93 lines
2.3 KiB
C#
93 lines
2.3 KiB
C#
using EnvelopeGenerator.API.Models.PsPdfKitAnnotation;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace EnvelopeGenerator.API.Models.PsPdfKitAnnotation;
|
|
|
|
public record Annotation : IAnnotation
|
|
{
|
|
public required string Name { get; init; }
|
|
|
|
#region Bound Annotation
|
|
[JsonIgnore]
|
|
public string? HorBoundAnnotName { get; init; }
|
|
|
|
[JsonIgnore]
|
|
public string? VerBoundAnnotName { get; init; }
|
|
#endregion
|
|
|
|
#region Layout
|
|
[JsonIgnore]
|
|
public double? MarginLeft { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public double MarginLeftRatio { get; init; } = 1;
|
|
|
|
[JsonIgnore]
|
|
public double? MarginTop { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public double MarginTopRatio { get; init; } = 1;
|
|
|
|
public double? Width { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public double WidthRatio { get; init; } = 1;
|
|
|
|
public double? Height { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public double HeightRatio { get; init; } = 1;
|
|
#endregion
|
|
|
|
#region Position
|
|
public double Left => (MarginLeft ?? 0) + (HorBoundAnnot?.HorBoundary ?? 0);
|
|
|
|
public double Top => (MarginTop ?? 0) + (VerBoundAnnot?.VerBoundary ?? 0);
|
|
#endregion
|
|
|
|
#region Boundary
|
|
[JsonIgnore]
|
|
public double HorBoundary => Left + (Width ?? 0);
|
|
|
|
[JsonIgnore]
|
|
public double VerBoundary => Top + (Height ?? 0);
|
|
#endregion
|
|
|
|
#region BoundAnnot
|
|
[JsonIgnore]
|
|
public Annotation? HorBoundAnnot { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public Annotation? VerBoundAnnot { get; set; }
|
|
#endregion
|
|
|
|
public Color? BackgroundColor { get; init; }
|
|
|
|
#region Border
|
|
public Color? BorderColor { get; init; }
|
|
|
|
public string? BorderStyle { get; init; }
|
|
|
|
public int? BorderWidth { get; set; }
|
|
#endregion
|
|
|
|
[JsonIgnore]
|
|
internal Annotation Default
|
|
{
|
|
set
|
|
{
|
|
// 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 == null && value.MarginTop != null)
|
|
MarginTop = value.MarginTop * MarginTopRatio;
|
|
|
|
if (Width == null && value.Width != null)
|
|
Width = value.Width * WidthRatio;
|
|
|
|
if (Height == null && value.Height != null)
|
|
Height = value.Height * HeightRatio;
|
|
}
|
|
}
|
|
}; |