Beispiel #1
0
        private void DrawTabPages(Graphics g)
        {
            Point pt    = PointToClient(Control.MousePosition);
            bool  flag  = false;
            bool  flag2 = base.Alignment == TabAlignment.Top || base.Alignment == TabAlignment.Bottom;
            LinearGradientMode linearGradientMode = flag2 ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal;

            if (flag2)
            {
                IntPtr upDownButtonHandle = UpDownButtonHandle;
                if (upDownButtonHandle != IntPtr.Zero && Win32.IsWindowVisible(upDownButtonHandle))
                {
                    RECT lpRect = default(RECT);
                    Win32.GetWindowRect(upDownButtonHandle, ref lpRect);
                    Rectangle r = Rectangle.FromLTRB(lpRect.left, lpRect.top, lpRect.right, lpRect.bottom);
                    r = RectangleToClient(r);
                    switch (base.Alignment)
                    {
                    case TabAlignment.Top:
                        r.Y = 0;
                        break;

                    case TabAlignment.Bottom:
                        r.Y = base.ClientRectangle.Height - DisplayRectangle.Height;
                        break;
                    }
                    r.Height = base.ClientRectangle.Height;
                    g.SetClip(r, CombineMode.Exclude);
                    flag = true;
                }
            }
            for (int i = 0; i < base.TabCount; i++)
            {
                TabPage   tabPage     = base.TabPages[i];
                Rectangle tabRect     = GetTabRect(i);
                bool      flag3       = tabRect.Contains(pt);
                bool      flag4       = base.SelectedIndex == i;
                Color     color       = _BaseTabolor;
                Color     borderColor = _BorderColor;
                Blend     blend       = new Blend();
                blend.Positions = new float[5]
                {
                    0f,
                    0.3f,
                    0.5f,
                    0.7f,
                    1f
                };
                blend.Factors = new float[5]
                {
                    0.1f,
                    0.3f,
                    0.5f,
                    0.8f,
                    1f
                };
                if (flag4)
                {
                    color = _CheckedTabColor;
                }
                else if (flag3)
                {
                    color           = _HeightLightTabColor;
                    blend.Positions = new float[5]
                    {
                        0f,
                        0.3f,
                        0.6f,
                        0.8f,
                        1f
                    };
                    blend.Factors = new float[5]
                    {
                        0.2f,
                        0.4f,
                        0.6f,
                        0.5f,
                        0.4f
                    };
                }
                Rectangle rect = new Rectangle(tabRect.Left, tabRect.Bottom, tabRect.Width, 1);
                g.SetClip(rect, CombineMode.Exclude);
                CornerRadius cornerRadius = new CornerRadius(_TabCornerRadius, _TabCornerRadius, 0, 0);
                tabRect.X     += _TabMargin;
                tabRect.Width -= _TabMargin;
                tabRect.Y++;
                tabRect.Height--;
                RoundRectangle roundRect = new RoundRectangle(tabRect, cornerRadius);
                GDIHelper.InitializeGraphics(g);
                switch (_TabStyle)
                {
                case EnumTabStyle.AnglesWing:
                    cornerRadius   = new CornerRadius(_TabCornerRadius);
                    tabRect.X     += _TabCornerRadius;
                    tabRect.Width -= _TabCornerRadius * 2;
                    roundRect      = new RoundRectangle(tabRect, cornerRadius);
                    using (GraphicsPath path = roundRect.ToGraphicsAnglesWingPath())
                    {
                        using (LinearGradientBrush linearGradientBrush = new LinearGradientBrush(roundRect.Rect, color, _BackColor, LinearGradientMode.Vertical))
                        {
                            linearGradientBrush.Blend = blend;
                            g.FillPath(linearGradientBrush, path);
                        }
                    }
                    using (GraphicsPath path = roundRect.ToGraphicsAnglesWingPath())
                    {
                        using (Pen pen = new Pen(_BorderColor, 1f))
                        {
                            g.DrawPath(pen, path);
                        }
                    }
                    break;

                case EnumTabStyle.Default:
                    GDIHelper.FillPath(g, roundRect, color, _BackColor, blend);
                    GDIHelper.DrawPathBorder(g, roundRect, _BorderColor);
                    break;
                }
                g.ResetClip();
                if (base.Alignment == TabAlignment.Top)
                {
                    Image image     = null;
                    Size  imageSize = Size.Empty;
                    if (base.ImageList != null && tabPage.ImageIndex >= 0)
                    {
                        image     = base.ImageList.Images[tabPage.ImageIndex];
                        imageSize = image.Size;
                    }
                    GDIHelper.DrawImageAndString(g, tabRect, image, imageSize, tabPage.Text, _CaptionFont, _CaptionForceColor);
                }
                else
                {
                    bool hasImage = DrawTabImage(g, tabPage, tabRect);
                    DrawtabText(g, tabPage, tabRect, hasImage);
                }
            }
            if (flag)
            {
                g.ResetClip();
            }
            if (base.SelectedIndex > -1)
            {
                bool flag5 = true;
            }
        }
Beispiel #2
0
        private void DrawBorder(Graphics g)
        {
            if (base.SelectedIndex != -1)
            {
                Rectangle tabRect            = GetTabRect(base.SelectedIndex);
                Rectangle clientRectangle    = base.ClientRectangle;
                Point[]   array              = new Point[6];
                IntPtr    upDownButtonHandle = UpDownButtonHandle;
                if (upDownButtonHandle != IntPtr.Zero && Win32.IsWindowVisible(upDownButtonHandle))
                {
                    RECT lpRect = default(RECT);
                    Win32.GetWindowRect(upDownButtonHandle, ref lpRect);
                    Rectangle r = Rectangle.FromLTRB(lpRect.left, lpRect.top, lpRect.right, lpRect.bottom);
                    r             = RectangleToClient(r);
                    tabRect.X     = ((tabRect.X > r.X) ? r.X : tabRect.X);
                    tabRect.Width = ((tabRect.Right > r.X) ? (r.X - tabRect.X) : tabRect.Width);
                }
                int num = 0;
                if (_TabStyle == EnumTabStyle.AnglesWing)
                {
                    num = _TabCornerRadius / 2;
                }
                switch (base.Alignment)
                {
                case TabAlignment.Top:
                    array[0] = new Point(tabRect.X + _TabMargin + num, tabRect.Bottom);
                    array[1] = new Point(clientRectangle.X, tabRect.Bottom);
                    array[2] = new Point(clientRectangle.X, clientRectangle.Bottom - 1);
                    array[3] = new Point(clientRectangle.Right - 1, clientRectangle.Bottom - 1);
                    array[4] = new Point(clientRectangle.Right - 1, tabRect.Bottom);
                    array[5] = new Point(tabRect.Right - num, tabRect.Bottom);
                    break;

                case TabAlignment.Bottom:
                    array[0] = new Point(tabRect.X, tabRect.Y);
                    array[1] = new Point(clientRectangle.X, tabRect.Y);
                    array[2] = new Point(clientRectangle.X, clientRectangle.Y);
                    array[3] = new Point(clientRectangle.Right - 1, clientRectangle.Y);
                    array[4] = new Point(clientRectangle.Right - 1, tabRect.Y);
                    array[5] = new Point(tabRect.Right, tabRect.Y);
                    break;

                case TabAlignment.Left:
                    array[0] = new Point(tabRect.Right, tabRect.Y);
                    array[1] = new Point(tabRect.Right, clientRectangle.Y);
                    array[2] = new Point(clientRectangle.Right - 1, clientRectangle.Y);
                    array[3] = new Point(clientRectangle.Right - 1, clientRectangle.Bottom - 1);
                    array[4] = new Point(tabRect.Right, clientRectangle.Bottom - 1);
                    array[5] = new Point(tabRect.Right, tabRect.Bottom);
                    break;

                case TabAlignment.Right:
                    array[0] = new Point(tabRect.X, tabRect.Y);
                    array[1] = new Point(tabRect.X, clientRectangle.Y);
                    array[2] = new Point(clientRectangle.X, clientRectangle.Y);
                    array[3] = new Point(clientRectangle.X, clientRectangle.Bottom - 1);
                    array[4] = new Point(tabRect.X, clientRectangle.Bottom - 1);
                    array[5] = new Point(tabRect.X, tabRect.Bottom);
                    break;
                }
                using (Pen pen = new Pen(_BorderColor))
                {
                    g.DrawLines(pen, array);
                }
            }
        }
Beispiel #3
0
 private IntPtr FindUpDownButton()
 {
     return(Win32.FindWindowEx(base.Handle, IntPtr.Zero, "msctls_updown32", null));
 }