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

namespace PXP.Crawler.API.Plugins.Net.Chrome
{
    public class ChromeElementNodeBase : Node
    {
        protected internal GeckoNode node;
        protected internal GeckoElement element;
        protected internal bool hasElement = false;

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

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

        protected virtual void OnElementChanged()
        {
            
        }

        [NodePin(NodePin.NodePinDirection.Input)]
        [Browsable(false)]
        public virtual GeckoNode Element
        {
            get
            {
                return element;
            }
            set
            {
                node = value;
                if (node is GeckoElement)
                {
                    element = (GeckoElement) node;
                    hasElement = true;
                }
                else
                {
                    element = null;
                    hasElement = false;
                }
                OnElementChanged();
                NotifyPropertyChange("Element");
            }
        }
    }
}
