示例#1
0
        protected internal virtual void OnPaintScrollBarTrack(
            PaintScrollBarTrackEventArgs e)
        {
            System.Drawing.Graphics g = e.Graphics;
            Rectangle rect = e.TrackRectangle;

            Color baseColor = GetGray(ColorTable.Base);

            ControlPaintEx.DrawScrollBarTrack(
                g, rect, baseColor, Color.White, e.Orientation);
        }
示例#2
0
 void IScrollBarPaint.OnPaintScrollBarTrack(PaintScrollBarTrackEventArgs e)
 {
     OnPaintScrollBarTrack(e);
 }
        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 (System.Drawing.Graphics g = System.Drawing.Graphics.FromHdc(tempDc.Hdc))
                {
                    using (PaintScrollBarTrackEventArgs te =
                        new PaintScrollBarTrackEventArgs(
                        g,
                        trackRect,
                        direction,
                        bEnabled))
                    {
                        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();
            }
        }