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.Values
{
    [NodeInfo("As String", typeof(AsStringNode), Category = "Values",
        DefaultWidth = 80, DefaultHeight = 40, LockSize = true)]
    public class AsStringNode : Node
    {
        public AsStringNode(Program program) : base(program)
        {
        }

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

        private string valStr = "";
        private object val = null;

        [NodePin(NodePin.NodePinDirection.Input)]
        public object Value
        {
            get
            {
                return val;
            }
            set
            {
                val = value;
                if (val != null)
                {
                    ValueString = val.ToString();
                }
                else
                {
                    ValueString = "";
                }
            }
        }

        [NodePin(NodePin.NodePinDirection.Output)]        
        public string ValueString
        {
            get { return valStr; }
            internal set
            {
                valStr = value;
                NotifyPropertyChange("ValueString");
            }
        }
    }
}
