コード例 #1
0
        public override void RenderHeader(Graphics g, TabListPage page, TabListPageState state)
        {
            Color           fillColor;
            Color           textColor;
            Rectangle       fillBounds;
            Rectangle       textRectangle;
            TextFormatFlags flags;

            fillBounds    = new Rectangle(page.HeaderBounds.Left + 10, page.HeaderBounds.Top, page.HeaderBounds.Width - 10, page.HeaderBounds.Height);
            textRectangle = Rectangle.Inflate(fillBounds, -4, -4);

            // define the most appropriate colors
            fillColor = page.Owner.BackColor;
            textColor = page.Owner.ForeColor;

            // fill the background
            using (Brush brush = new SolidBrush(fillColor))
                g.FillRectangle(brush, fillBounds);

            // draw a chevron
            if ((state & TabListPageState.Selected) == TabListPageState.Selected)
            {
                using (Font font = new Font(page.Font.FontFamily, page.Font.Size + 2, FontStyle.Bold))
                    TextRenderer.DrawText(g, "»", font, page.HeaderBounds.Location, page.ForeColor);
            }

            // draw the text
            flags = TextFormatFlags.VerticalCenter | TextFormatFlags.Left | TextFormatFlags.NoPrefix | TextFormatFlags.SingleLine | TextFormatFlags.WordEllipsis;

            using (Font font = new Font(page.Font, (state & TabListPageState.Selected) == TabListPageState.Selected ? FontStyle.Bold : FontStyle.Regular))
                TextRenderer.DrawText(g, page.Text, font, textRectangle, textColor, fillColor, flags);
        }
コード例 #2
0
        /// <summary>
        /// Renders the header for the given <see cref="TabListPage"/>.
        /// </summary>
        /// <param name="g">The <see cref="Graphics"/> to draw on.</param>
        /// <param name="page">The <see cref="TabListPage"/> to be processed.</param>
        /// <param name="state">One of the <see cref="TabListPageState"/> values that specifies the state
        /// of the <see cref="TabListPage"/> to render.</param>
        /// <seealso cref="M:Cyotek.Windows.Forms.TabListPageRenderer.RenderHeader(Graphics,TabListPage,TabListPageState)"/>
        public override void RenderHeader(Graphics g, TabListPage page, TabListPageState state)
        {
            Color           fillColor;
            Color           textColor;
            Rectangle       fillBounds;
            Rectangle       textRectangle;
            TextFormatFlags flags;

            fillBounds    = page.HeaderBounds;
            textRectangle = Rectangle.Inflate(fillBounds, -4, -4);

            // define the most appropriate colors
            if ((state & TabListPageState.Selected) == TabListPageState.Selected)
            {
                fillColor = SystemColors.Highlight;
                textColor = SystemColors.HighlightText;
            }
            else if ((state & TabListPageState.HotLight) == TabListPageState.HotLight)
            {
                fillColor = SystemColors.ControlLight;
                textColor = page.Owner.ForeColor;
            }
            else
            {
                fillColor = SystemColors.Window;
                textColor = page.Owner.ForeColor;
            }

            // fill the background
            using (Brush brush = new SolidBrush(fillColor))
            {
                g.FillRectangle(brush, fillBounds);
            }

            // draw the text
            flags = TextFormatFlags.VerticalCenter | TextFormatFlags.Left | TextFormatFlags.NoPrefix | TextFormatFlags.SingleLine | TextFormatFlags.WordEllipsis;
            TextRenderer.DrawText(g, page.Text, page.Font, textRectangle, textColor, fillColor, flags);

            // focus
            if ((state & TabListPageState.Focused) == TabListPageState.Focused)
            {
                NativeMethods.DrawFocusRectangle(g, fillBounds);
            }
        }
コード例 #3
0
        public override void RenderHeader(Graphics g, TabListPage page, TabListPageState state)
        {
            Color fillColor;
              Color textColor;
              Rectangle fillBounds;
              Rectangle textRectangle;
              TextFormatFlags flags;
              int arrowSize;

              arrowSize = 6;
              fillBounds = page.HeaderBounds;
              fillBounds.Width -= arrowSize;
              textRectangle = Rectangle.Inflate(fillBounds, -4, -4);

              // define the most appropriate colors
              if ((state & TabListPageState.Selected) == TabListPageState.Selected)
              {
            fillColor = SystemColors.Highlight;
            textColor = SystemColors.HighlightText;
              }
              else if ((state & TabListPageState.Hot) == TabListPageState.Hot)
              {
            fillColor = SystemColors.ControlLightLight;
            textColor = page.Owner.ForeColor;
              }
              else
              {
            fillColor = page.Owner.BackColor;
            textColor = page.Owner.ForeColor;
              }

              // fill the background
              using (Brush brush = new SolidBrush(fillColor))
            g.FillRectangle(brush, fillBounds);

              // draw the selection arrow
              if ((state & TabListPageState.Selected) == TabListPageState.Selected)
              {
            int y;
            int x;
            Point point1;
            Point point2;
            Point point3;

            y = fillBounds.Top + ((fillBounds.Height - (arrowSize * 2)) / 2);
            x = fillBounds.Right;

            point1 = new Point(x, y);
            point2 = new Point(x + arrowSize, y + arrowSize);
            point3 = new Point(x, y + (arrowSize * 2));

            using (Brush brush = new SolidBrush(fillColor))
            {
              g.FillPolygon(brush, new Point[] { point1, point2, point3 });
            }
              }

              // draw the text
              flags = TextFormatFlags.VerticalCenter | TextFormatFlags.Left | TextFormatFlags.NoPrefix | TextFormatFlags.SingleLine | TextFormatFlags.WordEllipsis;
              TextRenderer.DrawText(g, page.Text, page.Font, textRectangle, textColor, fillColor, flags);

              // focus
              if ((state & TabListPageState.Focused) == TabListPageState.Focused)
              {
            SizeF textSize;
            int offset;

            textSize = TextRenderer.MeasureText(g, page.Text, page.Font, textRectangle.Size, flags);
            offset = 2;

            ControlPaint.DrawFocusRectangle(g, new Rectangle(textRectangle.X, textRectangle.Y, (int)textSize.Width + offset, (int)textSize.Height + offset), textColor, fillColor);
              }
        }
コード例 #4
0
 public abstract void RenderHeader(Graphics g, TabListPage page, TabListPageState state);
コード例 #5
0
 public abstract void RenderHeader(Graphics g, TabListPage page, TabListPageState state);
コード例 #6
0
        public override void RenderHeader(Graphics g, TabListPage page, TabListPageState state)
        {
            Color           fillColor;
            Color           textColor;
            Rectangle       fillBounds;
            Rectangle       textRectangle;
            TextFormatFlags flags;
            int             arrowSize;

            arrowSize         = 6;
            fillBounds        = page.HeaderBounds;
            fillBounds.Width -= arrowSize;
            textRectangle     = Rectangle.Inflate(fillBounds, -4, -4);

            // define the most appropriate colors
            if ((state & TabListPageState.Selected) == TabListPageState.Selected)
            {
                fillColor = SystemColors.Highlight;
                textColor = SystemColors.HighlightText;
            }
            else if ((state & TabListPageState.Hot) == TabListPageState.Hot)
            {
                fillColor = SystemColors.ControlLightLight;
                textColor = page.Owner.ForeColor;
            }
            else
            {
                fillColor = page.Owner.BackColor;
                textColor = page.Owner.ForeColor;
            }

            // fill the background
            using (Brush brush = new SolidBrush(fillColor))
                g.FillRectangle(brush, fillBounds);

            // draw the selection arrow
            if ((state & TabListPageState.Selected) == TabListPageState.Selected)
            {
                int   y;
                int   x;
                Point point1;
                Point point2;
                Point point3;

                y = fillBounds.Top + ((fillBounds.Height - (arrowSize * 2)) / 2);
                x = fillBounds.Right;

                point1 = new Point(x, y);
                point2 = new Point(x + arrowSize, y + arrowSize);
                point3 = new Point(x, y + (arrowSize * 2));

                using (Brush brush = new SolidBrush(fillColor))
                {
                    g.FillPolygon(brush, new[]
                    {
                        point1, point2, point3
                    });
                }
            }

            // draw the text
            flags = TextFormatFlags.VerticalCenter | TextFormatFlags.Left | TextFormatFlags.NoPrefix | TextFormatFlags.SingleLine | TextFormatFlags.WordEllipsis;
            TextRenderer.DrawText(g, page.Text, page.Font, textRectangle, textColor, fillColor, flags);

            // focus
            if ((state & TabListPageState.Focused) == TabListPageState.Focused)
            {
                SizeF textSize;
                int   offset;

                textSize = TextRenderer.MeasureText(g, page.Text, page.Font, textRectangle.Size, flags);
                offset   = 2;

                ControlPaint.DrawFocusRectangle(g, new Rectangle(textRectangle.X, textRectangle.Y, (int)textSize.Width + offset, (int)textSize.Height + offset), textColor, fillColor);
            }
        }