Exemple #1
0
 private bool IsTabItemsContaining(Form f, out MdiGMTabItem theTab)
 {
     theTab = null;
     foreach (MdiGMTabItem tab in _listTabItems)
     {
         if (f == tab.form)
         {
             theTab = tab;
             return(true);
         }
     }
     return(false);
 }
Exemple #2
0
        private MdiGMTabItem CreateNewTab(Form f)
        {
            MdiGMTabItem tab = new MdiGMTabItem(this);

            tab.form                       = f;
            tab.CloseBtn                   = new WLButton(_owner);
            tab.CloseBtn.ColorTable        = TabCloseBtnColor;
            tab.CloseBtn.BorderType        = ButtonBorderType.Ellipse;
            tab.CloseBtn.DrawForePathTwice = true;
            //tab.CloseBtn.DrawLightGlass = true;
            tab.CloseBtn.ClickSendBackOject = f;
            tab.CloseBtn.ForePathGetter     = new
                                              ButtonForePathGetter(Gdu.WinFormUI.MyGraphics.GraphicsPathHelper.CreateSingleLineCloseFlag);
            tab.CloseBtn.Click += new EventHandler(OnTabCloseBtnClick);

            // menu item
            tab.MenuItemPop        = new ToolStripMenuItem();
            tab.MenuItemPop.Tag    = f;
            tab.MenuItemPop.Click += new EventHandler(OnPopMenuItemClick);
            _menuPopup.Items.Add(tab.MenuItemPop);
            return(tab);
        }
Exemple #3
0
        private void RenderTabItem(Graphics g, MdiGMTabItem tab)
        {
            Rectangle rect      = tab.Bounds;
            Region    oldRegion = g.Clip;
            Region    newRegion = new Region(rect);

            g.Clip = newRegion;

            // fill backgroung
            Color backTop, backBottom;

            if (tab.IsFormActive)
            {
                backTop    = TabActiveBackColorTop;
                backBottom = TabActiveBackColorBottom;
            }
            else
            {
                backTop    = TabDeactiveBackColorTop;
                backBottom = TabDeactiveBackColorBottom;
            }

            // background
            using (LinearGradientBrush lb = new LinearGradientBrush(
                       rect, backTop, backBottom, LinearGradientMode.Vertical))
            {
                using (GraphicsPath path = PathGetter.GetTabBorderPath(rect, TabSlopeWidth))
                {
                    g.FillPath(lb, path);
                }
            }

            // icon
            if (ShowTabIcon && tab.form.Icon != null)
            {
                if (tab.IconRect.Right < tab.Bounds.Right)
                {
                    g.DrawIcon(tab.form.Icon, tab.IconRect);
                }
            }

            // text
            TextRenderer.DrawText(g, tab.form.Text, tab.form.Font, tab.TextRect, tab.form.ForeColor,
                                  TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis);

            // outter border
            rect.Width--;
            rect.Height--;
            using (Pen p = new Pen(TabOutterBorderColor))
            {
                if (tab.IsFormActive)
                {
                    Rectangle rectTab    = tab.Bounds;
                    Rectangle rectBottom = BarBottomRegionBounds;
                    Point     p1         = new Point(rectBottom.X, rectBottom.Y - 1);
                    Point     p2         = new Point(rectTab.X, rectTab.Bottom - 1);
                    Point     p3         = new Point(rectTab.X + TabSlopeWidth, rectTab.Y);
                    Point     p4         = new Point(rectTab.Right - 1 - TabSlopeWidth, rectTab.Y);
                    Point     p5         = new Point(rectTab.Right - 1, rectTab.Bottom - 1);
                    Point     p6         = new Point(rectBottom.Right - 1, rectBottom.Y - 1);
                    g.Clip = oldRegion;
                    g.DrawLines(p, new Point[] { p1, p2, p3, p4, p5, p6 });
                    g.Clip = newRegion;
                }
                else
                {
                    using (GraphicsPath path = PathGetter.GetTabBorderPath(rect, TabSlopeWidth))
                    {
                        g.DrawPath(p, path);
                    }
                }
            }

            // inner border
            rect.Inflate(-1, -1);
            rect.Height++;  // 为了使bar-bottom-region 与 active-tab 的连线能覆盖非 active-tab 的底部的线
            using (Pen p = new Pen(TabInnerBorderColor))
            {
                using (GraphicsPath path = PathGetter.GetTabBorderPath(rect, TabSlopeWidth))
                {
                    g.DrawPath(p, path);
                }
            }

            // do not let the active-tab to have bottom-line
            if (tab.IsFormActive)
            {
                Rectangle rtmp = tab.Bounds;
                Point     p1   = new Point(rtmp.Left + 1, rtmp.Bottom - 1);
                Point     p2   = new Point(rtmp.Right - 2, rtmp.Bottom - 1);
                using (Pen pen = new Pen(backBottom))
                {
                    g.DrawLine(pen, p1, p2);
                }
            }

            //close btn
            tab.CloseBtn.Bounds = tab.CloseBtnRect;
            tab.CloseBtn.DrawButton(g);

            g.Clip = oldRegion;
            newRegion.Dispose();
        }