mirror of
https://github.com/QL-Win/QuickLook.git
synced 2026-03-21 01:08:08 +08:00
Implement true fullscreen mode (hide taskbar and window chrome)
Co-authored-by: emako <24737061+emako@users.noreply.github.com>
This commit is contained in:
@@ -64,7 +64,52 @@ public partial class ViewerWindow
|
||||
|
||||
internal void ToggleFullscreen()
|
||||
{
|
||||
WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
|
||||
if (_isFullscreen)
|
||||
{
|
||||
// Exit fullscreen
|
||||
_isFullscreen = false;
|
||||
|
||||
// Restore window properties
|
||||
WindowState = _preFullscreenWindowState;
|
||||
WindowStyle = _preFullscreenWindowStyle;
|
||||
ResizeMode = _preFullscreenResizeMode;
|
||||
|
||||
// Restore position and size
|
||||
Left = _preFullscreenBounds.Left;
|
||||
Top = _preFullscreenBounds.Top;
|
||||
Width = _preFullscreenBounds.Width;
|
||||
Height = _preFullscreenBounds.Height;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Enter fullscreen
|
||||
_isFullscreen = true;
|
||||
|
||||
// Save current window properties
|
||||
_preFullscreenWindowState = WindowState;
|
||||
_preFullscreenWindowStyle = WindowStyle;
|
||||
_preFullscreenResizeMode = ResizeMode;
|
||||
_preFullscreenBounds = new Rect(Left, Top, Width, Height);
|
||||
|
||||
// Set to normal state first to get proper bounds
|
||||
WindowState = WindowState.Normal;
|
||||
|
||||
// Hide window chrome for true fullscreen
|
||||
WindowStyle = WindowStyle.None;
|
||||
ResizeMode = ResizeMode.NoResize;
|
||||
|
||||
// Get the screen bounds where the window is currently located
|
||||
var screen = System.Windows.Forms.Screen.FromHandle(new System.Windows.Interop.WindowInteropHelper(this).Handle);
|
||||
|
||||
// Set window to cover the entire screen
|
||||
Left = screen.Bounds.Left;
|
||||
Top = screen.Bounds.Top;
|
||||
Width = screen.Bounds.Width;
|
||||
Height = screen.Bounds.Height;
|
||||
|
||||
// Ensure the window is on top
|
||||
WindowState = WindowState.Maximized;
|
||||
}
|
||||
}
|
||||
|
||||
private void PositionWindow(Size size)
|
||||
|
||||
@@ -37,6 +37,11 @@ public partial class ViewerWindow : INotifyPropertyChanged
|
||||
|
||||
private bool _canOldPluginResize;
|
||||
private bool _pinned;
|
||||
private bool _isFullscreen;
|
||||
private WindowState _preFullscreenWindowState;
|
||||
private WindowStyle _preFullscreenWindowStyle;
|
||||
private ResizeMode _preFullscreenResizeMode;
|
||||
private Rect _preFullscreenBounds;
|
||||
|
||||
public bool Pinned
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user