69c010a9af
- aggiunta orologio grande in alto - review pagina in generale
109 lines
2.7 KiB
C#
109 lines
2.7 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using System;
|
|
|
|
namespace MP.MON.Client.Components
|
|
{
|
|
public partial class CmpFooter : ComponentBase, IDisposable
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public Version version { get; set; } = null!;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
aTimer.Stop();
|
|
aTimer.Dispose();
|
|
}
|
|
|
|
public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e)
|
|
{
|
|
var pUpd = Task.Run(async () =>
|
|
{
|
|
await Task.Delay(1);
|
|
//Console.WriteLine($"{DateTime.Now} | Elapsed Timer Footer");
|
|
await InvokeAsync(() => StateHasChanged());
|
|
});
|
|
pUpd.Wait();
|
|
}
|
|
|
|
public void StartTimer()
|
|
{
|
|
int tOutPeriod = 1000;
|
|
aTimer = new System.Timers.Timer(tOutPeriod);
|
|
aTimer.Elapsed += ElapsedTimer;
|
|
aTimer.Enabled = true;
|
|
aTimer.Start();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Public Classes
|
|
|
|
public class WindowDimension
|
|
{
|
|
#region Public Properties
|
|
|
|
public int Height { get; set; }
|
|
public int Width { get; set; }
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
#endregion Public Classes
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected async Task getWDim()
|
|
{
|
|
var dimension = await JSRuntime.InvokeAsync<WindowDimension>("getWindowDimensions");
|
|
Height = dimension.Height;
|
|
Width = dimension.Width;
|
|
}
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
if (firstRender)
|
|
{
|
|
await getWDim();
|
|
StateHasChanged();
|
|
Console.WriteLine($"Dimensioni schermo: {Width}x{Height}");
|
|
}
|
|
//Console.WriteLine($"OnAfterRenderAsync completato");
|
|
}
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
StartTimer();
|
|
Console.WriteLine($"OnInitialized Footer completato");
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private static System.Timers.Timer aTimer = null!;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private int Height { get; set; } = 0;
|
|
|
|
private int Width { get; set; } = 0;
|
|
|
|
#endregion Private Properties
|
|
}
|
|
} |