using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms.VisualStyles;
using DevExpress.Data.Helpers;
using PXP.Crawler.API.Model;

namespace PXP.Crawler.API.Plugins.Values
{
    [NodeInfo("Counter", typeof (CounterNode), Category = "Values")]
    public class CounterNode : Node
    {
        private int curr = 0;

        public CounterNode(Program program) : base(program)
        {
        }

        [NodePropertyPin]
        public bool Up
        {
            set
            {
                curr++;
                NotifyPropertyChange("Current");
                if (curr == Max)
                {
                    curr = Min;
                }
                else
                {
                    curr++;
                }
            }
        }

        [NodePropertyPin]
        public bool Down
        {
            set
            {
                curr--;
                if (curr == Min)
                {
                    curr = Max;
                }
                else { }
                NotifyPropertyChange("Current");                
            }
        }

        [NodePropertyPin(NodePinDirection.Input)]
        public bool Reset
        {
            set
            {
                curr = 0;
                NotifyPropertyChange("Current");
            }
        }

        [NodePropertyPin(NodePinDirection.Input)]
        public int Min { get; set; }


        [NodePropertyPin(NodePinDirection.Input)]
        public int Max { get; set; }


        [NodePropertyPin(NodePinDirection.Output)]
        public int Current
        {
            get
            {
                return curr;
            }
        }

    }

}
