using CommunityToolkit.Mvvm.ComponentModel;
using OpenCvSharp;
using VisionBuilder.UI.Common.Commands;
using VisionBuilder.UI.Common.Commands.Interfaces;

namespace VisionBuilder.UI.Common.ViewModel;

public partial class PreviewVM:ObservableObject, IEventHandler<ImageProcessedEvent>
{
    [ObservableProperty] private Mat _imagePreview;
    [ObservableProperty] private bool _isError;

    public void Handle(ImageProcessedEvent @event)
    {
        IsError = @event.HasError;
        ImagePreview = @event.ImageAnalysis.Clone();
    }
}