using EnvelopeGenerator.ReceiverUI.Models.Constants; namespace EnvelopeGenerator.ReceiverUI.Models; /// /// 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. /// public class SignatureDto { /// Unique identifier. public int Id { get; init; } private double _x; private double _y; /// Horizontal position in INCHES from left edge. public double X { get => _x * Factor; init => _x = value; } /// Vertical position in INCHES from top edge. public double Y { get => _y * Factor; init => _y = value; } /// 1-based page number. public int Page { get; init; } /// Sender application type that created this signature. 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)}'.") }; } } }