Skip to content

Commit 0c4a82c

Browse files
committed
Fix window loading above the screen's top edge. closes #382
1 parent 70bcd6b commit 0c4a82c

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

CompactGUI/Models/SetttingsHandler.vb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ Public Class SettingsHandler : Inherits ObservableObject
6464
AppSettings.WindowWidth = 500
6565
End If
6666

67+
Dim scHeight = SystemParameters.MaximizedPrimaryScreenHeight * 0.9
68+
69+
If scHeight < AppSettings.WindowHeight Then
70+
AppSettings.WindowHeight = scHeight
71+
AppSettings.WindowWidth = scHeight * 0.625
72+
AppSettings.WindowScalingFactor = scHeight / 800
73+
End If
74+
6775
End Sub
6876

6977

CompactGUI/Views/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
mc:Ignorable="d" xmlns:ui="http://schemas.modernwpf.com/2019" xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase" d:DataContext="{d:DesignInstance Type=local:MainViewModel}" RenderOptions.ClearTypeHint="Enabled"
1010
WindowState="{Binding WindowState}" ShowInTaskbar="{Binding ShowInTaskbar}" AllowDrop="True" Drop="Window_Drop"
1111
ui:WindowHelper.UseModernWindowStyle="True" ui:TitleBar.ExtendViewIntoTitleBar="True"
12-
Title="CompactGUI"
12+
Title="CompactGUI" Loaded="MainWindow_Loaded"
1313
Height="{Binding BindableSettings.WindowHeight, Mode=TwoWay,FallbackValue=800}"
1414
Width="{Binding BindableSettings.WindowWidth, Mode=TwoWay, FallbackValue=500}" ResizeMode="NoResize"
1515
WindowStyle="SingleBorderWindow" Background="White" >

CompactGUI/Views/MainWindow.xaml.vb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Class MainWindow
1313
Me.DataContext = ViewModel
1414

1515
ViewModel.State = "FreshLaunch"
16+
17+
1618
End Sub
1719

1820
Public Property ViewModel As New MainViewModel
@@ -58,4 +60,13 @@ Class MainWindow
5860

5961

6062
End Sub
63+
64+
Private Sub MainWindow_Loaded(sender As Object, e As RoutedEventArgs)
65+
66+
Me.Top = (SystemParameters.PrimaryScreenHeight - SettingsHandler.AppSettings.WindowHeight) / 2
67+
Me.Left = (SystemParameters.PrimaryScreenWidth - SettingsHandler.AppSettings.WindowWidth) / 2
68+
69+
If Me.Top < 0 Then Me.Top = 0
70+
71+
End Sub
6172
End Class

0 commit comments

Comments
 (0)