diff --git a/EgwCoreLib.BlazorTest/Pages/TestPdfViewer.razor b/EgwCoreLib.BlazorTest/Pages/TestPdfViewer.razor
new file mode 100644
index 0000000..02c751e
--- /dev/null
+++ b/EgwCoreLib.BlazorTest/Pages/TestPdfViewer.razor
@@ -0,0 +1,24 @@
+@page "/TestPdfViewer"
+
+
+
+
+
Selezione: @FileSel
+
+
+
diff --git a/EgwCoreLib.BlazorTest/Pages/TestPdfViewer.razor.cs b/EgwCoreLib.BlazorTest/Pages/TestPdfViewer.razor.cs
new file mode 100644
index 0000000..5bb0a6f
--- /dev/null
+++ b/EgwCoreLib.BlazorTest/Pages/TestPdfViewer.razor.cs
@@ -0,0 +1,19 @@
+namespace EgwCoreLib.BlazorTest.Pages
+{
+ public partial class TestPdfViewer
+ {
+ protected string FileSel
+ {
+ get => fileSel;
+ set
+ {
+ if (fileSel != value)
+ {
+ fileSel = value;
+ StateHasChanged();
+ }
+ }
+ }
+ private string fileSel { get; set; } = "File01.pdf";
+ }
+}
\ No newline at end of file
diff --git a/EgwCoreLib.BlazorTest/Pages/_Layout.cshtml b/EgwCoreLib.BlazorTest/Pages/_Layout.cshtml
index f3cbc14..48d1302 100644
--- a/EgwCoreLib.BlazorTest/Pages/_Layout.cshtml
+++ b/EgwCoreLib.BlazorTest/Pages/_Layout.cshtml
@@ -44,9 +44,17 @@
onConnectionUp: () => console.log("Client reconnected!")
}
}).then(() => {
- Blazor.defaultReconnectionHandler._reconnectCallback = function (d) {
- document.location.reload();
- }
+ Object.defineProperty(Blazor.defaultReconnectionHandler, '_reconnectionDisplay', {
+ get() {
+ return this.__reconnectionDisplay;
+ },
+ set(value) {
+ this.__reconnectionDisplay = {
+ show: () => value.show(),
+ update: (d) => value.update(d),
+ rejected: (d) => document.location.reload()
+ }
+ }
});
});
diff --git a/EgwCoreLib.BlazorTest/wwwroot/test/File01.pdf b/EgwCoreLib.BlazorTest/wwwroot/test/File01.pdf
new file mode 100644
index 0000000..de5ec71
Binary files /dev/null and b/EgwCoreLib.BlazorTest/wwwroot/test/File01.pdf differ
diff --git a/EgwCoreLib.BlazorTest/wwwroot/test/File02.pdf b/EgwCoreLib.BlazorTest/wwwroot/test/File02.pdf
new file mode 100644
index 0000000..d7dc79c
Binary files /dev/null and b/EgwCoreLib.BlazorTest/wwwroot/test/File02.pdf differ
diff --git a/EgwCoreLib.BlazorTest/wwwroot/test/File03.pdf b/EgwCoreLib.BlazorTest/wwwroot/test/File03.pdf
new file mode 100644
index 0000000..9bd45aa
Binary files /dev/null and b/EgwCoreLib.BlazorTest/wwwroot/test/File03.pdf differ
diff --git a/EgwCoreLib.BlazorTest/wwwroot/test/File04.pdf b/EgwCoreLib.BlazorTest/wwwroot/test/File04.pdf
new file mode 100644
index 0000000..7bcc17f
Binary files /dev/null and b/EgwCoreLib.BlazorTest/wwwroot/test/File04.pdf differ
diff --git a/EgwCoreLib.BlazorTest/wwwroot/test/File05.pdf b/EgwCoreLib.BlazorTest/wwwroot/test/File05.pdf
new file mode 100644
index 0000000..5860114
Binary files /dev/null and b/EgwCoreLib.BlazorTest/wwwroot/test/File05.pdf differ
diff --git a/EgwCoreLib.Razor/EgwCoreLib.Razor.csproj b/EgwCoreLib.Razor/EgwCoreLib.Razor.csproj
index 9a99e29..06ac4f4 100644
--- a/EgwCoreLib.Razor/EgwCoreLib.Razor.csproj
+++ b/EgwCoreLib.Razor/EgwCoreLib.Razor.csproj
@@ -33,6 +33,7 @@
+
@@ -52,6 +53,7 @@
true
PreserveNewest
+
diff --git a/EgwCoreLib.Razor/PdfViewer.razor b/EgwCoreLib.Razor/PdfViewer.razor
index 2c8e950..3465e75 100644
--- a/EgwCoreLib.Razor/PdfViewer.razor
+++ b/EgwCoreLib.Razor/PdfViewer.razor
@@ -1,12 +1,10 @@
-
- @if (isMobile)
- {
-
Mobile
-
- }
- else
- {
- Desktop
-
- }
-
\ No newline at end of file
+@if (isMobile)
+{
+ Mobile
+
+}
+else
+{
+ Desktop
+
+}
diff --git a/EgwCoreLib.Razor/PdfViewer.razor.cs b/EgwCoreLib.Razor/PdfViewer.razor.cs
index d1cbe33..cd56f7b 100644
--- a/EgwCoreLib.Razor/PdfViewer.razor.cs
+++ b/EgwCoreLib.Razor/PdfViewer.razor.cs
@@ -1,5 +1,9 @@
using Microsoft.AspNetCore.Components;
+using Microsoft.Extensions.Options;
using Microsoft.JSInterop;
+using System.Diagnostics.CodeAnalysis;
+using System.Xml.Linq;
+using ZXingBlazor.Components;
namespace EgwCoreLib.Razor
{
@@ -14,11 +18,13 @@ namespace EgwCoreLib.Razor
///
/// Larghezza desiderata
///
+ [Parameter]
public string Width { get; set; } = "100%";
///
/// Altezza desiderata
///
- public string Height { get; set; } = "60%";
+ [Parameter]
+ public string Height { get; set; } = "80%";
///
/// Boolean Mobile vs Desktop
@@ -26,12 +32,23 @@ namespace EgwCoreLib.Razor
private bool isMobile { get; set; }
[Inject]
- protected IJSRuntime JSRuntime { get; set; } = null!;
+ [NotNull]
+ private IJSRuntime? JS { get; set; }
+
+ private IJSObjectReference? module;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
+ try
+ {
+ if (!firstRender) return;
+
+ module = await JS.InvokeAsync("import", "./_content/EgwCoreLib.Razor/PdfViewer.razor.js");
+ isMobile = await JS.InvokeAsync("isDevice");
+ }
+ catch
+ { }
- isMobile = await JSRuntime.InvokeAsync("isDevice");
}
}
}
\ No newline at end of file
diff --git a/EgwCoreLib.Razor/PdfViewer.razor.js b/EgwCoreLib.Razor/PdfViewer.razor.js
new file mode 100644
index 0000000..951d596
--- /dev/null
+++ b/EgwCoreLib.Razor/PdfViewer.razor.js
@@ -0,0 +1,3 @@
+function isDevice() {
+ return /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini|mobile/i.test(navigator.userAgent);
+}
\ No newline at end of file