@@ -8,17 +8,8 @@ namespace SignaturePad
8
8
public partial class SignaturePad
9
9
{
10
10
[ Parameter ]
11
- public byte [ ] Value
12
- {
13
- get => _value ;
14
- set
15
- {
16
- if ( value == _value ) return ;
17
-
18
- _value = value ;
19
- UpdateImage ( ) ;
20
- }
21
- }
11
+ public byte [ ] Value { get ; set ; } = [ ] ;
12
+
22
13
[ Parameter ]
23
14
public EventCallback < byte [ ] > ValueChanged { get ; set ; }
24
15
[ Parameter ]
@@ -36,6 +27,7 @@ public byte[] Value
36
27
public bool Disabled { get ; set ; }
37
28
38
29
30
+
39
31
/// <summary>
40
32
/// Captures all the custom attributes that are not part of BlazorBootstrap component.
41
33
/// </summary>
@@ -45,8 +37,8 @@ public byte[] Value
45
37
private readonly string _id = Guid . NewGuid ( ) . ToString ( ) ;
46
38
private readonly DotNetObjectReference < SignaturePad > _reference ;
47
39
private IJSObjectReference ? _jsModule ;
48
- private byte [ ] _value = [ ] ;
49
-
40
+
41
+
50
42
public SignaturePad ( )
51
43
{
52
44
_reference = DotNetObjectReference . Create ( this ) ;
@@ -56,19 +48,19 @@ public SignaturePad()
56
48
public async Task SignatureDataChangedAsync ( )
57
49
{
58
50
using MemoryStream memoryStream = new ( ) ;
59
- var dataReference = await _jsModule . InvokeAsync < IJSStreamReference > ( "getBase64" , _id ) ;
51
+ var dataReference = await _jsModule ! . InvokeAsync < IJSStreamReference > ( "getBase64" , _id ) ;
60
52
using var dataReferenceStream = await dataReference . OpenReadStreamAsync ( maxAllowedSize : 10_000_000 ) ;
61
53
await dataReferenceStream . CopyToAsync ( memoryStream ) ;
62
54
63
55
string base64 = Encoding . UTF8 . GetString ( memoryStream . ToArray ( ) ) ;
64
56
65
57
try
66
58
{
67
- _value = Convert . FromBase64String ( base64 ) ;
59
+ Value = Convert . FromBase64String ( base64 ) ;
68
60
}
69
61
catch ( Exception )
70
62
{
71
- _value = [ ] ;
63
+ Value = [ ] ;
72
64
}
73
65
74
66
@@ -82,6 +74,8 @@ protected async override Task OnAfterRenderAsync(bool firstRender)
82
74
{
83
75
_jsModule = await jsRuntime . InvokeAsync < IJSObjectReference > ( "import" , "./_content/Blazor.SignaturePad/sigpad.interop.js?ver=8.1.2" ) ;
84
76
await Setup ( ) ;
77
+ await Update ( ) ;
78
+ await UpdateImage ( ) ;
85
79
}
86
80
87
81
await base . OnAfterRenderAsync ( firstRender ) ;
0 commit comments