Add F11 fullscreen functionality

This commit is contained in:
Stone_Red
2024-04-04 23:10:49 +02:00
parent e8d8745a2b
commit cbe32f7bdf
2 changed files with 12 additions and 1 deletions
@@ -29,6 +29,7 @@ public partial class MainWindowViewModel : ViewModelBase
private ContentViewModelBase content;
private TabItem currentTab = null!;
private WindowState windowState;
private bool showSidePanel;
private bool isBusy;
private int progress;
@@ -52,6 +53,12 @@ public partial class MainWindowViewModel : ViewModelBase
}
}
public WindowState WindowState
{
get => windowState;
set => this.RaiseAndSetIfChanged(ref windowState, value);
}
public ContentViewModelBase Content
{
get => content;
@@ -143,6 +150,8 @@ public partial class MainWindowViewModel : ViewModelBase
this.RaisePropertyChanged(nameof(CloseTabEnabled));
});
public ICommand ToggleFullScreen => ReactiveCommand.Create(() => WindowState = WindowState == WindowState.FullScreen ? WindowState.Normal : WindowState.FullScreen);
private MarkdownContentViewModel DefaultContent => new("New Tab", new StringBuilder()
.AppendLine($"![Logo](avares://Markdowser/Assets/Markdowser-{(Settings.Current.DarkMode ? "Dark" : "Light")}-Transparent.png)")
.AppendLine()
+3 -1
View File
@@ -11,7 +11,7 @@
x:DataType="vm:MainWindowViewModel"
Icon="{Binding Icon}"
Title="{Binding Title}"
Loaded="Window_Loaded">
Loaded="Window_Loaded" WindowState="{Binding WindowState}">
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
@@ -32,6 +32,7 @@
<Window.KeyBindings>
<KeyBinding Gesture="Ctrl+R" Command="{Binding Browse}" />
<KeyBinding Gesture="F5" Command="{Binding Browse}" />
<KeyBinding Gesture="Alt+Home" Command="{StaticResource HomeCommand}" />
<KeyBinding Gesture="Alt+H" Command="{StaticResource HomeCommand}" />
<KeyBinding Gesture="Alt+Left" Command="{Binding Back}" />
@@ -39,6 +40,7 @@
<KeyBinding Gesture="Ctrl+T" Command="{Binding NewTab}" />
<KeyBinding Gesture="Ctrl+W" Command="{Binding CloseTab}" />
<KeyBinding Gesture="Alt+S" Command="{Binding ToggleSidePanel}" />
<KeyBinding Gesture="F11" Command="{Binding ToggleFullScreen}" />
</Window.KeyBindings>
<Grid RowDefinitions="Auto, *, Auto">