Example #1
0
 /// <summary>
 /// Draws the background of a tab.
 /// </summary>
 /// <param name="g">The graphics to draw on.</param>
 /// <param name="param">The parameters required to draw the tab.</param>
 public virtual void DrawTabBackGround(Graphics g, DrawTabParams param)
 {
     using (var brush = new SolidBrush(GetTabBackColor(param)))
     {
         g.FillRectangle(brush, param.Bounds);
     }
 }
Example #2
0
        /// <summary>
        /// Draws the contents of a tab.
        /// </summary>
        /// <param name="g">The graphics to draw on.</param>
        /// <param name="param">The parameters required to draw the tab.</param>
        public override void DrawTabContents(Graphics g, DrawTabParams param)
        {
            base.DrawTabContents(g, param);

            // draw ribbon
            if (param.IsSelected)
            {
                using (var pen = new Pen(MarkerColor))
                {
                    if ((Parent.TabLocation & TabLocation.Top) != TabLocation.None)
                    {
                        g.DrawLine(pen, param.Bounds.Left, param.Bounds.Top, param.Bounds.Right, param.Bounds.Top);
                    }
                    else if ((Parent.TabLocation & TabLocation.Bottom) != TabLocation.None)
                    {
                        g.DrawLine(pen, param.Bounds.Left, param.Bounds.Bottom - 1, param.Bounds.Right, param.Bounds.Bottom - 1);
                    }
                    else if ((Parent.TabLocation & TabLocation.Left) != TabLocation.None)
                    {
                        g.DrawLine(pen, param.Bounds.Left, param.Bounds.Top, param.Bounds.Left, param.Bounds.Bottom);
                    }
                    else if ((Parent.TabLocation & TabLocation.Right) != TabLocation.None)
                    {
                        g.DrawLine(pen, param.Bounds.Right - 1, param.Bounds.Top, param.Bounds.Right - 1, param.Bounds.Bottom);
                    }
                }
            }
        }
Example #3
0
 /// <summary>
 /// Draws the separators between tabs.
 /// </summary>
 /// <param name="g">The graphics to draw on.</param>
 /// <param name="param">The parameters required to draw the tab.</param>
 public virtual void DrawSeparator(Graphics g, DrawTabParams param)
 {
     if (!param.IsSelected)
     {
         using (var pen = new Pen(SeparatorColor))
         {
             if (Parent.IsHorizontal)
             {
                 if (param.Index != Parent.SelectedIndex + 1 && (param.Index != 0 || (param.Index == 0 && Parent.ScrollButtons)))
                 {
                     g.DrawLine(pen, param.Bounds.Left, param.Bounds.Top + 4, param.Bounds.Left, param.Bounds.Bottom - 4);
                 }
                 if (param.Index == Parent.Tabs.Count - 1 && Parent.ScrollButtons)
                 {
                     g.DrawLine(pen, param.Bounds.Right - 1, param.Bounds.Top + 4, param.Bounds.Right - 1, param.Bounds.Bottom - 4);
                 }
             }
             else
             {
                 if (param.Index != Parent.SelectedIndex + 1 && (param.Index != 0 || (param.Index == 0 && Parent.ScrollButtons)))
                 {
                     g.DrawLine(pen, param.Bounds.Left + 4, param.Bounds.Top, param.Bounds.Right - 4, param.Bounds.Top);
                 }
                 if (param.Index == Parent.Tabs.Count - 1 && Parent.ScrollButtons)
                 {
                     g.DrawLine(pen, param.Bounds.Left + 4, param.Bounds.Bottom - 1, param.Bounds.Right - 4, param.Bounds.Bottom - 1);
                 }
             }
         }
     }
 }
Example #4
0
            /// <summary>
            /// Draws the control.
            /// </summary>
            public virtual void Render(Graphics g)
            {
                // draw backgound
                DrawBackGround(g);

                // draw tabs
                int i = 0;

                foreach (var tab in Parent.Tabs)
                {
                    var param = new DrawTabParams(i, tab, ReferenceEquals(tab, Parent.SelectedTab), Parent.GetTabState(tab), Parent.GetTabBounds(tab));
                    DrawTabBackGround(g, param);
                    DrawTabContents(g, param);
                    DrawSeparator(g, param);
                    i++;
                }

                // draw border
                if (Parent.BorderStyle != BorderStyle.None)
                {
                    DrawBorder(g, Parent.DisplayRectangle.GetInflated(1, 1));
                }

                // draw scroll buttons
                if (Parent.ScrollButtons)
                {
                    DrawNearScrollButton(g, new DrawButtonParams(Parent.GetNearScrollButtonState(), Parent.NearScrollButtonBounds));
                    DrawFarScrollButton(g, new DrawButtonParams(Parent.GetFarScrollButtonState(), Parent.FarScrollButtonBounds));
                }
            }
Example #5
0
            /// <summary>
            /// Returns close tab button backcolor for the given state.
            /// </summary>
            /// <param name="param">The state of the tab.</param>
            protected Color GetCloseTabButtonBackColor(DrawTabParams param)
            {
                var state = Parent.GetTabCloseButtonState(param.Tab);

                if ((state & ItemState.Hot) != ItemState.Inactive)
                {
                    return(HotTabBackColor);
                }
                else
                {
                    return(GetTabBackColor(param));
                }
            }
Example #6
0
 /// <summary>
 /// Draws the icon of a tab.
 /// </summary>
 /// <param name="g">The graphics to draw on.</param>
 /// <param name="param">The parameters required to draw the tab.</param>
 public virtual void DrawTabIcon(Graphics g, DrawTabParams param)
 {
     if (Parent.TextDirection == TextDirection.Right)
     {
         g.DrawImage(param.Tab.Icon, Parent.GetIconBounds(param.Tab));
     }
     else if (Parent.TextDirection == TextDirection.Down)
     {
         g.DrawImageRotatedDown(param.Tab.Icon, Parent.GetIconBounds(param.Tab));
     }
     else
     {
         g.DrawImageRotatedUp(param.Tab.Icon, Parent.GetIconBounds(param.Tab));
     }
 }
Example #7
0
 /// <summary>
 /// Draws the close button of a tab.
 /// </summary>
 /// <param name="g">The graphics to draw on.</param>
 /// <param name="param">The parameters required to draw the tab.</param>
 public override void DrawCloseButton(Graphics g, DrawTabParams param)
 {
     using (var icon = InvertBitmap(Parent.CloseTabImage))
     {
         if (Parent.TextDirection == TextDirection.Right)
         {
             g.DrawImage(icon, Parent.GetCloseButtonBounds(param.Tab));
         }
         else if (Parent.TextDirection == TextDirection.Down)
         {
             g.DrawImageRotatedDown(icon, Parent.GetCloseButtonBounds(param.Tab));
         }
         else
         {
             g.DrawImageRotatedUp(icon, Parent.GetCloseButtonBounds(param.Tab));
         }
     }
 }
Example #8
0
            /// <summary>
            /// Draws the close button of a tab.
            /// </summary>
            /// <param name="g">The graphics to draw on.</param>
            /// <param name="param">The parameters required to draw the tab.</param>
            public virtual void DrawCloseButton(Graphics g, DrawTabParams param)
            {
                Color buttonBackColor = GetCloseTabButtonBackColor(param);

                using (var buttonBrush = new SolidBrush(buttonBackColor))
                    g.FillRectangle(buttonBrush, Parent.GetCloseButtonBounds(param.Tab));

                if (Parent.TextDirection == TextDirection.Right)
                {
                    g.DrawImage(Parent.CloseTabImage, Parent.GetCloseButtonBounds(param.Tab));
                }
                else if (Parent.TextDirection == TextDirection.Down)
                {
                    g.DrawImageRotatedDown(Parent.CloseTabImage, Parent.GetCloseButtonBounds(param.Tab));
                }
                else
                {
                    g.DrawImageRotatedUp(Parent.CloseTabImage, Parent.GetCloseButtonBounds(param.Tab));
                }
            }
Example #9
0
            /// <summary>
            /// Draws the text of a tab.
            /// </summary>
            /// <param name="g">The graphics to draw on.</param>
            /// <param name="param">The parameters required to draw the tab.</param>
            public virtual void DrawTabText(Graphics g, DrawTabParams param)
            {
                var backColor = GetTabBackColor(param);
                var foreColor = GetTabForeColor(param);

                TextFormatFlags flags = TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine;

                if (Parent.TextDirection == TextDirection.Right)
                {
                    TextRenderer.DrawText(g, param.Tab.Text, param.Tab.Font, Parent.GetTextBounds(param.Tab), foreColor, backColor, flags);
                }
                else if (Parent.TextDirection == TextDirection.Down)
                {
                    g.DrawVerticalTextDown(param.Tab.Text, param.Tab.Font, Parent.GetTextBounds(param.Tab), foreColor, backColor, flags);
                }
                else
                {
                    g.DrawVerticalTextUp(param.Tab.Text, param.Tab.Font, Parent.GetTextBounds(param.Tab), foreColor, backColor, flags);
                }
            }
Example #10
0
            /// <summary>
            /// Draws the contents of a tab.
            /// </summary>
            /// <param name="g">The graphics to draw on.</param>
            /// <param name="param">The parameters required to draw the tab.</param>
            public virtual void DrawTabContents(Graphics g, DrawTabParams param)
            {
                // text
                if (!string.IsNullOrEmpty(param.Tab.Text))
                {
                    DrawTabText(g, param);
                }

                // icon
                if (param.Tab.Icon != null)
                {
                    DrawTabIcon(g, param);
                }

                // close button
                if (Parent.ShowCloseTabButtons && param.IsSelected)
                {
                    DrawCloseButton(g, param);
                }
            }
Example #11
0
 /// <summary>
 /// Returns tab backcolor for the given state.
 /// </summary>
 /// <param name="param">The state of the tab.</param>
 protected Color GetTabBackColor(DrawTabParams param)
 {
     if ((param.State & ItemState.Pressed) != ItemState.Inactive)
     {
         return(UseTabColors ? param.Tab.BackColor.Lighten(0.1f) : PressedTabBackColor);
     }
     else if ((param.State & ItemState.Hot) != ItemState.Inactive && param.IsSelected)
     {
         return(UseTabColors ? param.Tab.BackColor.Darken(0.05f) : HotAndActiveTabBackColor);
     }
     else if ((param.State & ItemState.Hot) != ItemState.Inactive && !param.IsSelected)
     {
         return(UseTabColors ? param.Tab.BackColor.Darken(0.05f) : HotTabBackColor);
     }
     else if (param.IsSelected)
     {
         return(UseTabColors ? param.Tab.BackColor : ActiveTabBackColor);
     }
     else
     {
         return(UseTabColors ? param.Tab.BackColor.Darken(0.1f) : InactiveTabBackColor);
     }
 }
Example #12
0
            /// <summary>
            /// Returns tab forecolor for the given state.
            /// </summary>
            /// <param name="param">The state of the tab.</param>
            protected Color GetTabForeColor(DrawTabParams param)
            {
                if (UseTabColors)
                {
                    return(param.Tab.ForeColor);
                }

                if ((param.State & ItemState.Pressed) != ItemState.Inactive)
                {
                    return(PressedTabForeColor);
                }
                else if ((param.State & ItemState.Hot) != ItemState.Inactive && !param.IsSelected)
                {
                    return(HotTabForeColor);
                }
                else if (param.IsSelected)
                {
                    return(ActiveTabForeColor);
                }
                else
                {
                    return(InactiveTabForeColor);
                }
            }
Example #13
0
 /// <summary>
 /// Draws the separators between tabs.
 /// </summary>
 /// <param name="g">The graphics to draw on.</param>
 /// <param name="param">The parameters required to draw the tab.</param>
 public override void DrawSeparator(Graphics g, DrawTabParams param)
 {
     // do not draw separators
 }