|
|
@@ -113,7 +113,7 @@ public static class WindowHelper
|
|
|
var scalingFactor = screen.Scaling;
|
|
|
|
|
|
// Get the current screen's bounds (in physical pixels, not adjusted for scaling)
|
|
|
- var screenBounds = screen.Bounds;
|
|
|
+ var screenBounds = screen.WorkingArea;
|
|
|
|
|
|
// Calculate the actual bounds in logical units (adjusting for scaling)
|
|
|
var screenWidth = screenBounds.Width / scalingFactor;
|
|
|
@@ -135,8 +135,6 @@ public static class WindowHelper
|
|
|
{
|
|
|
window.Position = new PixelPoint(window.Position.X, (int)centeredY);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -393,7 +391,38 @@ public static class WindowHelper
|
|
|
vm.IsTopToolbarShown = false; // Hide interface in fullscreen. Remember to turn back when exiting fullscreen
|
|
|
vm.IsBottomToolbarShown = false;
|
|
|
vm.IsInterfaceShown = false;
|
|
|
- Dispatcher.UIThread.Post(() => CenterWindowOnScreen());
|
|
|
+ Dispatcher.UIThread.Post(() =>
|
|
|
+ {
|
|
|
+ // Get the screen that the window is currently on
|
|
|
+ var window = desktop.MainWindow;
|
|
|
+ var screens = desktop.MainWindow.Screens;
|
|
|
+ var screen = screens.ScreenFromVisual(window);
|
|
|
+
|
|
|
+ if (screen == null)
|
|
|
+ {
|
|
|
+ return; // No screen found (edge case)
|
|
|
+ }
|
|
|
+
|
|
|
+ // Get the scaling factor of the screen (DPI scaling)
|
|
|
+ var scalingFactor = screen.Scaling;
|
|
|
+
|
|
|
+ // Get the current screen's bounds (in physical pixels, not adjusted for scaling)
|
|
|
+ var screenBounds = screen.Bounds;
|
|
|
+
|
|
|
+ // Calculate the actual bounds in logical units (adjusting for scaling)
|
|
|
+ var screenWidth = screenBounds.Width / scalingFactor;
|
|
|
+ var screenHeight = screenBounds.Height / scalingFactor;
|
|
|
+
|
|
|
+ // Get the size of the window
|
|
|
+ var windowSize = window.ClientSize;
|
|
|
+
|
|
|
+ // Calculate the position to center the window on the screen
|
|
|
+ var centeredX = screenBounds.X + (screenWidth - windowSize.Width) / 2;
|
|
|
+ var centeredY = screenBounds.Y + (screenHeight - windowSize.Height) / 2;
|
|
|
+
|
|
|
+ // Set the window's new position
|
|
|
+ window.Position = new PixelPoint((int)centeredX, (int)centeredY);
|
|
|
+ });
|
|
|
// TODO: Add Fullscreen mode for Windows (and maybe for Linux?)
|
|
|
// macOS fullscreen version already works nicely
|
|
|
}
|
|
|
@@ -515,25 +544,13 @@ public static class WindowHelper
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
var screenSize = ScreenHelper.ScreenSize;
|
|
|
double desktopMinWidth = 0, desktopMinHeight = 0, containerWidth = 0, containerHeight = 0;
|
|
|
- if (Dispatcher.UIThread.CheckAccess())
|
|
|
- {
|
|
|
- desktopMinWidth = desktop.MainWindow.MinWidth;
|
|
|
- desktopMinHeight = desktop.MainWindow.MinHeight;
|
|
|
- containerWidth = mainView.Bounds.Width;
|
|
|
- containerHeight = mainView.Bounds.Height;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Dispatcher.UIThread.Invoke(() =>
|
|
|
- {
|
|
|
- desktopMinWidth = desktop.MainWindow.MinWidth;
|
|
|
- desktopMinHeight = desktop.MainWindow.MinHeight;
|
|
|
- containerWidth = mainView.Bounds.Width;
|
|
|
- containerHeight = mainView.Bounds.Height;
|
|
|
- }, DispatcherPriority.Send);
|
|
|
- }
|
|
|
+ desktopMinWidth = desktop.MainWindow.MinWidth;
|
|
|
+ desktopMinHeight = desktop.MainWindow.MinHeight;
|
|
|
+ containerWidth = mainView.Bounds.Width;
|
|
|
+ containerHeight = mainView.Bounds.Height;
|
|
|
|
|
|
if (double.IsNaN(containerWidth) || double.IsNaN(containerHeight) || double.IsNaN(width) || double.IsNaN(height))
|
|
|
{
|