using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PXP.Crawler.API.Designers.Controls;
using PXP.Crawler.API.Model;

namespace PXP.Crawler.API.Designers
{
    public class NodeContainerDesigner : NodeDesigner
    {
        internal NodeContainerDesignerControl nodeDesignerControl;

        public NodeContainerDesignerControl ContainerControl
        {
            get
            {
                return nodeDesignerControl;
            }
        }

        public NodeContainerDesigner(Node node): base(node)
        {
            
        }

        public override void CreateDesignerControl(Node node)
        {
            nodeDesignerControl = new NodeContainerDesignerControl(node);
            control = nodeDesignerControl;
            control.Location = node.designerData.Bounds.Location;
            control.Size = node.designerData.Bounds.Size;

            nodeDesignerControl.MouseDown += nodeDesignerControl_MouseDown;
        }

        void nodeDesignerControl_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Clicks == 2)
            {
                /*if (base.designObject.nodeForm != null)
                {
                    if (base.control.Parent == designObject.nodeForm)
                    {
                        designObject.nodeForm.Hide();
                        designObject.nodeForm.Controls.Remove(nodeDesignerControl.DesignerContainer);
                        control.Controls.Add(nodeDesignerControl.DesignerContainer);
                    }
                    else
                    {
                        nodeDesignerControl.DesignerContainer.Parent.Controls.Remove(nodeDesignerControl.DesignerContainer);
                        designObject.nodeForm.Controls.Add(nodeDesignerControl.DesignerContainer);
                        designObject.nodeForm.Size = control.Size;
                        designObject.nodeForm.Show();
                    }
                }*/
                //MessageBox.Show("DC");
            }
        }   
     
        
    }
}
