Exemplo n.º 1
0
        protected override void OnFontChanged(EventArgs e)
        {
            base.OnFontChanged(e);
            IntPtr hFont = ModernFonts.TabControl(this.FontSize, this.FontWeight).ToHfont();

            WinApi.SendMessage(this.Handle, WM_SETFONT, hFont, (IntPtr)(-1));
            WinApi.SendMessage(this.Handle, WM_FONTCHANGE, IntPtr.Zero, IntPtr.Zero);
            this.UpdateStyles();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Measures the text.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <returns>Preferred size.</returns>
        private Size MeasureText(string text)
        {
            Size preferredSize;

            using (Graphics g = CreateGraphics())
            {
                Size proposedSize = new Size(int.MaxValue, int.MaxValue);
                preferredSize = TextRenderer.MeasureText(g, text ?? string.Empty, ModernFonts.TabControl(this.FontSize, this.FontWeight), proposedSize, ModernPaint.GetTextFormatFlags(ContentAlignment.MiddleLeft) | TextFormatFlags.NoPadding);
            }

            return(preferredSize);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Draws the tab.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="graphics">The graphics.</param>
        private void DrawTab(int index, Graphics graphics)
        {
            Color foreColor;
            Color backColor = this.BackColor;

            if (!this.UseCustomBackColor)
            {
                backColor = ModernPaint.BackColor.Form(this.ThemeStyle);
            }

            TabPage   tabPage      = this.TabPages[index];
            Rectangle tabRectangle = this.GetTabRect(index);

            if (!this.Enabled)
            {
                foreColor = ModernPaint.ForeColor.Label.Disabled(this.ThemeStyle);
            }
            else
            {
                if (this.UseCustomForeColor)
                {
                    foreColor = Control.DefaultForeColor;
                }
                else
                {
                    foreColor = !this.UseStyleColors ? ModernPaint.ForeColor.TabControl.Normal(this.ThemeStyle) : ModernPaint.GetStyleColor(this.ColorStyle);
                }
            }

            if (index == 0)
            {
                tabRectangle.X = this.DisplayRectangle.X;
            }

            Rectangle bgRectangle = tabRectangle;

            tabRectangle.Width += 20;

            using (Brush bgBrush = new SolidBrush(backColor))
            {
                graphics.FillRectangle(bgBrush, bgRectangle);
            }

            TextRenderer.DrawText(graphics, tabPage.Text, ModernFonts.TabControl(this.FontSize, this.FontWeight), tabRectangle, foreColor, backColor, ModernPaint.GetTextFormatFlags(ContentAlignment.MiddleLeft));
        }