using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace DockableUI
{
    public partial class DockedFormsContainer : UserControl
    {
        public DockedFormsContainer()
        {
            InitializeComponent();
            this.BackColor = SystemColors.Control;
            //this.toolStrip1.Renderer = new Tabs.TabsRenderer();
        }

        internal Splitter AssignedSplitter { get; set; }

        #region Properties

        [DefaultValue(typeof(Color), "Control")]
        public override Color BackColor
        {
            get { return base.BackColor; }
            set { base.BackColor = value; }
        }

        public new bool Visible
        {
            get { return base.Visible; }
            set
            {
                //if (AssignedSplitter != null) AssignedSplitter.Visible = value;
                base.Visible = value;
            }
        }

        public new DockStyle Dock
        {
            get { return base.Dock; }
            set
            {
                if (value != base.Dock)
                {
                    switch (value)
                    {
                        case DockStyle.Bottom:
                            //resizeSplitter1.Dock = DockStyle.Top;
                            Tabs.Dock = DockStyle.Bottom;
                            base.Dock = value;
                            break;
                        case DockStyle.Top:
                            //resizeSplitter1.Dock = DockStyle.Bottom;
                            base.Dock = value;
                            break;
                        case DockStyle.Left:
                            //resizeSplitter1.Dock = DockStyle.Right;
                            Tabs.Dock = DockStyle.Bottom;
                            base.Dock = value;
                            break;
                        case DockStyle.Right:
                            //resizeSplitter1.Dock = DockStyle.Left;
                            Tabs.Dock = DockStyle.Bottom;
                            base.Dock = value;
                            break;
                        case DockStyle.Fill:
                            Tabs.Dock = DockStyle.Top;
                            base.Dock = value;
                            break;
                    }
                }
            }
        }

        #endregion

        private void DockedFormsContainer_ControlAdded(object sender, ControlEventArgs e)
        {
            DockingForm f = e.Control as DockingForm;
            if (f != null)
            {
                f.BringToFront();
            }
        }

        private void DockedFormsContainer_ParentChanged(object sender, EventArgs e)
        {
            Parent.Resize += new EventHandler(delegate(object senderA, EventArgs eA) { base.MaximumSize = Parent.ClientSize; });
            base.MaximumSize = Parent.ClientSize;
            base.MinimumSize = new Size(24, 24);
        }

        public void RemoveTab(DockingForm control)
        {
            Tabs.RemoveTab(control);
        }

        public void RemoveTab(Tabs.TabButton btn)
        {
            Tabs.RemoveTab(btn);
        }

        public void AddTab(DockingForm control)
        {
            Tabs.AddTab(control);
        }

        //private bool highlight=false;
        //private PictureBox highlightplane;
        //public bool Highlight
        //{
        //    get { return highlight; }
        //    set
        //    {
        //        if (value != highlight)
        //        {
        //            if (value)
        //            {
        //                highlightplane = new PictureBox();

        //            }
        //        }
        //    }
        //}
    }
}
