Add signature workflow models, services, and configurations

Introduced new models (`SignatureDto`, `SignatureCaptureDto`, `EnvelopeReceiverDto`) to support a signature-based workflow. Added services for handling API interactions (`SignatureService`, `AuthService`, `DocumentService`, `EnvelopeReceiverService`, `SignatureCacheService`).

Enhanced configuration with `ApiOptions` and `PdfViewerOptions`. Integrated DevExpress features with custom data connection providers, in-memory report storage, and font loading utilities.

Marked `AnnotationDto` and `AnnotationService` as `[Obsolete]` in favor of newer implementations. Added detailed documentation for coordinate systems, unit conversions, and usage scenarios.
This commit is contained in:
2026-06-12 14:02:55 +02:00
parent d599fe3156
commit 1f889d8b58
21 changed files with 946 additions and 0 deletions

View File

@@ -0,0 +1,101 @@
using EnvelopeGenerator.WebUI.Client.Models.Constants;
namespace EnvelopeGenerator.WebUI.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;
}
}