using Hawkeye.VisionBuilder.Workflow.Datatypes;
using Hawkeye.VisionBuilder.Workflow.Operations.Attributes;
using OpenCvSharp;
using System.Runtime.InteropServices;
using Hawkeye.VisionBuilder.Workflow.DataTransfer;

namespace Hawkeye.VisionBuilder.Workflow.Operations.AI;

[Category("AI")]
[IgnoreOperation]
public class Color128SimpleOperation: ColorAIOperation
{
    public Color128SimpleOperation():base("bg128simple")
    {
        
    }


    public override string FilterClasses { get; set; } = "1";
    public override FilePath ModelFilePath { get; set; } = new FilePath(){Format = "Model file(*.h5)|*.h5"};


    public override void Save(BinaryWriter bw)
    {
        base.Save(bw);
        bw.Write(FilterClasses);
        bw.Write(ModelFilePath.Path);
    }

    public override void Load(BinaryReader br)
    {
        base.Load(br);
        FilterClasses = br.ReadString();
        ModelFilePath.Path = br.ReadString();
    }

    public override void Save(Dictionary<string, object> dict)
    {
        base.Save(dict);
        dict[nameof(FilterClasses)] = FilterClasses;
        dict[nameof(ModelFilePath)] = ModelFilePath.Path;
    }

    public override void Load(Dictionary<string, object> dict)
    {
        base.Load(dict);
        if (dict.ContainsKey(nameof(FilterClasses)))
            FilterClasses = dict[nameof(FilterClasses)].ToString();
        if (dict.ContainsKey(nameof(ModelFilePath)))
            ModelFilePath.Path = dict[nameof(ModelFilePath)].ToString();
    }
}