forked from amkovkov/GranuSightSoftware2
chore: move CameraView logic to itself
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user