using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PXP.Crawler.API.Utils;

namespace PXP.Crawler.API.Designers.Controls
{
    public class NodeDesignerControlContainer : ContainerControl
    {
        internal NodeContainerDesignerControl nodeDescCont;
        internal bool mouseEnabled = true;
        public NodeDesignerControlContainer(NodeContainerDesignerControl nodeDesignerControl)
        {
            nodeDescCont = nodeDesignerControl;

            //SetStyle(ControlStyles.Opaque, true);
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);            
            UpdateStyles();
            base.BackColor = Color.Transparent;
            Enabled = true;

            InitializeComponent();
        }

        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // NodeDesignerControlContainer
            // 
            this.Font = new System.Drawing.Font("Tahoma", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
            this.ResumeLayout(false);

        }

        public bool MouseEnabled
        {
            get { return mouseEnabled; }
            set { mouseEnabled = value; }
        }

        protected override void WndProc(ref Message m)
        {
            if (mouseEnabled)
            {
                base.WndProc(ref m);
            }
            else
            {
                if (m.Msg == (int)Win32.WindowsMessage.NCHITTEST)
                {
                    m.Result = (IntPtr)Win32.HitTest.TRANSPARENT;
                }
                else
                {
                    base.WndProc(ref m);
                }
            }

        }
    }
}
