Renamed namespaces and related identifiers from EnvelopeGenerator.WebUI to EnvelopeGenerator.Server across the project. This change affects data models, services, controllers, and configuration files to ensure consistency with the new architecture. Updated @using directives in Razor components and other files to reflect the new namespace structure. Adjusted project references in EnvelopeGenerator.Server.csproj to point to the new EnvelopeGenerator.Server.Client project. Modified middleware and logging configurations to use the new EnvelopeGenerator.Server namespace, including changes in Program.cs and appsettings.json. Updated resource and file references to use the new EnvelopeGenerator.Server path, ensuring correct resource loading. Adjusted configuration options in Program.cs to use the new namespace for options classes, such as ApiOptions and PdfViewerOptions. Updated authentication scheme names and related constants to align with the new namespace structure. Revised comments and documentation to reflect the new namespace, ensuring clarity and consistency in the codebase.
101 lines
3.5 KiB
C#
101 lines
3.5 KiB
C#
using EnvelopeGenerator.Server.Client.Models.Constants;
|
|
|
|
namespace EnvelopeGenerator.Server.Client.Models;
|
|
|
|
/// <summary>
|
|
/// Represents a signature position on a PDF page.
|
|
/// Coordinates stored in INCHES (GdPicture14 native unit).
|
|
/// Origin: Top-left corner, X increases right, Y increases down.
|
|
/// </summary>
|
|
public class SignatureDto
|
|
{
|
|
/// <summary>Unique identifier.</summary>
|
|
public int Id { get; init; }
|
|
|
|
private double _x;
|
|
private double _y;
|
|
|
|
/// <summary>Horizontal position in INCHES from left edge.</summary>
|
|
public double X
|
|
{
|
|
get => _x * Factor;
|
|
init => _x = value;
|
|
}
|
|
|
|
/// <summary>Vertical position in INCHES from top edge.</summary>
|
|
public double Y
|
|
{
|
|
get => _y * Factor;
|
|
init => _y = value;
|
|
}
|
|
|
|
/// <summary>1-based page number.</summary>
|
|
public int Page { get; init; }
|
|
|
|
/// <summary>Sender application type that created this signature.</summary>
|
|
public SenderAppType SenderAppType { get; init; }
|
|
|
|
private UnitOfLength _unitOfLength;
|
|
|
|
public SignatureDto Convert(UnitOfLength unitOfLength)
|
|
{
|
|
_unitOfLength = unitOfLength;
|
|
return this;
|
|
}
|
|
|
|
public double Factor
|
|
{
|
|
get
|
|
{
|
|
if (SenderAppType != SenderAppType.LegacyFormApp)
|
|
{
|
|
throw new NotImplementedException(
|
|
$"SenderAppType '{SenderAppType}' is not yet implemented. " +
|
|
$"Currently, only '{nameof(SenderAppType.LegacyFormApp)}' is supported. " +
|
|
$"Future implementations will handle '{nameof(SenderAppType.ReceiverUIBlazorApp)}' and other types.");
|
|
}
|
|
|
|
// LegacyFormApp uses GdPicture14 with INCHES
|
|
return _unitOfLength switch
|
|
{
|
|
UnitOfLength.Inch => 1.0, // No conversion needed: INCHES → INCHES
|
|
UnitOfLength.Point => 72.0, // INCHES → PDF Points: 1 inch = 72 points (PDF standard, NOT pixels!)
|
|
_ => throw new InvalidOperationException(
|
|
$"Unknown UnitOfLength: {_unitOfLength}. Expected '{nameof(UnitOfLength.Inch)}' or '{nameof(UnitOfLength.Point)}'.")
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
public static class SignatureDtoExtensions
|
|
{
|
|
/// <summary>
|
|
/// Converts all signatures in the collection to the specified unit of length.
|
|
/// </summary>
|
|
/// <typeparam name="T">Type of the collection (IEnumerable, List, etc.)</typeparam>
|
|
/// <param name="signatures">Collection of SignatureDto objects to convert.</param>
|
|
/// <param name="unitOfLength">Target unit of measurement (Inch or Point).</param>
|
|
/// <returns>The same collection with all signatures converted to the specified unit.</returns>
|
|
/// <exception cref="ArgumentNullException">Thrown when signatures collection is null.</exception>
|
|
/// <remarks>
|
|
/// <b>Usage:</b>
|
|
/// <code>
|
|
/// var signatures = await SignatureService.GetAsync(envelopeKey);
|
|
/// var convertedSignatures = signatures.ConvertAll(UnitOfLength.Point);
|
|
/// </code>
|
|
/// <b>Note:</b> This method modifies each SignatureDto object in place and returns the same collection.
|
|
/// </remarks>
|
|
public static T Convert<T>(this T signatures, UnitOfLength unitOfLength)
|
|
where T : IEnumerable<SignatureDto>
|
|
{
|
|
if (signatures == null)
|
|
throw new ArgumentNullException(nameof(signatures));
|
|
|
|
foreach (var signature in signatures)
|
|
{
|
|
signature.Convert(unitOfLength);
|
|
}
|
|
|
|
return signatures;
|
|
}
|
|
} |