diff --git a/BlazorSRRDemo/BlazorSRRDemo/BlazorSRRDemo.csproj b/BlazorSRRDemo/BlazorSRRDemo/BlazorSRRDemo.csproj
index d7fa7ab..e611b27 100644
--- a/BlazorSRRDemo/BlazorSRRDemo/BlazorSRRDemo.csproj
+++ b/BlazorSRRDemo/BlazorSRRDemo/BlazorSRRDemo.csproj
@@ -12,4 +12,10 @@
+
+
+ true
+
+
+
diff --git a/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/BGImage.razor b/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/BGImage.razor
index c5a117a..6e66c15 100644
--- a/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/BGImage.razor
+++ b/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/BGImage.razor
@@ -1,3 +1,3 @@
@page "/BGImageDemo"
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/Disabled.razor b/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/Disabled.razor
index ea9c2ba..87c461d 100644
--- a/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/Disabled.razor
+++ b/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/Disabled.razor
@@ -1,3 +1,3 @@
@page "/Disabled"
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/ExistingSignature.razor b/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/ExistingSignature.razor
new file mode 100644
index 0000000..0144374
--- /dev/null
+++ b/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/ExistingSignature.razor
@@ -0,0 +1,4 @@
+@page "/ExistingSignature"
+
+
+
diff --git a/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/Home.razor b/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/Home.razor
index 1fa0c18..5ffc8af 100644
--- a/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/Home.razor
+++ b/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/Home.razor
@@ -1,3 +1,3 @@
@page "/"
-
+
diff --git a/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/Options.razor b/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/Options.razor
index 063dd0a..153de93 100644
--- a/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/Options.razor
+++ b/BlazorSRRDemo/BlazorSRRDemo/Components/Pages/Options.razor
@@ -1,3 +1,3 @@
@page "/OptionsDemo"
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/BlazorSRRDemo/BlazorSRRDemo/Components/_Imports.razor b/BlazorSRRDemo/BlazorSRRDemo/Components/_Imports.razor
index 55f8ef0..e0c7c2c 100644
--- a/BlazorSRRDemo/BlazorSRRDemo/Components/_Imports.razor
+++ b/BlazorSRRDemo/BlazorSRRDemo/Components/_Imports.razor
@@ -9,3 +9,4 @@
@using BlazorSRRDemo
@using BlazorSRRDemo.Components
@using Demos.Core
+@using Demos.Core.SignaturePadDemos
diff --git a/BlazorServerDemo/BlazorServerDemo.csproj b/BlazorServerDemo/BlazorServerDemo.csproj
index 20a07cb..a3ee8a2 100644
--- a/BlazorServerDemo/BlazorServerDemo.csproj
+++ b/BlazorServerDemo/BlazorServerDemo.csproj
@@ -11,4 +11,10 @@
+
+
+ true
+
+
+
diff --git a/BlazorServerDemo/Pages/ExistingSignature.razor b/BlazorServerDemo/Pages/ExistingSignature.razor
new file mode 100644
index 0000000..b13f63f
--- /dev/null
+++ b/BlazorServerDemo/Pages/ExistingSignature.razor
@@ -0,0 +1,4 @@
+@page "/ExistingSignature"
+
+
+
diff --git a/BlazorWebAssemblyDemo/BlazorWebAssemblyDemo.csproj b/BlazorWebAssemblyDemo/BlazorWebAssemblyDemo.csproj
index 1108d01..9faf3f3 100644
--- a/BlazorWebAssemblyDemo/BlazorWebAssemblyDemo.csproj
+++ b/BlazorWebAssemblyDemo/BlazorWebAssemblyDemo.csproj
@@ -16,4 +16,10 @@
+
+
+ true
+
+
+
diff --git a/BlazorWebAssemblyDemo/Pages/BGImage.razor b/BlazorWebAssemblyDemo/Pages/BGImage.razor
index 1f98455..b41e5a7 100644
--- a/BlazorWebAssemblyDemo/Pages/BGImage.razor
+++ b/BlazorWebAssemblyDemo/Pages/BGImage.razor
@@ -1,3 +1,3 @@
@page "/BGImageDemo"
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/BlazorWebAssemblyDemo/Pages/Disabled.razor b/BlazorWebAssemblyDemo/Pages/Disabled.razor
index 4c1bcb8..a4c6aaf 100644
--- a/BlazorWebAssemblyDemo/Pages/Disabled.razor
+++ b/BlazorWebAssemblyDemo/Pages/Disabled.razor
@@ -1,3 +1,3 @@
@page "/Disabled"
-
+
diff --git a/BlazorWebAssemblyDemo/Pages/ExistingSignature.razor b/BlazorWebAssemblyDemo/Pages/ExistingSignature.razor
new file mode 100644
index 0000000..208b369
--- /dev/null
+++ b/BlazorWebAssemblyDemo/Pages/ExistingSignature.razor
@@ -0,0 +1,5 @@
+@page "/ExistingSignature"
+
+
+
+
diff --git a/BlazorWebAssemblyDemo/Pages/Home.razor b/BlazorWebAssemblyDemo/Pages/Home.razor
index b77e2d8..4f6fa2b 100644
--- a/BlazorWebAssemblyDemo/Pages/Home.razor
+++ b/BlazorWebAssemblyDemo/Pages/Home.razor
@@ -6,4 +6,4 @@
Welcome to your new app.
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/BlazorWebAssemblyDemo/Pages/Options.razor b/BlazorWebAssemblyDemo/Pages/Options.razor
index 535df83..5d80d2a 100644
--- a/BlazorWebAssemblyDemo/Pages/Options.razor
+++ b/BlazorWebAssemblyDemo/Pages/Options.razor
@@ -1,3 +1,3 @@
@page "/OptionsDemo"
-
+
diff --git a/BlazorWebAssemblyDemo/_Imports.razor b/BlazorWebAssemblyDemo/_Imports.razor
index 4a7e07f..a43e819 100644
--- a/BlazorWebAssemblyDemo/_Imports.razor
+++ b/BlazorWebAssemblyDemo/_Imports.razor
@@ -9,3 +9,4 @@
@using BlazorWebAssemblyDemo
@using BlazorWebAssemblyDemo.Layout
@using Demos.Core
+@using Demos.Core.SignaturePadDemos
\ No newline at end of file
diff --git a/Demos.Core/Demos.Core.csproj b/Demos.Core/Demos.Core.csproj
index 33bc615..d9eedb4 100644
--- a/Demos.Core/Demos.Core.csproj
+++ b/Demos.Core/Demos.Core.csproj
@@ -19,4 +19,10 @@
+
+
+ true
+
+
+
diff --git a/Demos.Core/NavMenu.razor b/Demos.Core/NavMenu.razor
index 699b882..6f1bbb2 100644
--- a/Demos.Core/NavMenu.razor
+++ b/Demos.Core/NavMenu.razor
@@ -29,6 +29,12 @@
+
+
+ Existing signature
+
+
+
BG Image
diff --git a/Demos.Core/SignaturePadDemos/ExistingSignatureDemo.razor b/Demos.Core/SignaturePadDemos/ExistingSignatureDemo.razor
new file mode 100644
index 0000000..c69ae1b
--- /dev/null
+++ b/Demos.Core/SignaturePadDemos/ExistingSignatureDemo.razor
@@ -0,0 +1,45 @@
+@using System.Text
+@inject NavigationManager navigationManager
+@inject SignatureInMemoryService memoryService
+
+SignaturePad Default Demo
+
+
+
+@if (Input.Signature.Any())
+{
+ Signature
+
+
+
+}
+
+@if(memoryService.Signature.Any())
+{
+
+}
+
+@code {
+ public MyInput Input { get; set; } = new();
+
+ public ExistingSignatureDemo()
+ {
+ Input.Signature = Encoding.UTF8.GetBytes("data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAALgAAAA5CAYAAACF3+G6AAAAAXNSR0IArs4c6QAADlZJREFUeF7t3QOULFkSBuB/1rZt27Zt88zatm3be9actW3bmLVtz25+b+7dyZed1ZXVXV1d3ZVxTp3u1y95b9y4EX/8EbVPRpnHCBwuyY2T+Pm3JP8sn88m+eqEG5wiyVmSnC7JX5NcJslxkhwqyeGTHKVc7x9J9kvyqSRfT/KOeTzwqlxjn1V50Rnf8xBJLlAU7YxJTp3k4ElOleT0SQ5b/j3jZfccXpX/CBs5uZzzsyTvTPKlJN9sFscnkvx2E9fbtaeuqoKfO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AdDmrrCiaG9el8qInMwjqR7V/gyTtyFT5dk/ePBRcSZlApgaPkgYmBuPMNsrnxjNHihJsWhA+6vZqIyDkHRCXifVMrgGj3UnlYpQWr75WN1WLDPZUDd79huf23Au0KTQLzZVTHK3CaZRNjsA8FNwjYPE9sHCJ53XNIa/GBerezxfMon1aLFXZplFA2/cCpakiomBS15XzIjC2M6GLYlyyvu3i2r5n6b6DMj4cauV2dj3Y/ui6DZnpDR4zb2V8UCk0wM3ezULxawKllmlVi2sB2MHsXPV3C0ajoJVJsCzL5P8Pkg7Vm1kdRBkAAAAASUVORK5CYII=");
+ }
+
+ private void SaveSignature()
+ {
+ memoryService.Signature = Input.Signature;
+ }
+
+ private void OpenSignature()
+ {
+ navigationManager.NavigateTo(Input.SignatureAsBase64);
+ }
+
+ private void ReadSignature()
+ {
+ Input.Signature = memoryService.Signature;
+ StateHasChanged();
+ }
+}
diff --git a/SignaturePad/SignaturePad.razor.cs b/SignaturePad/SignaturePad.razor.cs
index f26c3d8..e7460a2 100644
--- a/SignaturePad/SignaturePad.razor.cs
+++ b/SignaturePad/SignaturePad.razor.cs
@@ -8,17 +8,8 @@ namespace SignaturePad
public partial class SignaturePad
{
[Parameter]
- public byte[] Value
- {
- get => _value;
- set
- {
- if (value == _value) return;
-
- _value = value;
- UpdateImage();
- }
- }
+ public byte[] Value { get; set; } = [];
+
[Parameter]
public EventCallback ValueChanged { get; set; }
[Parameter]
@@ -36,6 +27,7 @@ public byte[] Value
public bool Disabled { get; set; }
+
///
/// Captures all the custom attributes that are not part of BlazorBootstrap component.
///
@@ -45,8 +37,8 @@ public byte[] Value
private readonly string _id = Guid.NewGuid().ToString();
private readonly DotNetObjectReference _reference;
private IJSObjectReference? _jsModule;
- private byte[] _value = [];
-
+
+
public SignaturePad()
{
_reference = DotNetObjectReference.Create(this);
@@ -56,7 +48,7 @@ public SignaturePad()
public async Task SignatureDataChangedAsync()
{
using MemoryStream memoryStream = new();
- var dataReference = await _jsModule.InvokeAsync("getBase64", _id);
+ var dataReference = await _jsModule!.InvokeAsync("getBase64", _id);
using var dataReferenceStream = await dataReference.OpenReadStreamAsync(maxAllowedSize: 10_000_000);
await dataReferenceStream.CopyToAsync(memoryStream);
@@ -64,11 +56,11 @@ public async Task SignatureDataChangedAsync()
try
{
- _value = Convert.FromBase64String(base64);
+ Value = Convert.FromBase64String(base64);
}
catch (Exception)
{
- _value = [];
+ Value = [];
}
@@ -82,6 +74,8 @@ protected async override Task OnAfterRenderAsync(bool firstRender)
{
_jsModule = await jsRuntime.InvokeAsync("import", "./_content/Blazor.SignaturePad/sigpad.interop.js?ver=8.1.2");
await Setup();
+ await Update();
+ await UpdateImage();
}
await base.OnAfterRenderAsync(firstRender);