private void PaintSelectedPage(Graphics g, CCTabControl ctl, TabInfo tab)
        {
            Rectangle pageRect = BorderRectangle;

            using (GraphicsPath path = new GraphicsPath())
            {
                path.AddArc(tab.TabRectangle.Left - ArcSize, pageRect.Top - ArcSize, ArcSize, ArcSize, 90, -90);
                path.AddArc(tab.TabRectangle.Left, tab.TabRectangle.Top, ArcSize, ArcSize, 180, 90);
                path.AddArc(tab.TabRectangle.Right - ArcSize, tab.TabRectangle.Top, ArcSize, ArcSize, 270, 90);
                path.AddArc(tab.TabRectangle.Right, pageRect.Top - ArcSize, ArcSize, ArcSize, 180, -90);
                path.AddArc(pageRect.Right - ArcSize, pageRect.Top, ArcSize, ArcSize, 270, 90);
                path.AddArc(pageRect.Right - ArcSize, pageRect.Bottom - ArcSize, ArcSize, ArcSize, 0, 90);
                path.AddArc(pageRect.Left, pageRect.Bottom - ArcSize, ArcSize, ArcSize, 90, 90);
                path.AddArc(pageRect.Left, pageRect.Top, ArcSize, ArcSize, 180, 90);
                path.CloseAllFigures();
                g.FillPath(new LinearGradientBrush(Rectangle.FromLTRB(pageRect.Left, tab.TabRectangle.Top, pageRect.Right, pageRect.Bottom), ctl.SelectedPanelColor, ctl.GradientColor, LinearGradientMode.Vertical), path);
                g.DrawPath(new Pen(ctl.LineColor), path);

                Point textPoint = tab.TabRectangle.Location;
                textPoint.Offset(TextPadding, TextPadding);

                Color textColor;
                if (tab.HasFlag(TabState.Enabled))
                {
                    textColor = ctl.SelectedTextColor;
                }
                else
                {
                    textColor = ctl.DisabledTextColor;
                }
                TextRenderer.DrawText(g, tab.Text, ctl.Font, textPoint, textColor);
            }
        }
        public void PaintTab(Graphics g, CCTabControl ctl, TabInfo tab)
        {
            using (GraphicsPath path = CCPathTool.FlatRoundedRectangle(
                       tab.TabRectangle, ArcSize))
            {
                g.FillPath(new SolidBrush(ctl.PanelColor), path);
                g.DrawPath(new Pen(ctl.LineColor), path);
            }

            Point textPoint = tab.TabRectangle.Location;

            textPoint.Offset(TextPadding, TextPadding);

            Color textColor;

            if (tab.HasFlag(TabState.Enabled))
            {
                textColor = ctl.ForeColor;
            }
            else
            {
                textColor = ctl.DisabledTextColor;
            }
            TextRenderer.DrawText(g, tab.Text, ctl.Font, textPoint, textColor);
        }
        private void OnRemovePanel(object sender, EventArgs e)
        {
            //try
            //{
            CCTabControl            tabCtl             = Control as CCTabControl;
            IDesignerHost           _designerHost      = GetService(typeof(IDesignerHost)) as IDesignerHost;
            IComponentChangeService componentChangeSvc = GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            using (DesignerTransaction _designerTransaction = _designerHost.CreateTransaction("Add Panel"))
            {
                int tabIndex = tabCtl.SelectedIndex;
                if ((tabIndex < 0) || (tabIndex >= tabCtl.TabPages.Count))
                {
                    return;
                }

                Control panel = tabCtl.TabPages[tabIndex];
                componentChangeSvc.OnComponentChanging(tabCtl, null);
                tabCtl.Controls.Remove(panel);
                componentChangeSvc.OnComponentChanged(tabCtl, null, null, null);
                _designerHost.DestroyComponent(panel);
                _designerTransaction.Commit();

                //if (tabCtl.Controls.Count != tabCtl.TabPages.Count)
                //    Debug.WriteLine("Tab control out of sync");

                tabIndex = tabCtl.SelectedIndex;
//                if ((tabIndex < 0) || (tabIndex >= tabCtl.TabPages.Count))
//                    Debug.WriteLine("Tab selection is invalid");
            }
            //}
            //catch (Exception ex) { Debug.WriteLine(ex.ToString()); }
        }
        public void Paint(PaintEventArgs e, CCTabControl owner, TabInfo tab)
        {
            if (!tab.HasFlag(TabState.Visible) || (tab.TabRectangle == Rectangle.Empty))
            {
                return;
            }

            if (tab.HasFlag(TabState.Selected))
            {
                PaintSelectedPage(e.Graphics, owner, tab);
            }
            else
            {
                this.PaintTab(e.Graphics, owner, tab);
            }
        }
        private void OnAddPanel(object sender, EventArgs e)
        {
            CCTabControl            tabCtl             = Control as CCTabControl;
            IDesignerHost           _designerHost      = GetService(typeof(IDesignerHost)) as IDesignerHost;
            IComponentChangeService componentChangeSvc = GetService(typeof(IComponentChangeService)) as IComponentChangeService;

            DesignerTransaction _designerTransaction = _designerHost.CreateTransaction("Add Panel");

            Control panel = _designerHost.CreateComponent(tabCtl.GetDefaultPageType()) as Control;

            panel.Text = panel.Name;
            if (panel != null)
            {
                componentChangeSvc.OnComponentChanging(Control, null);
                Control.Controls.Add(panel);
                componentChangeSvc.OnComponentChanged(Control, null, null, null);
            }
            _designerTransaction.Commit();
        }
        void CreateTabGlyphs()
        {
            CCTabControl tabControl = Control as CCTabControl;
            int          count      = Control.Controls.Count;

            for (int i = 0; i < count; i++)
            {
                Point     offset = BehaviorService.ControlToAdornerWindow(Control);
                Rectangle rect   = tabControl.GetTabRect(i);
                if (rect != Rectangle.Empty)
                {
                    rect.Offset(offset);
                    Glyph g = new ControlBodyGlyph(rect, Cursors.Hand, Control, new TabBehavior(this));
                    _tabGlyphs.Add(g);
                    tabControlAdorner.Glyphs.Add(g);
                }
                else
                {
                    _tabGlyphs.Add(null);
                }
            }
        }
 public TabPageCollection(CCTabControl owner)
     : base()
 {
     this._owner = owner;
 }
 public ControlCollection(CCTabControl owner)
     : base(owner)
 {
     _owner = owner;
 }