コード例 #1
0
ファイル: SkinVScrollBar.cs プロジェクト: jollitycn/JGNet
        internal protected virtual void OnPaintScrollBarArrow(
            PaintScrollBarArrowEventArgs e)
        {
            Graphics       g            = e.Graphics;
            Rectangle      rect         = e.ArrowRectangle;
            ControlState   controlState = e.ControlState;
            ArrowDirection direction    = e.ArrowDirection;
            bool           bHorizontal  = e.Orientation == Orientation.Horizontal;
            bool           bEnabled     = e.Enabled;

            Color backColor        = BackNormal;
            Color baseColor        = Base;
            Color borderColor      = Border;
            Color innerBorderColor = InnerBorder;
            Color foreColor        = Fore;

            bool changeColor = false;

            if (bEnabled)
            {
                switch (controlState)
                {
                case ControlState.Hover:
                    baseColor = BackHover;
                    break;

                case ControlState.Pressed:
                    baseColor   = BackPressed;
                    changeColor = true;
                    break;

                default:
                    baseColor = Base;
                    break;
                }
            }
            else
            {
                backColor   = GetGray(backColor);
                baseColor   = GetGray(Base);
                borderColor = GetGray(borderColor);
                foreColor   = GetGray(foreColor);
            }

            using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
            {
                ControlPaintEx.DrawScrollBarArraw(
                    g,
                    rect,
                    baseColor,
                    backColor,
                    borderColor,
                    innerBorderColor,
                    foreColor,
                    e.Orientation,
                    direction,
                    changeColor);
            }
        }
コード例 #2
0
ファイル: SkinVScrollBar.cs プロジェクト: jollitycn/JGNet
        internal protected virtual void OnPaintScrollBarTrack(
            PaintScrollBarTrackEventArgs e)
        {
            Graphics  g    = e.Graphics;
            Rectangle rect = e.TrackRectangle;

            Color baseColor = GetGray(Base);

            ControlPaintEx.DrawScrollBarTrack(
                g, rect, baseColor, Color.White, e.Orientation);
        }
コード例 #3
0
ファイル: SkinVScrollBar.cs プロジェクト: jollitycn/JGNet
        internal protected virtual void OnPaintScrollBarThumb(
            PaintScrollBarThumbEventArgs e)
        {
            bool bEnabled = e.Enabled;

            if (!bEnabled)
            {
                return;
            }

            Graphics     g            = e.Graphics;
            Rectangle    rect         = e.ThumbRectangle;
            ControlState controlState = e.ControlState;

            Color backColor        = BackNormal;
            Color baseColor        = Base;
            Color borderColor      = Border;
            Color innerBorderColor = InnerBorder;

            bool changeColor = false;

            switch (controlState)
            {
            case ControlState.Hover:
                baseColor = BackHover;
                break;

            case ControlState.Pressed:
                baseColor   = BackPressed;
                changeColor = true;
                break;

            default:
                baseColor = Base;
                break;
            }

            using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g))
            {
                ControlPaintEx.DrawScrollBarThumb(
                    g,
                    rect,
                    baseColor,
                    backColor,
                    borderColor,
                    innerBorderColor,
                    e.Orientation,
                    changeColor);
            }
        }
コード例 #4
0
ファイル: SBManger.cs プロジェクト: jollitycn/JGNet
        private void DrawScrollBar(
            IntPtr maskHWnd,
            Rectangle bounds,
            Rectangle trackRect,
            Rectangle topLeftArrowRect,
            Rectangle bottomRightArrowRect,
            Rectangle thumbRect,
            ControlState topLeftArrowState,
            ControlState bottomRightArrowState,
            ControlState thumbState,
            Orientation direction)
        {
            bool            bHorizontal = direction == Orientation.Horizontal;
            ArrowDirection  arrowDirection;
            bool            bEnabled = _owner.Enabled;
            IScrollBarPaint paint    = _owner as IScrollBarPaint;

            if (paint == null)
            {
                return;
            }

            ImageDc tempDc = new ImageDc(bounds.Width, bounds.Height);
            IntPtr  hdc    = NativeMethods.GetDC(maskHWnd);

            try
            {
                using (Graphics g = Graphics.FromHdc(tempDc.Hdc))
                {
                    using (PaintScrollBarTrackEventArgs te =
                               new PaintScrollBarTrackEventArgs(
                                   g,
                                   trackRect,
                                   direction,
                                   bEnabled))
                    {
                        Graphics  ge   = te.Graphics;
                        Rectangle rect = te.TrackRectangle;

                        Color baseColor = GetGray(Color.Blue);

                        ControlPaintEx.DrawScrollBarTrack(
                            ge, rect, baseColor, Color.White, te.Orientation);
                        //paint.OnPaintScrollBarTrack(te);
                    }

                    arrowDirection = bHorizontal ?
                                     ArrowDirection.Left : ArrowDirection.Up;

                    using (PaintScrollBarArrowEventArgs te =
                               new PaintScrollBarArrowEventArgs(
                                   g,
                                   topLeftArrowRect,
                                   topLeftArrowState,
                                   arrowDirection,
                                   direction,
                                   bEnabled))
                    {
                        paint.OnPaintScrollBarArrow(te);
                    }

                    arrowDirection = bHorizontal ?
                                     ArrowDirection.Right : ArrowDirection.Down;

                    using (PaintScrollBarArrowEventArgs te =
                               new PaintScrollBarArrowEventArgs(
                                   g,
                                   bottomRightArrowRect,
                                   bottomRightArrowState,
                                   arrowDirection,
                                   direction,
                                   bEnabled))
                    {
                        paint.OnPaintScrollBarArrow(te);
                    }

                    using (PaintScrollBarThumbEventArgs te =
                               new PaintScrollBarThumbEventArgs(
                                   g,
                                   thumbRect,
                                   thumbState,
                                   direction,
                                   bEnabled))
                    {
                        paint.OnPaintScrollBarThumb(te);
                    }
                }

                NativeMethods.BitBlt(
                    hdc,
                    0,
                    0,
                    bounds.Width,
                    bounds.Height,
                    tempDc.Hdc,
                    0,
                    0,
                    TernaryRasterOperations.SRCCOPY);
            }
            finally
            {
                NativeMethods.ReleaseDC(maskHWnd, hdc);
                tempDc.Dispose();
            }
        }
コード例 #5
0
        internal static void RenderBackgroundInternal(
            Graphics g,
            Rectangle rect,
            Color baseColor,
            Color borderColor,
            Color innerBorderColor,
            RoundStyle style,
            int roundWidth,
            float basePosition,
            bool drawBorder,
            bool drawGlass,
            LinearGradientMode mode)
        {
            if (drawBorder)
            {
                rect.Width--;
                rect.Height--;
            }

            using (LinearGradientBrush brush = new LinearGradientBrush(
                       rect, Color.Transparent, Color.Transparent, mode))
            {
                Color[] colors = new Color[4];
                colors[0] = GetColor(baseColor, 0, 35, 24, 9);
                colors[1] = GetColor(baseColor, 0, 13, 8, 3);
                colors[2] = baseColor;
                colors[3] = GetColor(baseColor, 0, 35, 24, 9);

                ColorBlend blend = new ColorBlend();
                blend.Positions           = new float[] { 0.0f, basePosition, basePosition + 0.05f, 1.0f };
                blend.Colors              = colors;
                brush.InterpolationColors = blend;
                if (style != RoundStyle.None)
                {
                    using (GraphicsPath path =
                               GraphicsPathHelper.CreatePath(rect, roundWidth, style, false))
                    {
                        g.FillPath(brush, path);
                    }

                    if (baseColor.A > 80)
                    {
                        Rectangle rectTop = rect;

                        if (mode == LinearGradientMode.Vertical)
                        {
                            rectTop.Height = (int)(rectTop.Height * basePosition);
                        }
                        else
                        {
                            rectTop.Width = (int)(rect.Width * basePosition);
                        }
                        using (GraphicsPath pathTop = GraphicsPathHelper.CreatePath(
                                   rectTop, roundWidth, RoundStyle.Top, false))
                        {
                            using (SolidBrush brushAlpha =
                                       new SolidBrush(Color.FromArgb(128, 255, 255, 255)))
                            {
                                g.FillPath(brushAlpha, pathTop);
                            }
                        }
                    }

                    if (drawGlass)
                    {
                        RectangleF glassRect = rect;
                        if (mode == LinearGradientMode.Vertical)
                        {
                            glassRect.Y      = rect.Y + rect.Height * basePosition;
                            glassRect.Height = (rect.Height - rect.Height * basePosition) * 2;
                        }
                        else
                        {
                            glassRect.X     = rect.X + rect.Width * basePosition;
                            glassRect.Width = (rect.Width - rect.Width * basePosition) * 2;
                        }
                        ControlPaintEx.DrawGlass(g, glassRect, 170, 0);
                    }

                    if (drawBorder)
                    {
                        using (GraphicsPath path =
                                   GraphicsPathHelper.CreatePath(rect, roundWidth, style, false))
                        {
                            using (Pen pen = new Pen(borderColor))
                            {
                                g.DrawPath(pen, path);
                            }
                        }

                        rect.Inflate(-1, -1);
                        using (GraphicsPath path =
                                   GraphicsPathHelper.CreatePath(rect, roundWidth, style, false))
                        {
                            using (Pen pen = new Pen(innerBorderColor))
                            {
                                g.DrawPath(pen, path);
                            }
                        }
                    }
                }
                else
                {
                    g.FillRectangle(brush, rect);
                    if (baseColor.A > 80)
                    {
                        Rectangle rectTop = rect;
                        if (mode == LinearGradientMode.Vertical)
                        {
                            rectTop.Height = (int)(rectTop.Height * basePosition);
                        }
                        else
                        {
                            rectTop.Width = (int)(rect.Width * basePosition);
                        }
                        using (SolidBrush brushAlpha =
                                   new SolidBrush(Color.FromArgb(128, 255, 255, 255)))
                        {
                            g.FillRectangle(brushAlpha, rectTop);
                        }
                    }

                    if (drawGlass)
                    {
                        RectangleF glassRect = rect;
                        if (mode == LinearGradientMode.Vertical)
                        {
                            glassRect.Y      = rect.Y + rect.Height * basePosition;
                            glassRect.Height = (rect.Height - rect.Height * basePosition) * 2;
                        }
                        else
                        {
                            glassRect.X     = rect.X + rect.Width * basePosition;
                            glassRect.Width = (rect.Width - rect.Width * basePosition) * 2;
                        }
                        ControlPaintEx.DrawGlass(g, glassRect, 200, 0);
                    }

                    if (drawBorder)
                    {
                        using (Pen pen = new Pen(borderColor))
                        {
                            g.DrawRectangle(pen, rect);
                        }

                        rect.Inflate(-1, -1);
                        using (Pen pen = new Pen(innerBorderColor))
                        {
                            g.DrawRectangle(pen, rect);
                        }
                    }
                }
            }
        }
コード例 #6
0
        internal static void RenderBackgroundInternal3(
            Graphics g,
            Rectangle rect,
            Color baseColor,
            Color borderColor,
            Color innerBorderColor,
            RoundStyle style,
            int roundWidth,
            float basePosition,
            bool drawBorder,
            bool drawGlass,
            LinearGradientMode mode)
        {
            if (drawBorder)
            {
                rect.Width--;
                rect.Height--;
            }
            if (rect.Width < 1 || rect.Height < 1)
            {
                return;
            }
            using (LinearGradientBrush brush = new LinearGradientBrush(
                       rect, Color.Transparent, Color.Transparent, mode))
            {
                FillBrush(brush, baseColor, borderColor, basePosition, drawGlass);
                if (style != RoundStyle.None)
                {
                    using (GraphicsPath path =
                               GraphicsPathHelper.CreatePath(rect, roundWidth, style, false))
                    {
                        g.FillPath(brush, path);
                    }

                    if (drawGlass)
                    {
                        RectangleF glassRect = rect;
                        if (mode == LinearGradientMode.Vertical)
                        {
                            glassRect.Y      = rect.Y + rect.Height * basePosition;
                            glassRect.Height = (rect.Height - rect.Height * basePosition) * 2;
                        }
                        else
                        {
                            glassRect.X     = rect.X + rect.Width * basePosition;
                            glassRect.Width = (rect.Width - rect.Width * basePosition) * 2;
                        }
                        ControlPaintEx.DrawGlass(g, glassRect, 170, 0);

                        if (baseColor.A > 0)
                        {
                            Rectangle rectTop = rect;

                            if (mode == LinearGradientMode.Vertical)
                            {
                                rectTop.Height = (int)(rectTop.Height * basePosition);
                            }
                            else
                            {
                                rectTop.Width = (int)(rect.Width * basePosition);
                            }
                            using (GraphicsPath pathTop = GraphicsPathHelper.CreatePath(
                                       rectTop, roundWidth, RoundStyle.Top, false))
                            {
                                using (SolidBrush brushAlpha =
                                           new SolidBrush(Color.FromArgb(128, 255, 255, 255)))
                                {
                                    g.FillPath(brushAlpha, pathTop);
                                }
                            }
                        }
                    }

                    if (drawBorder)
                    {
                        using (GraphicsPath path =
                                   GraphicsPathHelper.CreatePath(rect, roundWidth, style, false))
                        {
                            using (Pen pen = new Pen(borderColor))
                            {
                                g.DrawPath(pen, path);
                            }
                        }

                        rect.Inflate(-1, -1);
                        using (GraphicsPath path =
                                   GraphicsPathHelper.CreatePath(rect, roundWidth, style, false))
                        {
                            using (Pen pen = new Pen(innerBorderColor))
                            {
                                g.DrawPath(pen, path);
                            }
                        }
                    }
                }
                else
                {
                    g.FillRectangle(brush, rect);
                    if (drawGlass)
                    {
                        RectangleF glassRect = rect;
                        if (mode == LinearGradientMode.Vertical)
                        {
                            glassRect.Y      = rect.Y + rect.Height * basePosition;
                            glassRect.Height = (rect.Height - rect.Height * basePosition) * 2;
                        }
                        else
                        {
                            glassRect.X     = rect.X + rect.Width * basePosition;
                            glassRect.Width = (rect.Width - rect.Width * basePosition) * 2;
                        }
                        ControlPaintEx.DrawGlass(g, glassRect, 200, 0);

                        if (baseColor.A > 80)
                        {
                            Rectangle rectTop = rect;
                            if (mode == LinearGradientMode.Vertical)
                            {
                                rectTop.Height = (int)(rectTop.Height * basePosition);
                            }
                            else
                            {
                                rectTop.Width = (int)(rect.Width * basePosition);
                            }
                            using (SolidBrush brushAlpha =
                                       new SolidBrush(Color.FromArgb(128, 255, 255, 255)))
                            {
                                g.FillRectangle(brushAlpha, rectTop);
                            }
                        }
                    }

                    if (drawBorder)
                    {
                        using (Pen pen = new Pen(borderColor))
                        {
                            g.DrawRectangle(pen, rect);
                        }

                        rect.Inflate(-1, -1);
                        using (Pen pen = new Pen(innerBorderColor))
                        {
                            g.DrawRectangle(pen, rect);
                        }
                    }
                }
            }
        }