mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-04-10 03:06:35 +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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,8 +120,9 @@
|
||||
<WindowDrawnDecorationsContent.FullscreenPopover>
|
||||
<!-- Shown on hover at top edge in fullscreen -->
|
||||
<DockPanel
|
||||
Height="{TemplateBinding TitleBarHeight}"
|
||||
Height="{TemplateBinding DefaultTitleBarHeight}"
|
||||
Background="{DynamicResource TitleBarBackground}"
|
||||
VerticalAlignment="Top"
|
||||
WindowDecorationProperties.ElementRole="TitleBar">
|
||||
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
|
||||
<Button
|
||||
|
||||
Reference in New Issue
Block a user