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.
59 lines
1.5 KiB
C#
59 lines
1.5 KiB
C#
using System.Text.Json.Serialization;
|
|
|
|
namespace EnvelopeGenerator.API.Models.PsPdfKitAnnotation;
|
|
|
|
/// <summary>
|
|
/// The Background is an annotation for the PSPDF Kit. However, it has no function.
|
|
/// It is only the first annotation as a background for other annotations.
|
|
/// </summary>
|
|
public record Background : IAnnotation
|
|
{
|
|
[JsonIgnore]
|
|
public double Margin { get; init; }
|
|
|
|
public string Name { get; } = "Background";
|
|
|
|
public double? Width { get; set; }
|
|
|
|
public double? Height { get; set; }
|
|
|
|
public double Left { get; set; }
|
|
|
|
public double Top { get; set; }
|
|
|
|
public Color? BackgroundColor { get; init; }
|
|
|
|
#region Border
|
|
public Color? BorderColor { get; init; }
|
|
|
|
public string? BorderStyle { get; init; }
|
|
|
|
public int? BorderWidth { get; set; }
|
|
#endregion
|
|
|
|
public void Locate(IEnumerable<IAnnotation> annotations)
|
|
{
|
|
// set Top
|
|
if (annotations.MinBy(a => a.Top)?.Top is double minTop)
|
|
Top = minTop;
|
|
|
|
// set Left
|
|
if (annotations.MinBy(a => a.Left)?.Left is double minLeft)
|
|
Left = minLeft;
|
|
|
|
// set Width
|
|
if(annotations.MaxBy(a => a.GetRight())?.GetRight() is double maxRight)
|
|
Width = maxRight - Left;
|
|
|
|
// set Height
|
|
if (annotations.MaxBy(a => a.GetBottom())?.GetBottom() is double maxBottom)
|
|
Height = maxBottom - Top;
|
|
|
|
// add margins
|
|
Top -= Margin;
|
|
Left -= Margin;
|
|
Width += Margin * 2;
|
|
Height += Margin * 2;
|
|
}
|
|
}
|