feat: fullscreen argument

This commit is contained in:
2026-02-26 06:55:14 +03:00
parent 6248d556f3
commit 252201c930
6 changed files with 41 additions and 16 deletions
+8 -2
View File
@@ -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<MainView>();
var mainView = new MainView(mainViewLogger)
{
+15 -11
View File
@@ -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<bool> _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<RenderingMode> _renderingModeArgument = new("--rendering-mode")
private static readonly Option<RenderingMode> _renderingMode = new("--rendering-mode")
{
Description = "Rendering mode to use",
DefaultValueFactory = (_) => RenderingMode.X11
};
private static readonly Option<bool> _hideConsoleArgument = new("--hide-console")
private static readonly Option<bool> _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.");
+5 -2
View File
@@ -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();