|
|
|
|
@@ -1,4 +1,4 @@
|
|
|
|
|
@page "/reportviewer/"
|
|
|
|
|
@page "/receiver"
|
|
|
|
|
@using System.Drawing
|
|
|
|
|
@using DevExpress.Drawing
|
|
|
|
|
@using DevExpress.Utils
|
|
|
|
|
@@ -17,6 +17,9 @@
|
|
|
|
|
<link href="_content/DevExpress.Blazor.Themes/blazing-berry.bs5.min.css" rel="stylesheet" />
|
|
|
|
|
<link href="_content/DevExpress.Blazor.Reporting.Viewer/css/dx-blazor-reporting-components.bs5.css" rel="stylesheet" />
|
|
|
|
|
|
|
|
|
|
<div class="receiver-page-layout">
|
|
|
|
|
|
|
|
|
|
<div class="receiver-signature-panel">
|
|
|
|
|
<div class="card m-3">
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<h5 class="card-title">Unterschrift</h5>
|
|
|
|
|
@@ -38,6 +41,7 @@
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<DxPopup @bind-Visible="SignaturePopupVisible"
|
|
|
|
|
HeaderText="Unterschrift erfassen"
|
|
|
|
|
@@ -82,6 +86,25 @@
|
|
|
|
|
<canvas id="receiver-image-signature-pad" width="520" height="160" class="border rounded bg-white w-100" style="max-width: 520px;"></canvas>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="border-top mt-3 pt-3">
|
|
|
|
|
<p class="text-muted mb-2">Bitte geben Sie die folgenden Angaben ein. Das Datum wird automatisch hinzugefuegt.</p>
|
|
|
|
|
<div class="row g-2">
|
|
|
|
|
<div class="col-12 col-md-6">
|
|
|
|
|
<label class="form-label" for="receiver-signer-name">Vor- und Nachname *</label>
|
|
|
|
|
<input id="receiver-signer-name" class="form-control" value="@SignerFullName" @oninput="args => SignerFullName = args.Value?.ToString() ?? string.Empty" />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-12 col-md-6">
|
|
|
|
|
<label class="form-label" for="receiver-signer-position">Position</label>
|
|
|
|
|
<input id="receiver-signer-position" class="form-control" value="@SignerPosition" @oninput="args => SignerPosition = args.Value?.ToString() ?? string.Empty" />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-12 col-md-6">
|
|
|
|
|
<label class="form-label" for="receiver-signature-place">Ort *</label>
|
|
|
|
|
<input id="receiver-signature-place" class="form-control" value="@SignaturePlace" @oninput="args => SignaturePlace = args.Value?.ToString() ?? string.Empty" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
@if(!string.IsNullOrWhiteSpace(PopupValidationMessage)) {
|
|
|
|
|
<div class="text-danger mt-2">@PopupValidationMessage</div>
|
|
|
|
|
}
|
|
|
|
|
@@ -95,9 +118,13 @@
|
|
|
|
|
</FooterContentTemplate>
|
|
|
|
|
</DxPopup>
|
|
|
|
|
|
|
|
|
|
<div class="receiver-viewer-wrapper">
|
|
|
|
|
@if(Report is not null) {
|
|
|
|
|
<DxReportViewer @key="ViewerKey" @ref="reportViewer" Report="Report" RootCssClasses="w-100 h-100" />
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
@code {
|
|
|
|
|
const string SignatureTabDraw = "draw";
|
|
|
|
|
@@ -125,6 +152,9 @@
|
|
|
|
|
string ActiveSignatureTab = SignatureTabDraw;
|
|
|
|
|
string TypedSignatureText = string.Empty;
|
|
|
|
|
string TypedSignatureFont = "'Brush Script MT', cursive";
|
|
|
|
|
string SignerFullName = string.Empty;
|
|
|
|
|
string SignerPosition = string.Empty;
|
|
|
|
|
string SignaturePlace = string.Empty;
|
|
|
|
|
int ViewerKey;
|
|
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync() {
|
|
|
|
|
@@ -195,6 +225,16 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async Task ApplySignatureAsync() {
|
|
|
|
|
if(string.IsNullOrWhiteSpace(SignerFullName)) {
|
|
|
|
|
PopupValidationMessage = "Bitte geben Sie Vor- und Nachname ein.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(string.IsNullOrWhiteSpace(SignaturePlace)) {
|
|
|
|
|
PopupValidationMessage = "Bitte geben Sie den Ort ein.";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var signatureDataUrl = await GetActiveSignatureDataUrlAsync();
|
|
|
|
|
|
|
|
|
|
if(string.IsNullOrWhiteSpace(signatureDataUrl)) {
|
|
|
|
|
@@ -204,7 +244,7 @@
|
|
|
|
|
|
|
|
|
|
PopupValidationMessage = null;
|
|
|
|
|
SignatureValidationMessage = null;
|
|
|
|
|
Report = CreateSignedReportInstance(signatureDataUrl);
|
|
|
|
|
Report = CreateSignedReportInstance(signatureDataUrl, SignerFullName.Trim(), SignerPosition.Trim(), SignaturePlace.Trim());
|
|
|
|
|
SignatureApplied = true;
|
|
|
|
|
SignaturePopupVisible = false;
|
|
|
|
|
ViewerKey++;
|
|
|
|
|
@@ -242,13 +282,13 @@
|
|
|
|
|
: PredefinedReports.ReportsFactory.GetReport("LargeDatasetReport");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XtraReport CreateSignedReportInstance(string signatureDataUrl) {
|
|
|
|
|
XtraReport CreateSignedReportInstance(string signatureDataUrl, string signerFullName, string signerPosition, string signaturePlace) {
|
|
|
|
|
var report = CreateReportInstance();
|
|
|
|
|
AddSignature(report, signatureDataUrl);
|
|
|
|
|
AddSignature(report, signatureDataUrl, signerFullName, signerPosition, signaturePlace);
|
|
|
|
|
return report;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void AddSignature(XtraReport report, string signatureDataUrl) {
|
|
|
|
|
static void AddSignature(XtraReport report, string signatureDataUrl, string signerFullName, string signerPosition, string signaturePlace) {
|
|
|
|
|
var imageBytes = Convert.FromBase64String(signatureDataUrl[(signatureDataUrl.IndexOf(',') + 1)..]);
|
|
|
|
|
using var imageStream = new MemoryStream(imageBytes);
|
|
|
|
|
var imageSource = new ImageSource(DXImage.FromStream(imageStream));
|
|
|
|
|
@@ -259,28 +299,53 @@
|
|
|
|
|
report.Bands.Add(bottomMargin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bottomMargin.HeightF = Math.Max(bottomMargin.HeightF, 120F);
|
|
|
|
|
RemoveExistingSignature(bottomMargin);
|
|
|
|
|
|
|
|
|
|
var signatureLabel = new XRLabel {
|
|
|
|
|
Name = "receiverSignatureLabel",
|
|
|
|
|
Text = $"Empfaengerunterschrift - {DateTime.Now:g}",
|
|
|
|
|
BoundsF = new RectangleF(390F, 6F, 230F, 18F),
|
|
|
|
|
Font = new DXFont("Open Sans", 8F, DXFontStyle.Bold),
|
|
|
|
|
ForeColor = System.Drawing.Color.FromArgb(73, 80, 87),
|
|
|
|
|
TextAlignment = TextAlignment.MiddleLeft
|
|
|
|
|
};
|
|
|
|
|
// Layout constants
|
|
|
|
|
const float sigX = 390F;
|
|
|
|
|
const float sigWidth = 230F;
|
|
|
|
|
const float sigImgHeight = 70F;
|
|
|
|
|
const float infoHeight = 65F; // up to 4 lines at 8pt
|
|
|
|
|
const float innerGap = 5F;
|
|
|
|
|
const float bottomPad = 6F;
|
|
|
|
|
const float defaultTopPad = 8F;
|
|
|
|
|
const float maxBandHeight = 210F;
|
|
|
|
|
|
|
|
|
|
float requiredHeight = defaultTopPad + sigImgHeight + innerGap + infoHeight + bottomPad;
|
|
|
|
|
|
|
|
|
|
// Grow band if needed, but cap at maxBandHeight to avoid overlapping page content
|
|
|
|
|
bottomMargin.HeightF = Math.Min(maxBandHeight, Math.Max(bottomMargin.HeightF, requiredHeight));
|
|
|
|
|
|
|
|
|
|
// If band is tighter than required, compress top padding so content still fits
|
|
|
|
|
float topPad = Math.Max(0F, bottomMargin.HeightF - bottomPad - infoHeight - innerGap - sigImgHeight);
|
|
|
|
|
|
|
|
|
|
float imageY = topPad;
|
|
|
|
|
float labelY = imageY + sigImgHeight + innerGap;
|
|
|
|
|
|
|
|
|
|
var signatureInformation = string.IsNullOrWhiteSpace(signerPosition)
|
|
|
|
|
? $"Empfaengerunterschrift\n{signerFullName}\n{signaturePlace}, {DateTime.Now:d}"
|
|
|
|
|
: $"Empfaengerunterschrift\n{signerFullName}\n{signerPosition}\n{signaturePlace}, {DateTime.Now:d}";
|
|
|
|
|
|
|
|
|
|
var signature = new XRPictureBox {
|
|
|
|
|
Name = "receiverSignatureImage",
|
|
|
|
|
ImageSource = imageSource,
|
|
|
|
|
BoundsF = new RectangleF(390F, 28F, 230F, 70F),
|
|
|
|
|
BoundsF = new RectangleF(sigX, imageY, sigWidth, sigImgHeight),
|
|
|
|
|
Sizing = ImageSizeMode.ZoomImage,
|
|
|
|
|
Borders = BorderSide.Bottom,
|
|
|
|
|
BorderColor = System.Drawing.Color.FromArgb(73, 80, 87)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bottomMargin.Controls.AddRange(new XRControl[] { signatureLabel, signature });
|
|
|
|
|
var signatureLabel = new XRLabel {
|
|
|
|
|
Name = "receiverSignatureLabel",
|
|
|
|
|
Text = signatureInformation,
|
|
|
|
|
Multiline = true,
|
|
|
|
|
BoundsF = new RectangleF(sigX, labelY, sigWidth, infoHeight),
|
|
|
|
|
Font = new DXFont("Open Sans", 8F, DXFontStyle.Regular),
|
|
|
|
|
ForeColor = System.Drawing.Color.FromArgb(73, 80, 87),
|
|
|
|
|
TextAlignment = TextAlignment.TopLeft
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bottomMargin.Controls.AddRange(new XRControl[] { signature, signatureLabel });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void RemoveExistingSignature(BottomMarginBand bottomMargin) {
|
|
|
|
|
|