mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-04-09 02:36:34 +08:00
Add fullscreen toggle functionality and update popover alignment (#773)
* fix: update Height binding and add VerticalAlignment to fullscreen popover. * feat: add fullscreen toggle functionality with F11 key.
This commit is contained in:
@@ -1,11 +1,38 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
|
||||
namespace Semi.Avalonia.Demo.Views;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private WindowState _stateBeforeFullScreen = WindowState.Normal;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
KeyDown += FullScreenKeyDown;
|
||||
}
|
||||
|
||||
private void FullScreenKeyDown(object? sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.F11)
|
||||
{
|
||||
|
||||
ToggleFullScreen();
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleFullScreen()
|
||||
{
|
||||
if (WindowState is not WindowState.FullScreen)
|
||||
{
|
||||
_stateBeforeFullScreen = WindowState;
|
||||
WindowState = WindowState.FullScreen;
|
||||
}
|
||||
else
|
||||
{
|
||||
WindowState = _stateBeforeFullScreen;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user