From e39e62e4cc2a22a2e53ad9b1c0ce7c97bcfb8f0d Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 13 Jan 2023 11:36:05 +0100 Subject: [PATCH] update secondi che pulsano --- GPW.CORE.SMART/Components/DtCard.razor | 10 +++++++++- GPW.CORE.SMART/Components/DtCard.razor.cs | 17 +++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/GPW.CORE.SMART/Components/DtCard.razor b/GPW.CORE.SMART/Components/DtCard.razor index 7c3e79d..003e817 100644 --- a/GPW.CORE.SMART/Components/DtCard.razor +++ b/GPW.CORE.SMART/Components/DtCard.razor @@ -3,7 +3,15 @@ @($"{dtCurr:dddd dd MMMM}")
- @($"{dtCurr:HH}:{dtCurr:mm}") +
+
+ @($"{dtCurr:HH}") +
+
:
+
+ @($"{dtCurr:mm}") +
+
@if (showAction) { diff --git a/GPW.CORE.SMART/Components/DtCard.razor.cs b/GPW.CORE.SMART/Components/DtCard.razor.cs index 2cb5028..b1acb54 100644 --- a/GPW.CORE.SMART/Components/DtCard.razor.cs +++ b/GPW.CORE.SMART/Components/DtCard.razor.cs @@ -52,11 +52,13 @@ namespace GPW.CORE.Smart.Components }); pUpd.Wait(); } + public void ElapsedTimerUi(object? source, System.Timers.ElapsedEventArgs e) { var pUpd = Task.Run(async () => { dtCurr = DateTime.Now; + cssSec = (dtCurr.Second % 2 == 0) ? "text-light" : "text-dark"; await Task.Delay(1); await InvokeAsync(() => StateHasChanged()); }); @@ -71,23 +73,34 @@ namespace GPW.CORE.Smart.Components timbTimer.Enabled = true; timbTimer.Start(); } + public void StartTimerUI() { // timer che scatta dopo 3sec - uiTimer = new System.Timers.Timer(2000); + uiTimer = new System.Timers.Timer(1000); uiTimer.Elapsed += ElapsedTimerUi; uiTimer.Enabled = true; uiTimer.AutoReset = true; uiTimer.Start(); } + #endregion Public Methods + + #region Protected Properties + + protected string cssSec { get; set; } = "text-light"; + + #endregion Protected Properties + + #region Protected Methods + protected override void OnInitialized() { base.OnInitialized(); StartTimerUI(); } - #endregion Public Methods + #endregion Protected Methods #region Private Fields