mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-04-08 10:16: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.Controls;
|
||||||
|
using Avalonia.Input;
|
||||||
|
|
||||||
namespace Semi.Avalonia.Demo.Views;
|
namespace Semi.Avalonia.Demo.Views;
|
||||||
|
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
|
private WindowState _stateBeforeFullScreen = WindowState.Normal;
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
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>
|
<WindowDrawnDecorationsContent.FullscreenPopover>
|
||||||
<!-- Shown on hover at top edge in fullscreen -->
|
<!-- Shown on hover at top edge in fullscreen -->
|
||||||
<DockPanel
|
<DockPanel
|
||||||
Height="{TemplateBinding TitleBarHeight}"
|
Height="{TemplateBinding DefaultTitleBarHeight}"
|
||||||
Background="{DynamicResource TitleBarBackground}"
|
Background="{DynamicResource TitleBarBackground}"
|
||||||
|
VerticalAlignment="Top"
|
||||||
WindowDecorationProperties.ElementRole="TitleBar">
|
WindowDecorationProperties.ElementRole="TitleBar">
|
||||||
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
|
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Reference in New Issue
Block a user