Ejemplo n.º 1
0
        /// <summary>
        /// Returns a modified font based on the property value.
        /// </summary>
        /// <param name="tabFont">The base font.</param>
        /// <param name="activeTabEnum">The enum specifying how to change it.</param>
        /// <returns>A new font modified.</returns>
        private static Font GetModifiedFont(Font tabFont, ActiveTabFontStyleEnum activeTabEnum)
        {
            Font res = new Font(tabFont, FontStyle.Regular);

            switch (activeTabEnum)
            {
            case ActiveTabFontStyleEnum.Bold:
                res = FontChangeBold(res, true);
                break;

            case ActiveTabFontStyleEnum.Bold_Italic:
                res = FontChangeBold(res, true);
                res = FontChangeItalic(res, true);
                break;

            case ActiveTabFontStyleEnum.Italic:
                res = FontChangeItalic(res, true);
                break;

            case ActiveTabFontStyleEnum.Strikeout:
                res = FontChangeStrikeout(res, true);
                break;

            case ActiveTabFontStyleEnum.Underline:
                res = FontChangeUnderline(res, true);
                break;
            }

            return(res);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Sets the value for the property ActiveTabFontStyle.
 /// </summary>
 /// <param name="tabControl">The tab control to set.</param>
 /// <param name="value">The value to be set.</param>
 private static void Static_SetActiveTabFontStyle(TabControl tabControl, ActiveTabFontStyleEnum value)
 {
     if (CheckForProperty(tabControl, newPropertiesEnum.ActiveFontStyle))
     {
         newProperties[tabControl.GetHashCode()][newPropertiesEnum.ActiveFontStyle] = value;
         if (value != ActiveTabFontStyleEnum.Default)
         {
             SetCustomDrawingMode(tabControl, newPropertiesEnum.ActiveFontStyle, true);
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Paints the gray disable font.
        /// </summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The DrawItem event arguments.</param>
        private static void TabControl_DrawItem(object sender, DrawItemEventArgs e)
        {
            TabControl cTabControl = ((TabControl)sender);

            // painting in middle of SetVisible operation
            if (e.Index >= cTabControl.TabCount)
            {
                return;
            }
            Graphics g = e.Graphics;

            using (StringFormat strFrmt = new StringFormat())
            {
                strFrmt.Trimming      = StringTrimming.Character;
                strFrmt.Alignment     = StringAlignment.Center;
                strFrmt.LineAlignment = StringAlignment.Center;
                Rectangle tmpRec;
                Color     col;
                bool      UsesMnemonic = Static_GetUseMnemonic(cTabControl);
                //AIS Bug-1644
                if (UsesMnemonic)
                {
                    strFrmt.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;
                }
                //AIS Bug-1644

                ActiveTabFontStyleEnum activeTabEnum = Static_GetActiveTabFontStyle(cTabControl);
                Font  tabFont;
                Color bgColor;

                tabFont = cTabControl.Font;
                bgColor = cTabControl.TabPages[e.Index].BackColor;
                if (bgColor == Color.Transparent)
                {
                    bgColor = cTabControl.BackColor;
                }

                if (cTabControl.Enabled && GetTabEnabled(cTabControl, cTabControl.TabPages[e.Index]))
                {
                    col = cTabControl.ForeColor;
                }
                else
                {
                    col = Color.Gray;
                }

                Rectangle tabRect = cTabControl.GetTabRect(e.Index);
                using (SolidBrush drawBrush = new SolidBrush(col), bgBrush = new SolidBrush(bgColor))
                {
                    if ((cTabControl.Alignment == TabAlignment.Top) || (cTabControl.Alignment == TabAlignment.Bottom))
                    {
                        if (cTabControl.SelectedIndex == e.Index)
                        {
                            if (activeTabEnum != ActiveTabFontStyleEnum.Default)
                            {
                                tabFont = GetModifiedFont(tabFont, activeTabEnum);
                            }

                            if (cTabControl.Alignment == TabAlignment.Top)
                            {
                                tmpRec = new Rectangle(tabRect.X, tabRect.Y + tabRect.Height - 2, tabRect.Width, 4);
                            }
                            else
                            {
                                tmpRec = new Rectangle(tabRect.X, tabRect.Y - 2, tabRect.Width, 4);
                            }
                        }
                        else
                        {
                            tmpRec = e.Bounds;
                        }

                        g.FillRectangle(bgBrush, tmpRec);

                        strFrmt.FormatFlags = 0;
                        g.DrawString(cTabControl.TabPages[e.Index].Text, tabFont, drawBrush, tabRect, strFrmt);
                    }
                    else
                    {
                        if (cTabControl.SelectedIndex == e.Index)
                        {
                            if (activeTabEnum != ActiveTabFontStyleEnum.Default)
                            {
                                tabFont = GetModifiedFont(tabFont, activeTabEnum);
                            }

                            if (cTabControl.Alignment == TabAlignment.Left)
                            {
                                tmpRec = new Rectangle(tabRect.X + tabRect.Width - 2, tabRect.Y, 4, tabRect.Height);
                            }
                            else
                            {
                                tmpRec = new Rectangle(tabRect.X - 2, tabRect.Y, 4, tabRect.Height);
                            }
                        }
                        else
                        {
                            tmpRec = e.Bounds;
                        }

                        g.FillRectangle(bgBrush, tmpRec);

                        strFrmt.FormatFlags = StringFormatFlags.DirectionVertical;
                        g.DrawString(cTabControl.TabPages[e.Index].Text, tabFont, drawBrush, tabRect, strFrmt);
                    }
                }
            }
            cTabControl.Update();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Sets the value for the property ActiveTabFontStyle.
 /// </summary>
 /// <param name="tabControl">The tab control to set.</param>
 /// <param name="value">The value to be set.</param>
 public void SetActiveTabFontStyle(TabControl tabControl, ActiveTabFontStyleEnum value)
 {
     Static_SetActiveTabFontStyle(tabControl, value);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Sets the value for the property ActiveTabFontStyle.
 /// </summary>
 /// <param name="tabControl">The tab control to set.</param>
 /// <param name="value">The value to be set.</param>
 private static void Static_SetActiveTabFontStyle(TabControl tabControl, ActiveTabFontStyleEnum value)
 {
     if (CheckForProperty(tabControl, newPropertiesEnum.ActiveFontStyle))
     {
         newProperties[tabControl.GetHashCode()][newPropertiesEnum.ActiveFontStyle] = value;
         if (value != ActiveTabFontStyleEnum.Default)
             SetCustomDrawingMode(tabControl, newPropertiesEnum.ActiveFontStyle, true);
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Returns a modified font based on the property value.
        /// </summary>
        /// <param name="tabFont">The base font.</param>
        /// <param name="activeTabEnum">The enum specifying how to change it.</param>
        /// <returns>A new font modified.</returns>
        private static Font GetModifiedFont(Font tabFont, ActiveTabFontStyleEnum activeTabEnum)
        {
            Font res = new Font(tabFont, FontStyle.Regular);
            switch (activeTabEnum)
            {
                case ActiveTabFontStyleEnum.Bold:
                    res = FontChangeBold(res, true);
                    break;
                case ActiveTabFontStyleEnum.Bold_Italic:
                    res = FontChangeBold(res, true);
                    res = FontChangeItalic(res, true);
                    break;
                case ActiveTabFontStyleEnum.Italic:
                    res = FontChangeItalic(res, true);
                    break;
                case ActiveTabFontStyleEnum.Strikeout:
                    res = FontChangeStrikeout(res, true);
                    break;
                case ActiveTabFontStyleEnum.Underline:
                    res = FontChangeUnderline(res, true);
                    break;
            }

            return res;
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Sets the value for the property ActiveTabFontStyle.
 /// </summary>
 /// <param name="tabControl">The tab control to set.</param>
 /// <param name="value">The value to be set.</param>
 public void SetActiveTabFontStyle(TabControl tabControl, ActiveTabFontStyleEnum value)
 {
     Static_SetActiveTabFontStyle(tabControl, value);
 }