forked from amkovkov/GranuSightSoftware2
feat: fullscreen argument
This commit is contained in:
@@ -30,6 +30,7 @@ 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;
|
||||
|
||||
|
||||
+15
-11
@@ -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.");
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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}">
|
||||
|
||||
<ContentControl x:Name="MainContent" />
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<MainWindowViewModel> _logger;
|
||||
|
||||
[ObservableProperty] private string _title;
|
||||
[ObservableProperty] private SystemDecorations _systemDecorations;
|
||||
[ObservableProperty] private bool _topmost;
|
||||
[ObservableProperty] private WindowState _windowState;
|
||||
|
||||
public MainWindowViewModel(ILogger<MainWindowViewModel> logger)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user