Imports System.Windows.Forms Class Application ' Application-level events, such as Startup, Exit, and DispatcherUnhandledException ' can be handled in this file. 'Protected Overrides Sub OnStartup(e As StartupEventArgs) ' MyBase.OnStartup(e) ' Dim mainWindow As New MainWindow ' Dim thisDpiWidthFactor As Double ' Dim thisDpiHeightFactor As Double ' mainWindow.Show() ' 'Controllo che abbia creato la finestra per evitare crash se non c'è la chiave ' If (IsNothing(Application.Current)) Then ' Exit Sub ' End If ' CalculateDpiFactors(mainWindow, thisDpiWidthFactor, thisDpiHeightFactor) ' If (Screen.AllScreens.Length > 1) Then ' Dim s2 As Screen = Screen.AllScreens(1) ' Dim r2 As System.Drawing.Rectangle = s2.WorkingArea ' mainWindow.Top = r2.Top / thisDpiHeightFactor ' mainWindow.Left = r2.Left / thisDpiWidthFactor ' Else ' Dim s1 As Screen = Screen.AllScreens(0) ' Dim r1 As System.Drawing.Rectangle = s1.WorkingArea ' mainWindow.Top = r1.Top ' mainWindow.Left = r1.Left ' End If 'End Sub 'Private Shared Sub CalculateDpiFactors(ByRef mainwindow As Window, ByRef thisDpiWidthFactor As Double, ByRef thisDpiHeightFactor As Double) ' Dim MainWindowPresentationSource As PresentationSource = PresentationSource.FromVisual(Application.Current.MainWindow) ' Dim m As New Matrix ' m = PresentationSource.FromVisual(Application.Current.MainWindow).CompositionTarget.TransformToDevice ' thisDpiWidthFactor = m.M11 ' thisDpiHeightFactor = m.M22 'End Sub End Class