From 252201c93075835bc77aaf492b7964a4a766ec95 Mon Sep 17 00:00:00 2001 From: Alek-ban Date: Thu, 26 Feb 2026 06:55:14 +0300 Subject: [PATCH] feat: fullscreen argument --- GSS2.Test/App.axaml.cs | 10 +++++-- GSS2.Test/Program.cs | 26 +++++++++++-------- GSS2.Test/PropgramUi.cs | 7 +++-- GSS2.UI.Core/MainWindow.axaml | 5 +++- GSS2.UI.Core/MainWindow.axaml.cs | 4 +++ .../ViewModels/MainWindowViewModel.cs | 5 ++++ 6 files changed, 41 insertions(+), 16 deletions(-) diff --git a/GSS2.Test/App.axaml.cs b/GSS2.Test/App.axaml.cs index dc1ea15..257f466 100644 --- a/GSS2.Test/App.axaml.cs +++ b/GSS2.Test/App.axaml.cs @@ -30,7 +30,8 @@ public partial class App : Application { case IClassicDesktopStyleApplicationLifetime desktop: Console.WriteLine("Application running in classic style"); - + Console.WriteLine($"Application running in {(Program.IsFullscreen ? "fullscreen" : "window")} mode"); + desktop.Startup += (_, _) => Program.ApplicationHost.RunAsync(); desktop.Exit += (_, _) => Program.ApplicationHost.StopAsync(); @@ -38,6 +39,11 @@ public partial class App : Application var mainWindow = new MainWindow() { DataContext = new MainWindowViewModel(mainWindowViewModelLogger) + { + SystemDecorations = Program.IsFullscreen ? Avalonia.Controls.SystemDecorations.None : Avalonia.Controls.SystemDecorations.Full, + Topmost = Program.IsFullscreen, + WindowState = Program.IsFullscreen ? Avalonia.Controls.WindowState.FullScreen : Avalonia.Controls.WindowState.Normal + }, }; desktop.MainWindow = mainWindow; @@ -52,7 +58,7 @@ public partial class App : Application throw new InvalidOperationException($"Application framework initialization cannot be fulfilled, ApplicationLifetime has unknown type inherited from: {string.Join(", ", ApplicationLifetime.GetType().GetInterfaces().Select(i => i.FullName))}"); } - + var mainViewLogger = loggerFactory.CreateLogger(); var mainView = new MainView(mainViewLogger) { diff --git a/GSS2.Test/Program.cs b/GSS2.Test/Program.cs index 90eab2e..fcd11dd 100644 --- a/GSS2.Test/Program.cs +++ b/GSS2.Test/Program.cs @@ -15,6 +15,10 @@ public partial class Program private static string[]? _args = null; private static readonly RootCommand _rootCommand = new("Run UI application"); + private static readonly Option _fullscreen = new("--fullscreen") + { + Description = "Run in fullscreen mode" + }; private static readonly Command _cameraTuningCommand = new("camera-tuning") { @@ -76,15 +80,15 @@ public partial class Program DefaultValueFactory = (_) => 0 }; - private static readonly Option _renderingModeArgument = new("--rendering-mode") + private static readonly Option _renderingMode = new("--rendering-mode") { Description = "Rendering mode to use", DefaultValueFactory = (_) => RenderingMode.X11 }; - private static readonly Option _hideConsoleArgument = new("--hide-console") + private static readonly Option _hideConsole = new("--hide-console") { Description = "Suppress console output", - DefaultValueFactory = (result) => result.GetRequiredValue(_renderingModeArgument) == RenderingMode.DRM + DefaultValueFactory = (result) => result.GetRequiredValue(_renderingMode) == RenderingMode.DRM }; public static event ConsoleCancelEventHandler? ShutdownRequested; @@ -94,7 +98,13 @@ public partial class Program { _args = args; + _rootCommand.SetAction(Ui); + _rootCommand.Add(_fullscreen); + _rootCommand.Add(_renderingMode); + _rootCommand.Add(_hideConsole); + _rootCommand.Add(_cameraTuningCommand); + _cameraTuningCommand.SetAction(CameraTuning); _cameraTuningCommand.Add(_cameraTuningOutputFile); _cameraTuningCommand.Add(_cameraTuningGainR); _cameraTuningCommand.Add(_cameraTuningGainG); @@ -102,18 +112,12 @@ public partial class Program _cameraTuningCommand.Add(_cameraTuningThreshold); _cameraTuningCommand.Add(_cameraTuningSteps); + _rootCommand.Add(_captureCommand); + _captureCommand.SetAction(Capture); _captureCommand.Add(_captureOutputFile); _captureCommand.Add(_captureIntencityWhite); _captureCommand.Add(_captureIntencityUv365nm); _captureCommand.Add(_captureIntencityUv254nm); - _rootCommand.Add(_captureCommand); - - _rootCommand.Add(_renderingModeArgument); - _rootCommand.Add(_hideConsoleArgument); - - _rootCommand.SetAction(Ui); - _cameraTuningCommand.SetAction(CameraTuning); - _captureCommand.SetAction(Capture); Console.CancelKeyPress += new ConsoleCancelEventHandler(OnProgramShutdown); Console.WriteLine("Press Ctrl+C to shut down."); diff --git a/GSS2.Test/PropgramUi.cs b/GSS2.Test/PropgramUi.cs index b765001..5e103cf 100644 --- a/GSS2.Test/PropgramUi.cs +++ b/GSS2.Test/PropgramUi.cs @@ -17,12 +17,15 @@ namespace GSS2.Test; public partial class Program { public static IHost ApplicationHost { get; } = BuildHostApp(); + public static bool IsFullscreen = false; private static void Ui(ParseResult parseResult) { var builder = BuildAvaloniaApp(); - var renderingMode = parseResult.GetValue(_renderingModeArgument); - var hideConsole = parseResult.GetValue(_hideConsoleArgument); + var renderingMode = parseResult.GetValue(_renderingMode); + var hideConsole = parseResult.GetValue(_hideConsole); + var fullscreen = parseResult.GetValue(_fullscreen); + IsFullscreen = fullscreen; if (hideConsole) SilenceConsole(); diff --git a/GSS2.UI.Core/MainWindow.axaml b/GSS2.UI.Core/MainWindow.axaml index 525adbc..4f786a8 100644 --- a/GSS2.UI.Core/MainWindow.axaml +++ b/GSS2.UI.Core/MainWindow.axaml @@ -6,7 +6,10 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:vm="using:GSS2.UI.Core.ViewModels" Title="{Binding Title}" - x:DataType="vm:MainWindowViewModel"> + x:DataType="vm:MainWindowViewModel" + SystemDecorations="{Binding SystemDecorations}" + Topmost="{Binding Topmost}" + WindowState="{Binding WindowState}"> diff --git a/GSS2.UI.Core/MainWindow.axaml.cs b/GSS2.UI.Core/MainWindow.axaml.cs index 02f6d49..0a06d29 100644 --- a/GSS2.UI.Core/MainWindow.axaml.cs +++ b/GSS2.UI.Core/MainWindow.axaml.cs @@ -1,3 +1,4 @@ +using Avalonia; using Avalonia.Controls; namespace GSS2.UI.Core; @@ -7,6 +8,9 @@ public partial class MainWindow : Window public MainWindow() { InitializeComponent(); +#if DEBUG + this.AttachDevTools(); +#endif } public void SetControl(UserControl control) diff --git a/GSS2.UI.Core/ViewModels/MainWindowViewModel.cs b/GSS2.UI.Core/ViewModels/MainWindowViewModel.cs index f0b7196..3625b64 100644 --- a/GSS2.UI.Core/ViewModels/MainWindowViewModel.cs +++ b/GSS2.UI.Core/ViewModels/MainWindowViewModel.cs @@ -1,3 +1,5 @@ +using Avalonia.Controls; + using CommunityToolkit.Mvvm.ComponentModel; using Microsoft.Extensions.Logging; @@ -9,6 +11,9 @@ public partial class MainWindowViewModel : ViewModelBase private readonly ILogger _logger; [ObservableProperty] private string _title; + [ObservableProperty] private SystemDecorations _systemDecorations; + [ObservableProperty] private bool _topmost; + [ObservableProperty] private WindowState _windowState; public MainWindowViewModel(ILogger logger) {