diff --git a/app/TaskFlow/My Project/AssemblyInfo.vb b/app/TaskFlow/My Project/AssemblyInfo.vb index 2144043..a2fdc81 100644 --- a/app/TaskFlow/My Project/AssemblyInfo.vb +++ b/app/TaskFlow/My Project/AssemblyInfo.vb @@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - + diff --git a/app/TaskFlow/frmMain.vb b/app/TaskFlow/frmMain.vb index 884d8a1..650de93 100644 --- a/app/TaskFlow/frmMain.vb +++ b/app/TaskFlow/frmMain.vb @@ -413,9 +413,21 @@ Public Class frmMain Timer_Inactivity_Reset_Disable("FormLoad") 'Restore_Form_Position() - ScreenEx.RestoreFormPosition(Me, My.Settings.frmMainPosition) - ScreenEx.RestoreFormState(Me, My.Settings.frmMainWindowState) - ScreenEx.RestoreFormSize(Me, My.Settings.frmMainSize) + Dim oSavedPosition As Point = My.Settings.frmMainPosition + + ' Prüfen, ob die Position sichtbar ist + If IsPositionVisible(oSavedPosition) Then + ' Position ist sichtbar, das Formular wird dort angezeigt + ScreenEx.RestoreFormPosition(Me, My.Settings.frmMainPosition) + ScreenEx.RestoreFormState(Me, My.Settings.frmMainWindowState) + ScreenEx.RestoreFormSize(Me, My.Settings.frmMainSize) + Else + ' Position ist unsichtbar, Standardposition verwenden + Me.StartPosition = FormStartPosition.CenterScreen + + End If + + If IDB_ACTIVE = False And ERROR_STATE = "" Then Try @@ -481,7 +493,14 @@ Public Class frmMain FormOpenClose = False End Sub - + Private Function IsPositionVisible(position As Point) As Boolean + For Each scr As Screen In Screen.AllScreens + If scr.WorkingArea.Contains(position) Then + Return True ' Punkt ist sichtbar + End If + Next + Return False ' Punkt ist außerhalb aller sichtbaren Bereiche + End Function Public Class FontSetting Public Property Title As String Public Property Value As Integer diff --git a/app/TaskFlow/frmValidator.vb b/app/TaskFlow/frmValidator.vb index 313624a..cfc6a97 100644 --- a/app/TaskFlow/frmValidator.vb +++ b/app/TaskFlow/frmValidator.vb @@ -167,7 +167,14 @@ Public Class frmValidator Return oOperationMode End Function - + Private Function IsPositionVisible(position As Point) As Boolean + For Each scr As Screen In Screen.AllScreens + If scr.WorkingArea.Contains(position) Then + Return True ' Punkt ist sichtbar + End If + Next + Return False ' Punkt ist außerhalb aller sichtbaren Bereiche + End Function Private Sub frmValidation_Load(sender As Object, e As System.EventArgs) Handles Me.Load Try @@ -200,15 +207,30 @@ Public Class frmValidator Try If My.Settings.frmValidatorPosition.IsEmpty = False Then - If My.Settings.frmValidatorPosition.X > 0 And My.Settings.frmValidatorPosition.Y > 0 Then - Location = My.Settings.frmValidatorPosition - Else - Try - Logger.Debug($"!! Invalid PositionData X({My.Settings.frmValidatorPosition.X}), Y({My.Settings.frmValidatorPosition.Y})") - Catch ex As Exception + If IsPositionVisible(My.Settings.frmValidatorPosition) Then + ' Position ist sichtbar, das Formular wird dort angezeigt + Try + ScreenEx.RestoreFormPosition(Me, My.Settings.frmValidatorPosition) + Catch ex As Exception + Me.StartPosition = FormStartPosition.CenterScreen End Try + If My.Settings.frmValidatorPosition.X > 0 And My.Settings.frmValidatorPosition.Y > 0 Then + Location = My.Settings.frmValidatorPosition + Else + Try + Logger.Debug($"!! Invalid PositionData X({My.Settings.frmValidatorPosition.X}), Y({My.Settings.frmValidatorPosition.Y})") + Catch ex As Exception + + End Try + + End If + + Else + ' Position ist unsichtbar, Standardposition verwenden + Me.StartPosition = FormStartPosition.CenterScreen + End If End If If My.Settings.frmValidatorSize.IsEmpty = False Then @@ -219,8 +241,6 @@ Public Class frmValidator Me.WindowState = FormWindowState.Maximized End If End If - - End If Catch ex As Exception Logger.Info($"Error loading position: {ex.Message}")