Skip to content

Commit

Permalink
Fix window loading above the screen's top edge. closes #382
Browse files Browse the repository at this point in the history
  • Loading branch information
Iridium-IO committed Feb 29, 2024
1 parent 70bcd6b commit 0c4a82c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CompactGUI/Models/SetttingsHandler.vb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ Public Class SettingsHandler : Inherits ObservableObject
AppSettings.WindowWidth = 500
End If

Dim scHeight = SystemParameters.MaximizedPrimaryScreenHeight * 0.9

If scHeight < AppSettings.WindowHeight Then
AppSettings.WindowHeight = scHeight
AppSettings.WindowWidth = scHeight * 0.625
AppSettings.WindowScalingFactor = scHeight / 800
End If

End Sub


Expand Down
2 changes: 1 addition & 1 deletion CompactGUI/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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"
WindowState="{Binding WindowState}" ShowInTaskbar="{Binding ShowInTaskbar}" AllowDrop="True" Drop="Window_Drop"
ui:WindowHelper.UseModernWindowStyle="True" ui:TitleBar.ExtendViewIntoTitleBar="True"
Title="CompactGUI"
Title="CompactGUI" Loaded="MainWindow_Loaded"
Height="{Binding BindableSettings.WindowHeight, Mode=TwoWay,FallbackValue=800}"
Width="{Binding BindableSettings.WindowWidth, Mode=TwoWay, FallbackValue=500}" ResizeMode="NoResize"
WindowStyle="SingleBorderWindow" Background="White" >
Expand Down
11 changes: 11 additions & 0 deletions CompactGUI/Views/MainWindow.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Class MainWindow
Me.DataContext = ViewModel

ViewModel.State = "FreshLaunch"


End Sub

Public Property ViewModel As New MainViewModel
Expand Down Expand Up @@ -58,4 +60,13 @@ Class MainWindow


End Sub

Private Sub MainWindow_Loaded(sender As Object, e As RoutedEventArgs)

Me.Top = (SystemParameters.PrimaryScreenHeight - SettingsHandler.AppSettings.WindowHeight) / 2
Me.Left = (SystemParameters.PrimaryScreenWidth - SettingsHandler.AppSettings.WindowWidth) / 2

If Me.Top < 0 Then Me.Top = 0

End Sub
End Class

0 comments on commit 0c4a82c

Please sign in to comment.