示例#1
0
文件: TabPanel.cs 项目: zzyn/poc
        public void RemoveTab(Control c)
        {
            Controls.Remove(c);
            c.Visible = false;

            InnerTab it = c as InnerTab;

            if (it != null)
            {
                Form form = it.MainControl as Form;
                it.MainRemove();

                if (form != null)
                {
                    form.Visible         = false;
                    form.TopLevel        = true;
                    form.Dock            = DockStyle.None;
                    form.FormBorderStyle = FormBorderStyle.Sizable;

                    Rectangle r = RectangleToScreen(new Rectangle(0, 0, Width, Height - CaptionPadding.Top));

                    Size bd = SystemInformation.Border3DSize;

                    form.SetBounds(r.X - bd.Width, r.Y + CaptionPadding.Top - SystemInformation.CaptionHeight - bd.Height, r.Width + bd.Width * 2, Height + bd.Height * 2);

                    form.Resize += new EventHandler(form_Resize);

                    Control p = Parent;
                    while (!(p is Form))
                    {
                        if (p == null)
                        {
                            break;
                        }
                        p = p.Parent;
                    }
                    if (p != null)
                    {
                        form.Show((Form)p);
                    }
                    else
                    {
                        form.Show();
                    }
                }
            }
        }
示例#2
0
文件: TabPanel.cs 项目: zzyn/poc
        public void AddTab(Form form, string title)
        {
            form.Visible         = false;
            form.Resize         -= new EventHandler(form_Resize);
            form.TopLevel        = false;
            form.WindowState     = FormWindowState.Normal;
            form.Dock            = DockStyle.Fill;
            form.Margin          = Padding.Empty;
            form.FormBorderStyle = FormBorderStyle.None;


            InnerTab it = new InnerTab(form);

            it.Text = title;

            Controls.Add(it);
        }
示例#3
0
文件: TabPanel.cs 项目: zzyn/poc
 protected virtual void TabSetting(Control c)
 {
     if (IsTab)
     {
         c.Visible = false;
         c.Dock    = DockStyle.Fill;
         CaptionBasePanel cp = c as CaptionBasePanel;
         if (cp != null)
         {
             cp.TextVisible  = false;
             cp.FolderOpened = true;
             InnerTab it = c as InnerTab;
             if (it != null)
             {
                 it.MainControl.AutoSize = false;
             }
         }
     }
     else
     {
         CaptionBasePanel cp = c as CaptionBasePanel;
         if (cp != null)
         {
             cp.TextVisible  = true;
             cp.FolderOpened = false;
             InnerTab it = c as InnerTab;
             if (it != null)
             {
                 it.MainControl.AutoSize = true;
             }
         }
         c.Dock = DockStyle.Top;
         if (TabVisible(c))
         {
             c.Visible = true;
         }
         else
         {
             c.Visible = false;
         }
     }
 }
示例#4
0
文件: TabPanel.cs 项目: zzyn/poc
        /// <summary>
        /// 描画処理の拡張
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            int clheight = DisplayRectangle.Height;
            int clwidth  = DisplayRectangle.Width;

            e.Graphics.TranslateTransform(DisplayRectangle.X, DisplayRectangle.Y);


            if (IsTab)
            {
                Brush foreBrush = new SolidBrush(ButtonLabelForeColor);
                Color fc        = ButtonLabelForeColor;
                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
                int labelHeight = FontHeight + CaptionMargin.Vertical + 6;

                Control selected = null;


                Rectangle cr = e.ClipRectangle;

                e.Graphics.SetClip(new Rectangle(5, 0, clwidth - 10, clheight));

                for (int i = Controls.Count - 1; i >= 0; i--)
                {
                    Control c = Controls[i];
                    if (TabVisible(c))
                    {
                        //タブ描画
                        if (!c.Visible)
                        {
                            if (i >= LeftTab - 1)
                            {
                                Rectangle r = TabRect(LeftTab, c);

                                if (r.Left < clwidth)
                                {
                                    Rectangle rt = r;
                                    if (i > 0)
                                    {
                                        rt.X     -= 6;
                                        rt.Width += 6;
                                    }
                                    rt.Y      += 2;
                                    rt.Height -= 2;

                                    CaptionBasePanel cbp = c as CaptionBasePanel;

                                    Color bc = CaptionGraphics.BlendColor((cbp != null) ? cbp.ButtonLabelBackColor : ButtonLabelBackColor, Color.White, 60);


                                    GraphicsPath gp = CaptionGraphics.CreateRoundRectPath(rt, 4, 4, true, true, false, false);
                                    CaptionGraphics.DrawShadow(e.Graphics, gp, 1, 3, 20);

                                    e.Graphics.FillPath((HoverControl == c) ? new SolidBrush(CaptionGraphics.BlendColor(ClickableColor, bc, 20)) : new SolidBrush(bc), gp);

                                    if (cbp != null)
                                    {
                                        cbp.DrawMarkAndText(e.Graphics, Font, ButtonLabelForeColor, ButtonLabelForeColor, new Point(r.Left + CaptionMargin.Left, rt.Y + CaptionMargin.Top), true);
                                    }
                                    else
                                    {
                                        e.Graphics.FillEllipse(foreBrush, r.Left + CaptionMargin.Left, rt.Y + CaptionMargin.Top, FontHeight, FontHeight);
                                        TextRenderer.DrawText(e.Graphics, c.Text, Font, new Point(r.Left + (int)(1.5f * FontHeight), rt.Y + CaptionMargin.Top), ButtonLabelForeColor);
                                    }
                                }
                            }
                        }
                        else
                        {
                            selected = c;
                        }
                    }
                }

                e.Graphics.SetClip(cr);

                if (selected != null)
                {
                    CaptionBasePanel cbp = selected as CaptionBasePanel;

                    Rectangle sr = TabRect(LeftTab, selected);

                    GraphicsPath gp = CaptionGraphics.CreateRoundRectPath(sr, 4, 4, true, true, false, false);

                    CaptionGraphics.DrawShadow(e.Graphics, gp);

                    //複雑な形状なので全体再描画
                    Rectangle    r   = new Rectangle(6, labelHeight, clwidth - 12, clheight - labelHeight - 6);
                    GraphicsPath gpf = CaptionGraphics.CreateRoundRectPath(r, 2, 2, false, true, true, true);

                    CaptionGraphics.DrawShadow(e.Graphics, gpf);

                    Color blb = ButtonLabelBackColor;
                    Color bbc = BackColor;
                    if (cbp != null)
                    {
                        blb = cbp.ButtonLabelBackColor;
                        bbc = cbp.BackColor;
                    }

                    Brush brush = new SolidBrush((HoverControl == selected) ? ClickableColor : blb);
                    e.Graphics.FillPath(new SolidBrush(bbc), gpf);

                    Pen p = new Pen(blb, 2);
                    e.Graphics.DrawPath(p, gpf);
                    e.Graphics.FillPath(brush, gp);
                    e.Graphics.DrawPath(new Pen(brush, 2), gp);

                    if (Focused)
                    {
                        e.Graphics.DrawPath(new Pen(ButtonLabelFocusBackColor, 1), gp);
                    }

                    Icon ico = null;
                    if (selected is InnerTab)
                    {
                        InnerTab it = selected as InnerTab;
                        Form     fm = it.MainControl as Form;
                        if (fm != null)
                        {
                            ico = fm.Icon;
                        }
                    }

                    if (cbp != null)
                    {
                        cbp.DrawMarkAndText(e.Graphics, Font, Focused ? ButtonLabelFocusBackColor : fc, fc, new Point(sr.Left + CaptionMargin.Left, sr.Top + CaptionMargin.Top));
                    }
                    else
                    {
                        e.Graphics.FillEllipse(new SolidBrush(Focused ? ButtonLabelFocusBackColor : fc), sr.Left + CaptionMargin.Left, CaptionMargin.Top + 1, FontHeight, FontHeight);
                        TextRenderer.DrawText(e.Graphics, selected.Text, Font, new Point(CaptionMargin.Left + sr.Left + (int)(1.5f * FontHeight), CaptionMargin.Top + 1), fc);
                    }
                }
                else
                {
                    //複雑な形状なので全体再描画
                    Rectangle    r   = new Rectangle(6, labelHeight, clwidth - 12, clheight - labelHeight - 6);
                    GraphicsPath gpf = CaptionGraphics.CreateRoundRectPath(r, 2, 2, false, true, true, true);

                    CaptionGraphics.DrawShadow(e.Graphics, gpf);

                    e.Graphics.FillPath(Brushes.Gainsboro, gpf);
                    e.Graphics.DrawPath(new Pen(Color.Silver, 2), gpf);
                }

                if (TabRightOver())
                {
                    //コントローラー描画
                    Brush brush = new SolidBrush(ButtonLabelBackColor);

                    int ar = CONTROLER_WIDTH / 8;

                    //CONTROLER_WIDTH

                    Rectangle r = new Rectangle(clwidth - CONTROLER_WIDTH - 6, 0, CONTROLER_WIDTH / 2, CONTROLER_WIDTH / 2);

                    GraphicsPath gp = CaptionGraphics.CreateRoundRectPath(r, 4, 4);
                    CaptionGraphics.DrawShadow(e.Graphics, gp);
                    e.Graphics.FillPath((LeftTab > 0) ? brush : Brushes.Silver, gp);
                    e.Graphics.FillPolygon(foreBrush, new Point[] { new Point(r.X + ar, r.Y + r.Height / 2), new Point(r.X + ar * 3, r.Y + r.Height / 2 + ar), new Point(r.X + ar * 3, r.Y + r.Height / 2 - ar) });

                    r  = new Rectangle(clwidth - CONTROLER_WIDTH / 2 - 5, 0, CONTROLER_WIDTH / 2, CONTROLER_WIDTH / 2);
                    gp = CaptionGraphics.CreateRoundRectPath(r, 4, 4);
                    CaptionGraphics.DrawShadow(e.Graphics, gp);
                    e.Graphics.FillPath((RightTab < Controls.Count - 1) ? brush : Brushes.Silver, gp);
                    e.Graphics.FillPolygon(foreBrush, new Point[] { new Point(r.X + ar * 3, r.Y + r.Height / 2), new Point(r.X + ar, r.Y + r.Height / 2 + ar), new Point(r.X + ar, r.Y + r.Height / 2 - ar) });
                }
            }
            e.Graphics.TranslateTransform(-DisplayRectangle.X, -DisplayRectangle.Y);

            base.OnPaint(e);
        }