OverlayAktualisierung im frmMain

This commit is contained in:
Developer01
2026-07-01 15:48:13 +02:00
parent 744199dbbc
commit a2e5d1c136

View File

@@ -1335,9 +1335,7 @@ Public Class frmMain
End Sub
Private Async Sub TimerRefresh_Tick(sender As System.Object, e As EventArgs) Handles TimerRefresh.Tick
Try
If TimerRefresh.Enabled = False Then
Exit Sub
End If
If TimerRefresh.Enabled = False Then Exit Sub
If bwBasicData.IsBusy Then
LOGGER.Info("backGroundWorker BasicData in Action - no Client-Sync")
bsiMessage.Caption = "bwBasicData is busy - no Refreshing"
@@ -1348,7 +1346,7 @@ Public Class frmMain
TimerRefresh_running = True
' Cancel Refresh if a Validator Form or an Admin Form is opened
' Cancel Refresh if Validator/Admin Form is opened
If Application.OpenForms().OfType(Of frmMassValidator).Any() Or
Application.OpenForms().OfType(Of frmValidator).Any() Or
Application.OpenForms().OfType(Of frmAdministration).Any() Or
@@ -1356,42 +1354,52 @@ Public Class frmMain
Exit Sub
End If
'bsilastsync.Caption = $"{ClassAllgemeineFunktionen.GUI_LANGUAGE_INFO("CaptLastSync")}: " & Now.ToLongTimeString
bsilastsync.Caption = String.Format(S.Letzte_Synchronisation___0_, Now.ToLongTimeString)
' ✅ Prüfung ob Fenster aktiv ist
Dim isWindowActive As Boolean = (Me.ContainsFocus OrElse Me Is Form.ActiveForm)
If GridControlWorkflows.Visible = True And FormOpenClose = False Then
RefreshHelper.SaveViewInfo()
If isWindowActive Then
' ====== FENSTER IST AKTIV → MIT Overlay ======
bsilastsync.Caption = String.Format(S.Letzte_Synchronisation___0_, Now.ToLongTimeString)
If GridControlWorkflows.Visible = True And FormOpenClose = False Then
RefreshHelper.SaveViewInfo()
End If
If bwSync.IsBusy Then
TimerRefresh_running = False
Exit Sub
End If
Try
LoadNavBar()
Dim oStopWatch As New RefreshHelper.SW("Decide_Load")
Await Decide_Load(False, ForceReload:=False, AllowOverlay:=True) ' ✅ Overlay ERLAUBT
oStopWatch.Done()
If GridControlWorkflows.Visible = True And FormOpenClose = False Then
RefreshHelper.LoadViewInfo()
End If
Handling_DEBUG_USER()
Catch ex As Exception
LOGGER.Error(ex)
End Try
Else
' ====== FENSTER IST INAKTIV → OHNE Overlay ======
LOGGER.Debug("TimerRefresh: Silent background update (window not active)")
Try
LoadNavBar()
Await Decide_Load(False, ForceReload:=False, AllowOverlay:=False) ' ✅ Overlay VERBOTEN
' KEIN RefreshHelper.LoadViewInfo() → verhindert UI-Flackern
Catch ex As Exception
LOGGER.Error(ex)
End Try
End If
If bwSync.IsBusy Then
TimerRefresh_running = False
Exit Sub
End If
Try
'bwSync.ReportProgress(10)
LoadNavBar()
'bwSync.ReportProgress(60)
Dim oStopWatch As New RefreshHelper.SW("Decide_Load")
Await Decide_Load(False)
oStopWatch.Done()
'bwSync.ReportProgress(95)
If GridControlWorkflows.Visible = True And FormOpenClose = False Then RefreshHelper.LoadViewInfo()
Handling_DEBUG_USER()
Catch ex As Exception
LOGGER.Error(ex)
End Try
Catch ex As Exception
LOGGER.Error(ex)
End Try
TimerRefresh_running = False
'BarEditItem1.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
'' call this method to start your asynchronous Task.
'bwSync.RunWorkerAsync()
End Sub
Private Sub NotifyIcon1_Click(sender As System.Object, e As EventArgs) Handles NotifyIcon1.Click
@@ -1400,10 +1408,14 @@ Public Class frmMain
' ========================================
' HAUPTLADEMETHODE - Koordiniert den gesamten Ladevorgang
' ========================================
Private Async Function Decide_Load(pIsFormLoad As Boolean, Optional ForceReload As Boolean = False) As Tasks.Task
Private Async Function Decide_Load(pIsFormLoad As Boolean, Optional ForceReload As Boolean = False, Optional AllowOverlay As Boolean = True) As Tasks.Task
Dim oHandle As Object = Nothing
Dim overlayStartedHere As Boolean = False
If Not _overlayActive Then
' ✅ Overlay nur anzeigen, wenn explizit erlaubt UND Fenster aktiv ist
Dim shouldShowOverlay As Boolean = AllowOverlay AndAlso (Me.ContainsFocus OrElse Me Is Form.ActiveForm)
If shouldShowOverlay AndAlso Not _overlayActive Then
oHandle = SplashScreenManager.ShowOverlayForm(Me)
_overlayActive = True
overlayStartedHere = True
@@ -1481,9 +1493,9 @@ Public Class frmMain
LOGGER.Info("Unexpected error in Decide_load: " & ex.Message)
Finally
FRONTEND_ACTION = FA_NONE
If overlayStartedHere Then
_overlayActive = False
If overlayStartedHere AndAlso _overlayActive Then
SplashScreenManager.CloseOverlayForm(oHandle)
_overlayActive = False
End If
If refreshWasEnabled Then
TimerRefresh.Start()