示例#1
0
        public Size GetPreferredTabSize(Graphics g)
        {
            if (Text == "")
            {
                return(new Size(0, 0));
            }
            BpTabControl tabs = (BpTabControl)Parent;
            Size         size = GetTabTextExtent(g, Text);

            if ((imgIndex >= 0) && (imgIndex < tabs.ImageList.Images.Count))
            {
                size.Height = Math.Max(size.Height, tabs.ImageList.ImageSize.Height);
                size.Width += padding + tabs.ImageList.ImageSize.Width;
            }
            return(size);
        }
示例#2
0
        protected virtual Size GetTabTextExtent(Graphics g, string text)
        {
            BpTabControl       tabs    = (BpTabControl)Parent;
            VisualStyleElement element = tabs.GetGuessedElement(this);

            /*if (Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(element))
             * {
             * VisualStyleRenderer renderer = new VisualStyleRenderer(element);
             * Rectangle bounds = renderer.GetTextExtent(g, text, TextFormatFlags.Default);
             * return new Size(bounds.Width, bounds.Height);
             * }
             * else*/
            {
                Font font = SystemFonts.MenuFont;
                return(TextRenderer.MeasureText(text, font));
            }
        }
示例#3
0
        protected virtual void DrawTabText(Graphics g, Rectangle bounds, string text, TextFormatFlags format)
        {
            BpTabControl       tabs    = (BpTabControl)Parent;
            VisualStyleElement element = tabs.GetElement(this);
            Font  font = SystemFonts.MenuFont;
            Color color;

            if (Disabled)
            {
                color = SystemColors.GrayText;
            }
            else
            {
                color = SystemColors.MenuText;
            }

            TextRenderer.DrawText(g, text, font, bounds, color, format);
        }
示例#4
0
        protected virtual void OnTabPaint(TabPaintEventArgs e)
        {
            BpTabControl tabs   = (BpTabControl)Parent;
            Rectangle    bounds = e.ClipRectangle;

            if ((imgIndex >= 0) && (imgIndex < tabs.ImageList.Images.Count))
            {
                int y = bounds.Y;
                y += (bounds.Height - tabs.ImageList.ImageSize.Height) / 2;
                tabs.ImageList.Draw(e.Graphics, bounds.X, y, imgIndex);
                bounds = new Rectangle(bounds.X + tabs.ImageList.ImageSize.Width + padding, bounds.Y, bounds.Width - tabs.ImageList.ImageSize.Width - padding, bounds.Height);
            }
            DrawTabText(e.Graphics, bounds, Text,
                        TextFormatFlags.EndEllipsis | TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
            if (TabPaint != null)
            {
                TabPaint(this, e);
            }
        }