Exemple #1
0
        protected override void OnDrawColumnHeader(DrawListViewColumnHeaderEventArgs e)
        {
            base.OnDrawColumnHeader(e);
            Graphics graphics = e.Graphics;

            GDIHelper.InitializeGraphics(graphics);
            Rectangle bounds = e.Bounds;

            GDIHelper.FillPath(graphics, new RoundRectangle(bounds, 0), _HeaderBeginColor, _HeaderEndColor);
            bounds.Height--;
            if (BorderStyle != 0)
            {
                using (Pen pen = new Pen(BorderColor))
                {
                    graphics.DrawLine(pen, new Point(bounds.Right, bounds.Bottom), new Point(bounds.Right, bounds.Top));
                    graphics.DrawLine(pen, new Point(bounds.Left, bounds.Bottom), new Point(bounds.Right, bounds.Bottom));
                }
            }
            else
            {
                GDIHelper.DrawPathBorder(graphics, new RoundRectangle(bounds, 0), _BorderColor);
            }
            bounds.Height++;
            TextFormatFlags formatFlags = GetFormatFlags(e.Header.TextAlign);
            Rectangle       rectangle   = new Rectangle(bounds.X + 3, bounds.Y, bounds.Width - 6, bounds.Height);
            Image           image       = null;
            Size            imageSize   = new Size(16, 16);
            Rectangle       empty       = Rectangle.Empty;

            if (e.Header.ImageList != null)
            {
                image = ((e.Header.ImageIndex == -1) ? null : e.Header.ImageList.Images[e.Header.ImageIndex]);
            }
            GDIHelper.DrawImageAndString(graphics, bounds, image, imageSize, e.Header.Text, _Font, e.ForeColor);
        }
Exemple #2
0
        private void DrawContent(Graphics g)
        {
            GDIHelper.InitializeGraphics(g);
            int       width     = base.Width;
            int       height    = base.Height;
            Rectangle rectangle = new Rectangle(_Margin, height / 2 - _BoxSize.Height / 2, _BoxSize.Width, _BoxSize.Height);
            Size      size      = g.MeasureString(Text, Font).ToSize();
            Rectangle rect      = default(Rectangle);

            rect.X      = rectangle.Right + _Margin;
            rect.Y      = _Margin;
            rect.Height = base.Height - _Margin * 2;
            rect.Width  = size.Width;
            RoundRectangle   roundRect    = new RoundRectangle(rectangle, _CornerRadius);
            EnumControlState controlState = _ControlState;

            if (controlState == EnumControlState.HeightLight)
            {
                GDIHelper.DrawPathBorder(g, roundRect, SkinManager.CurrentSkin.OuterBorderColor);
                GDIHelper.DrawPathInnerBorder(g, roundRect, SkinManager.CurrentSkin.HeightLightControlColor.First);
            }
            else
            {
                GDIHelper.DrawCheckBox(g, roundRect);
            }
            Color forceColor = base.Enabled ? ForeColor : SkinManager.CurrentSkin.UselessColor;

            GDIHelper.DrawImageAndString(g, rect, null, Size.Empty, Text, Font, forceColor);
            switch (base.CheckState)
            {
            case CheckState.Checked:
                GDIHelper.DrawCheckedStateByImage(g, rectangle);
                break;

            case CheckState.Indeterminate:
            {
                Rectangle rect2 = rectangle;
                rect2.Inflate(-3, -3);
                Color color = Color.FromArgb(46, 117, 35);
                GDIHelper.FillRectangle(g, new RoundRectangle(rect2, _CornerRadius), color);
                break;
            }
            }
        }
Exemple #3
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;
            }
        }