mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-04-08 02:06:37 +08:00
* fix: update Height binding and add VerticalAlignment to fullscreen popover. * feat: add fullscreen toggle functionality with F11 key.
38 lines
816 B
C#
38 lines
816 B
C#
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;
|
|
}
|
|
}
|
|
} |