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 { public partial class PdfDisplay { #region Public Properties /// /// URL del documento da mostrare /// [Parameter] public string PdfUrl { get; set; } = ""; /// /// Larghezza desiderata /// [Parameter] public string Width { get; set; } = "100%"; /// /// Elenco altezze ammesse /// [Parameter] public Dictionary HeightList { get => hList; set { if (hList != value && value.Count > 0) { hList = value; } } } private Dictionary hList { get; set; } = new Dictionary() { { "200", "200px" }, { "400", "400px" }, { "600", "600px" } }; protected override void OnInitialized() { // in base a quanti ne ho preso ultima o in mezzo... int numSkip = HeightList.Count() > 3 ? 2 : 0; Height = HeightList.Skip(numSkip).FirstOrDefault().Value; } #endregion Public Properties #region Protected Methods protected override async Task OnAfterRenderAsync(bool firstRender) { try { if (!firstRender) return; module = await JS.InvokeAsync("import", "./_content/EgwCoreLib.Razor/PdfDisplay.razor.js"); isMobile = await JS.InvokeAsync("isDevice"); } catch { } } #endregion Protected Methods #region Private Fields private IJSObjectReference? module; #endregion Private Fields #region Private Properties private string Height { get; set; } = "600px"; /// /// Boolean Mobile vs Desktop /// private bool isMobile { get; set; } [Inject] [NotNull] private IJSRuntime? JS { get; set; } #endregion Private Properties } }