using System;
using System.ComponentModel;

namespace OpenCVStudio_v0
{
    public sealed class Filter2DBlockProperties
    {
        private readonly ProjectManager projectManager;
        private readonly ProjectBlock block;
        private Filter2DKernel kernel;

        public Filter2DBlockProperties(ProjectManager projectManager, ProjectBlock block)
        {
            this.projectManager = projectManager ?? throw new ArgumentNullException(nameof(projectManager));
            this.block = block ?? throw new ArgumentNullException(nameof(block));
            kernel = projectManager.GetBlockParameter(block.Id, "Kernel", Filter2DKernel.Identity);
        }

        [Category("Фильтр")]
        [DisplayName("Ядро")]
        public Filter2DKernel Kernel
        {
            get => kernel;
            set
            {
                kernel = value;
                projectManager.SetBlockParameter(block.Id, "Kernel", value);
            }
        }

        [Category("Блок")]
        [DisplayName("Название")]
        [ReadOnly(true)]
        public string Name => block.Name;
    }
}