From ba1f62266593b7f2e9b87810d8649331e1bf1c5f Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Mon, 21 Nov 2022 12:43:45 +0100 Subject: [PATCH] gestione grandezza finestra --- MP.INVE/Pages/_Layout.cshtml | 1 + MP.INVE/Shared/MainLayout.razor | 10 ++++++++-- MP.INVE/Shared/MainLayout.razor.cs | 16 ++++++++++++++++ MP.INVE/Shared/NavMenu.razor | 4 ++-- MP.INVE/wwwroot/lib/WindowSize.js | 6 ++++++ 5 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 MP.INVE/wwwroot/lib/WindowSize.js diff --git a/MP.INVE/Pages/_Layout.cshtml b/MP.INVE/Pages/_Layout.cshtml index f7a5c3fa..967701ec 100644 --- a/MP.INVE/Pages/_Layout.cshtml +++ b/MP.INVE/Pages/_Layout.cshtml @@ -62,5 +62,6 @@ + diff --git a/MP.INVE/Shared/MainLayout.razor b/MP.INVE/Shared/MainLayout.razor index 75da5b44..d7ff713a 100644 --- a/MP.INVE/Shared/MainLayout.razor +++ b/MP.INVE/Shared/MainLayout.razor @@ -6,12 +6,18 @@
- + @if ((Height != 480) && (Width != 320)) + { + + }
- + @if ((Height != 480) && (Width != 320)) + { + + }
@if (userName != "0" || NavManager.Uri.Contains("OperatoreLogin")) diff --git a/MP.INVE/Shared/MainLayout.razor.cs b/MP.INVE/Shared/MainLayout.razor.cs index 089b4dfa..f72febb2 100644 --- a/MP.INVE/Shared/MainLayout.razor.cs +++ b/MP.INVE/Shared/MainLayout.razor.cs @@ -1,5 +1,6 @@ using Blazored.LocalStorage; using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; using MP.Data.DTO; namespace MP.INVE.Shared @@ -44,9 +45,21 @@ namespace MP.INVE.Shared } } + public int Height { get; set; } + public int Width { get; set; } + + public class WindowDimension + { + public int Width { get; set; } + public int Height { get; set; } + } + protected override async Task OnInitializedAsync() { await getId(); + var dimension = await JSRuntime.InvokeAsync("getWindowDimensions"); + Height = dimension.Height; + Width = dimension.Width; } protected void UpdateNavDisplay() @@ -65,6 +78,9 @@ namespace MP.INVE.Shared [Inject] private NavigationManager NavManager { get; set; } = null!; + [Inject] + private IJSRuntime JSRuntime { get; set; } = null!; + #endregion Private Properties } } \ No newline at end of file diff --git a/MP.INVE/Shared/NavMenu.razor b/MP.INVE/Shared/NavMenu.razor index a44fbbcd..cd920e0e 100644 --- a/MP.INVE/Shared/NavMenu.razor +++ b/MP.INVE/Shared/NavMenu.razor @@ -52,7 +52,7 @@
- *@