feat: GSS2.Test - UI+DI, Vulkan render test

This commit is contained in:
2026-01-22 08:04:04 +03:00
parent 2ce8d3e966
commit 5af1c508f5
23 changed files with 1093 additions and 131 deletions
+66
View File
@@ -0,0 +1,66 @@
using Avalonia.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using GSS2.Core.Hardware;
namespace GSS2.Test;
public partial class MainWindowViewModel : ViewModelBase
{
private readonly CameraService _cameraService;
private readonly IlluminatorService _illuminatorService;
private readonly LightsService _lightsService;
private readonly ILogger<MainWindowViewModel> _logger;
[ObservableProperty] private CameraViewModel _cameraViewModel;
public MainWindowViewModel(
CameraService cameraService,
IlluminatorService illuminatorService,
LightsService lightsService,
ILogger<MainWindowViewModel> logger,
CameraViewModel cameraViewModel
)
{
_cameraService = cameraService;
_illuminatorService = illuminatorService;
_lightsService = lightsService;
_logger = logger;
CameraViewModel = cameraViewModel;
_logger.LogInformation("Initialized");
}
public async Task<(LibCameraSharp.FrameBuffer, LibCameraSharp.StreamConfiguration)?> CaptureImage()
{
_logger.LogInformation("Capture image");
_lightsService.CpuLoad(0.5, 1, System.Drawing.Color.Aqua);
(LibCameraSharp.FrameBuffer, LibCameraSharp.StreamConfiguration)? result = null;
try
{
_illuminatorService.SetIntensity(0.01, 0, 0);
_illuminatorService.TurnOn();
result = await _cameraService.CaptureViewFinderBuffer(CancellationToken.None);
_lightsService.Flash(0.5, 2, System.Drawing.Color.Green);
}
catch (Exception e)
{
_logger.LogError(e, "Error while image capture");
_lightsService.Flash(0.5, 2, System.Drawing.Color.Red);
}
finally
{
_illuminatorService.TurnOff();
}
var snowfallTimer = new System.Timers.Timer(3000);
snowfallTimer.Elapsed += (_, _) =>
{
_lightsService.Snowfall(0.3, 1, System.Drawing.Color.Aqua);
snowfallTimer.Dispose();
};
snowfallTimer.Start();
return result;
}
}