chore: move CameraView logic to itself

This commit is contained in:
2026-01-23 08:42:58 +03:00
parent 8896629ce2
commit d4e7c300f4
8 changed files with 100 additions and 139 deletions
-35
View File
@@ -27,40 +27,5 @@ public partial class MainWindowViewModel : ViewModelBase
_lightsService = lightsService;
_logger = logger;
CameraViewModel = cameraViewModel;
_logger.LogInformation("Initialized");
}
public async Task<(LibCameraSharp.FrameBuffer, LibCameraSharp.StreamConfiguration)?> CaptureImage(int bufferId)
{
_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(bufferId, 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;
}
}