using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PXP.Crawler.API.Model;

namespace PXP.Crawler.API.Plugins.Operators
{
    [NodeInfo("Add (Integer)", typeof(AddIntNode), Category = "Operators", Description = "Add two integers...",
        DefaultWidth = 60, DefaultHeight = 40)]
    public class AddIntNode : Node
    {
        public AddIntNode(Program program) : base(program)
        {
            Name = "Add";
        }

        private int val1 = 0;
        private int val2 = 0;
        private int res = 0;

        public override void CreateDesigner()
        {
            base.CreateDesigner();
            designer.Control.BackColor = Color.Teal;
        }

        [NodePin(NodePin.NodePinDirection.Input)]
        public int Value1
        {
            get
            {
                return val1;
            }
            set
            {
                val1 = value;
                res = val1 + val2;
                NotifyPropertyChange("Result");
            }
        }

        [NodePin(NodePin.NodePinDirection.Input)]
        public int Value2
        {
            get
            {
                return val2;
            }
            set
            {
                val2 = value;
                res = val1 + val2;
                NotifyPropertyChange("Result");

            }
        }

        [NodePin]
        public int Result
        {
            get
            {
                return res;
            }
        }
    }
}
