using Hawkeye.VisionBuilder.Workflow.Datatypes;
using Hawkeye.VisionBuilder.Workflow.Operations.Attributes;

namespace Hawkeye.VisionBuilder.Workflow.Operations.AI;

[Category("AI")]
[IgnoreOperation]
public class Color128BinaryOperation:ColorAIOperation
{
    public Color128BinaryOperation() : base("prob128binary")
    {
        IsRaw = true;
    }


    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();
    }
}