forked from amkovkov/GranuSightSoftware2
feat: fullscreen argument
This commit is contained in:
@@ -30,7 +30,8 @@ public partial class App : Application
|
|||||||
{
|
{
|
||||||
case IClassicDesktopStyleApplicationLifetime desktop:
|
case IClassicDesktopStyleApplicationLifetime desktop:
|
||||||
Console.WriteLine("Application running in classic style");
|
Console.WriteLine("Application running in classic style");
|
||||||
|
Console.WriteLine($"Application running in {(Program.IsFullscreen ? "fullscreen" : "window")} mode");
|
||||||
|
|
||||||
desktop.Startup += (_, _) => Program.ApplicationHost.RunAsync();
|
desktop.Startup += (_, _) => Program.ApplicationHost.RunAsync();
|
||||||
desktop.Exit += (_, _) => Program.ApplicationHost.StopAsync();
|
desktop.Exit += (_, _) => Program.ApplicationHost.StopAsync();
|
||||||
|
|
||||||
@@ -38,6 +39,11 @@ public partial class App : Application
|
|||||||
var mainWindow = new MainWindow()
|
var mainWindow = new MainWindow()
|
||||||
{
|
{
|
||||||
DataContext = new MainWindowViewModel(mainWindowViewModelLogger)
|
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;
|
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))}");
|
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 mainViewLogger = loggerFactory.CreateLogger<MainView>();
|
||||||
var mainView = new MainView(mainViewLogger)
|
var mainView = new MainView(mainViewLogger)
|
||||||
{
|
{
|
||||||
|
|||||||
+15
-11
@@ -15,6 +15,10 @@ public partial class Program
|
|||||||
|
|
||||||
private static string[]? _args = null;
|
private static string[]? _args = null;
|
||||||
private static readonly RootCommand _rootCommand = new("Run UI application");
|
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")
|
private static readonly Command _cameraTuningCommand = new("camera-tuning")
|
||||||
{
|
{
|
||||||
@@ -76,15 +80,15 @@ public partial class Program
|
|||||||
DefaultValueFactory = (_) => 0
|
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",
|
Description = "Rendering mode to use",
|
||||||
DefaultValueFactory = (_) => RenderingMode.X11
|
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",
|
Description = "Suppress console output",
|
||||||
DefaultValueFactory = (result) => result.GetRequiredValue(_renderingModeArgument) == RenderingMode.DRM
|
DefaultValueFactory = (result) => result.GetRequiredValue(_renderingMode) == RenderingMode.DRM
|
||||||
};
|
};
|
||||||
|
|
||||||
public static event ConsoleCancelEventHandler? ShutdownRequested;
|
public static event ConsoleCancelEventHandler? ShutdownRequested;
|
||||||
@@ -94,7 +98,13 @@ public partial class Program
|
|||||||
{
|
{
|
||||||
_args = args;
|
_args = args;
|
||||||
|
|
||||||
|
_rootCommand.SetAction(Ui);
|
||||||
|
_rootCommand.Add(_fullscreen);
|
||||||
|
_rootCommand.Add(_renderingMode);
|
||||||
|
_rootCommand.Add(_hideConsole);
|
||||||
|
|
||||||
_rootCommand.Add(_cameraTuningCommand);
|
_rootCommand.Add(_cameraTuningCommand);
|
||||||
|
_cameraTuningCommand.SetAction(CameraTuning);
|
||||||
_cameraTuningCommand.Add(_cameraTuningOutputFile);
|
_cameraTuningCommand.Add(_cameraTuningOutputFile);
|
||||||
_cameraTuningCommand.Add(_cameraTuningGainR);
|
_cameraTuningCommand.Add(_cameraTuningGainR);
|
||||||
_cameraTuningCommand.Add(_cameraTuningGainG);
|
_cameraTuningCommand.Add(_cameraTuningGainG);
|
||||||
@@ -102,18 +112,12 @@ public partial class Program
|
|||||||
_cameraTuningCommand.Add(_cameraTuningThreshold);
|
_cameraTuningCommand.Add(_cameraTuningThreshold);
|
||||||
_cameraTuningCommand.Add(_cameraTuningSteps);
|
_cameraTuningCommand.Add(_cameraTuningSteps);
|
||||||
|
|
||||||
|
_rootCommand.Add(_captureCommand);
|
||||||
|
_captureCommand.SetAction(Capture);
|
||||||
_captureCommand.Add(_captureOutputFile);
|
_captureCommand.Add(_captureOutputFile);
|
||||||
_captureCommand.Add(_captureIntencityWhite);
|
_captureCommand.Add(_captureIntencityWhite);
|
||||||
_captureCommand.Add(_captureIntencityUv365nm);
|
_captureCommand.Add(_captureIntencityUv365nm);
|
||||||
_captureCommand.Add(_captureIntencityUv254nm);
|
_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.CancelKeyPress += new ConsoleCancelEventHandler(OnProgramShutdown);
|
||||||
Console.WriteLine("Press Ctrl+C to shut down.");
|
Console.WriteLine("Press Ctrl+C to shut down.");
|
||||||
|
|||||||
@@ -17,12 +17,15 @@ namespace GSS2.Test;
|
|||||||
public partial class Program
|
public partial class Program
|
||||||
{
|
{
|
||||||
public static IHost ApplicationHost { get; } = BuildHostApp();
|
public static IHost ApplicationHost { get; } = BuildHostApp();
|
||||||
|
public static bool IsFullscreen = false;
|
||||||
|
|
||||||
private static void Ui(ParseResult parseResult)
|
private static void Ui(ParseResult parseResult)
|
||||||
{
|
{
|
||||||
var builder = BuildAvaloniaApp();
|
var builder = BuildAvaloniaApp();
|
||||||
var renderingMode = parseResult.GetValue(_renderingModeArgument);
|
var renderingMode = parseResult.GetValue(_renderingMode);
|
||||||
var hideConsole = parseResult.GetValue(_hideConsoleArgument);
|
var hideConsole = parseResult.GetValue(_hideConsole);
|
||||||
|
var fullscreen = parseResult.GetValue(_fullscreen);
|
||||||
|
IsFullscreen = fullscreen;
|
||||||
|
|
||||||
if (hideConsole)
|
if (hideConsole)
|
||||||
SilenceConsole();
|
SilenceConsole();
|
||||||
|
|||||||
@@ -6,7 +6,10 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:vm="using:GSS2.UI.Core.ViewModels"
|
xmlns:vm="using:GSS2.UI.Core.ViewModels"
|
||||||
Title="{Binding Title}"
|
Title="{Binding Title}"
|
||||||
x:DataType="vm:MainWindowViewModel">
|
x:DataType="vm:MainWindowViewModel"
|
||||||
|
SystemDecorations="{Binding SystemDecorations}"
|
||||||
|
Topmost="{Binding Topmost}"
|
||||||
|
WindowState="{Binding WindowState}">
|
||||||
|
|
||||||
<ContentControl x:Name="MainContent" />
|
<ContentControl x:Name="MainContent" />
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
|
||||||
namespace GSS2.UI.Core;
|
namespace GSS2.UI.Core;
|
||||||
@@ -7,6 +8,9 @@ public partial class MainWindow : Window
|
|||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
#if DEBUG
|
||||||
|
this.AttachDevTools();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetControl(UserControl control)
|
public void SetControl(UserControl control)
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@@ -9,6 +11,9 @@ public partial class MainWindowViewModel : ViewModelBase
|
|||||||
private readonly ILogger<MainWindowViewModel> _logger;
|
private readonly ILogger<MainWindowViewModel> _logger;
|
||||||
|
|
||||||
[ObservableProperty] private string _title;
|
[ObservableProperty] private string _title;
|
||||||
|
[ObservableProperty] private SystemDecorations _systemDecorations;
|
||||||
|
[ObservableProperty] private bool _topmost;
|
||||||
|
[ObservableProperty] private WindowState _windowState;
|
||||||
|
|
||||||
public MainWindowViewModel(ILogger<MainWindowViewModel> logger)
|
public MainWindowViewModel(ILogger<MainWindowViewModel> logger)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user