상속: System.EventArgs
예제 #1
0
        /// <summary>
        /// Fires the tick drawing events
        /// </summary>
        /// <param name="hdc">The device context that holds the graphics operations</param>
        protected virtual void OnDrawTicks(IntPtr hdc)
        {
            Graphics graphics = Graphics.FromHdc(hdc);

            if (((OwnerDrawParts & TrackBarOwnerDrawParts.Ticks) == TrackBarOwnerDrawParts.Ticks) && !DesignMode)
            {
                TrackBarDrawItemEventArgs e = new TrackBarDrawItemEventArgs(graphics, ClientRectangle, (TrackBarItemState)ThumbState);
                if (DrawTicks != null)
                {
                    DrawTicks(this, e);
                }
            }
            else
            {
                if (TickStyle == TickStyle.None)
                {
                    return;
                }
                if (ThumbBounds.Equals(Rectangle.Empty))
                {
                    return;
                }
                Color black = Color.Black;
                if (VisualStyleRenderer.IsSupported)
                {
                    VisualStyleRenderer vsr = new VisualStyleRenderer("TRACKBAR", (int)NativeMethods.TrackBarParts.TKP_TICS, ThumbState);
                    black = vsr.GetColor(ColorProperty.TextColor);
                }
                if (Orientation == Orientation.Horizontal)
                {
                    DrawHorizontalTicks(graphics, black);
                }
                else
                {
                    DrawVerticalTicks(graphics, black);
                }
            }
            graphics.Dispose();
        }
예제 #2
0
        /// <summary>
        /// Fires the DrawThumb events
        /// </summary>
        /// <param name="hdc">The device context for graphics operations</param>
        protected virtual void OnDrawThumb(IntPtr hdc)
        {
            Graphics graphics = Graphics.FromHdc(hdc);

            graphics.Clip = new Region(ThumbBounds);
            if (((OwnerDrawParts & TrackBarOwnerDrawParts.Thumb) == TrackBarOwnerDrawParts.Thumb) && !DesignMode)
            {
                TrackBarDrawItemEventArgs e = new TrackBarDrawItemEventArgs(graphics, ThumbBounds, (TrackBarItemState)ThumbState);
                if (DrawThumb != null)
                {
                    DrawThumb(this, e);
                }
            }
            else
            {
                // Determine the style of the thumb, based on the tickstyle
                NativeMethods.TrackBarParts part = NativeMethods.TrackBarParts.TKP_THUMB;
                if (ThumbBounds.Equals(Rectangle.Empty))
                {
                    return;
                }
                switch (TickStyle)
                {
                case TickStyle.None:
                case TickStyle.BottomRight:
                    part = (Orientation != Orientation.Horizontal) ? NativeMethods.TrackBarParts.TKP_THUMBRIGHT : NativeMethods.TrackBarParts.TKP_THUMBBOTTOM;
                    break;

                case TickStyle.TopLeft:
                    part = (Orientation != Orientation.Horizontal) ? NativeMethods.TrackBarParts.TKP_THUMBLEFT : NativeMethods.TrackBarParts.TKP_THUMBTOP;
                    break;

                case TickStyle.Both:
                    part = (Orientation != Orientation.Horizontal) ? NativeMethods.TrackBarParts.TKP_THUMBVERT : NativeMethods.TrackBarParts.TKP_THUMB;
                    break;
                }
                // Perform drawing
                if (VisualStyleRenderer.IsSupported)
                {
                    VisualStyleRenderer vsr = new VisualStyleRenderer("TRACKBAR", (int)part, ThumbState);
                    vsr.DrawBackground(graphics, ThumbBounds);
                    graphics.ResetClip();
                    graphics.Dispose();
                    return;
                }
                switch (part)
                {
                case NativeMethods.TrackBarParts.TKP_THUMBBOTTOM:
                    DrawPointerDown(graphics);
                    break;

                case NativeMethods.TrackBarParts.TKP_THUMBTOP:
                    DrawPointerUp(graphics);

                    break;

                case NativeMethods.TrackBarParts.TKP_THUMBLEFT:
                    DrawPointerLeft(graphics);

                    break;

                case NativeMethods.TrackBarParts.TKP_THUMBRIGHT:
                    DrawPointerRight(graphics);

                    break;

                default:
                    if ((ThumbState == 3) || !Enabled)
                    {
                        ControlPaint.DrawButton(graphics, ThumbBounds, ButtonState.All);
                    }
                    else
                    {
                        // Tick-style is both - draw the thumb as a solid rectangle
                        graphics.FillRectangle(SystemBrushes.Control, ThumbBounds);
                    }
                    ControlPaint.DrawBorder3D(graphics, ThumbBounds, Border3DStyle.Raised);
                    break;
                }
            }
            graphics.ResetClip();
            graphics.Dispose();
        }
예제 #3
0
 /// <summary>
 /// Fires the tick drawing events
 /// </summary>
 /// <param name="hdc">The device context that holds the graphics operations</param>
 protected virtual void OnDrawTicks(IntPtr hdc)
 {
     Graphics graphics = Graphics.FromHdc(hdc);
     if (((OwnerDrawParts & TrackBarOwnerDrawParts.Ticks) == TrackBarOwnerDrawParts.Ticks) && !DesignMode)
     {
         TrackBarDrawItemEventArgs e = new TrackBarDrawItemEventArgs(graphics, ClientRectangle, (TrackBarItemState) ThumbState);
         if (DrawTicks != null)
         {
             DrawTicks(this, e);
         }
     }
     else
     {
         if (TickStyle == TickStyle.None)
         {
             return;
         }
         if (ThumbBounds.Equals(Rectangle.Empty))
         {
             return;
         }
         Color black = Color.Black;
         if (VisualStyleRenderer.IsSupported)
         {
             VisualStyleRenderer vsr = new VisualStyleRenderer("TRACKBAR", (int) NativeMethods.TrackBarParts.TKP_TICS, ThumbState);
             black = vsr.GetColor(ColorProperty.TextColor);
         }
         if (Orientation == Orientation.Horizontal)
         {
             DrawHorizontalTicks(graphics, black);
         }
         else
         {
             DrawVerticalTicks(graphics, black);
         }
     }
     graphics.Dispose();
 }
예제 #4
0
 /// <summary>
 /// Fires the DrawChannel events
 /// </summary>
 /// <param name="hdc">The device context for graphics operations</param>
 protected virtual void OnDrawChannel(IntPtr hdc)
 {
     Graphics graphics = Graphics.FromHdc(hdc);
     if (((OwnerDrawParts & TrackBarOwnerDrawParts.Channel) == TrackBarOwnerDrawParts.Channel) && !DesignMode)
     {
         TrackBarDrawItemEventArgs e = new TrackBarDrawItemEventArgs(graphics, ChannelBounds, (TrackBarItemState) ThumbState);
         if (DrawChannel != null)
         {
             DrawChannel(this, e);
         }
     }
     else
     {
         if (ChannelBounds.Equals(Rectangle.Empty))
         {
             return;
         }
         if (VisualStyleRenderer.IsSupported)
         {
             VisualStyleRenderer vsr = new VisualStyleRenderer("TRACKBAR", (int) NativeMethods.TrackBarParts.TKP_TRACK, (int) TrackBarItemState.Normal);
             vsr.DrawBackground(graphics, ChannelBounds);
             graphics.ResetClip();
             graphics.Dispose();
             return;
         }
         ControlPaint.DrawBorder3D(graphics, ChannelBounds, Border3DStyle.Sunken);
     }
     graphics.Dispose();
 }
예제 #5
0
        /// <summary>
        /// Fires the DrawThumb events
        /// </summary>
        /// <param name="hdc">The device context for graphics operations</param>
        protected virtual void OnDrawThumb(IntPtr hdc)
        {
            Graphics graphics = Graphics.FromHdc(hdc);
            graphics.Clip = new Region(ThumbBounds);
            if (((OwnerDrawParts & TrackBarOwnerDrawParts.Thumb) == TrackBarOwnerDrawParts.Thumb) && !DesignMode)
            {
                TrackBarDrawItemEventArgs e = new TrackBarDrawItemEventArgs(graphics, ThumbBounds, (TrackBarItemState) ThumbState);
                if (DrawThumb != null)
                {
                    DrawThumb(this, e);
                }
            }
            else
            {
                // Determine the style of the thumb, based on the tickstyle
                NativeMethods.TrackBarParts part = NativeMethods.TrackBarParts.TKP_THUMB;
                if (ThumbBounds.Equals(Rectangle.Empty))
                {
                    return;
                }
                switch (TickStyle)
                {
                    case TickStyle.None:
                    case TickStyle.BottomRight:
                        part = (Orientation != Orientation.Horizontal) ? NativeMethods.TrackBarParts.TKP_THUMBRIGHT : NativeMethods.TrackBarParts.TKP_THUMBBOTTOM;
                        break;
                    case TickStyle.TopLeft:
                        part = (Orientation != Orientation.Horizontal) ? NativeMethods.TrackBarParts.TKP_THUMBLEFT : NativeMethods.TrackBarParts.TKP_THUMBTOP;
                        break;

                    case TickStyle.Both:
                        part = (Orientation != Orientation.Horizontal) ? NativeMethods.TrackBarParts.TKP_THUMBVERT : NativeMethods.TrackBarParts.TKP_THUMB;
                        break;
                }
                // Perform drawing
                if (VisualStyleRenderer.IsSupported)
                {
                    VisualStyleRenderer vsr = new VisualStyleRenderer("TRACKBAR", (int) part, ThumbState);
                    vsr.DrawBackground(graphics, ThumbBounds);
                    graphics.ResetClip();
                    graphics.Dispose();
                    return;
                }
                switch (part)
                {
                    case NativeMethods.TrackBarParts.TKP_THUMBBOTTOM:
                        DrawPointerDown(graphics);
                        break;
                    case NativeMethods.TrackBarParts.TKP_THUMBTOP:
                        DrawPointerUp(graphics);

                        break;
                    case NativeMethods.TrackBarParts.TKP_THUMBLEFT:
                        DrawPointerLeft(graphics);

                        break;
                    case NativeMethods.TrackBarParts.TKP_THUMBRIGHT:
                        DrawPointerRight(graphics);

                        break;
                    default:
                        if ((ThumbState == 3) || !Enabled)
                        {
                            ControlPaint.DrawButton(graphics, ThumbBounds, ButtonState.All);
                        }
                        else
                        {
                            // Tick-style is both - draw the thumb as a solid rectangle
                            graphics.FillRectangle(SystemBrushes.Control, ThumbBounds);
                        }
                        ControlPaint.DrawBorder3D(graphics, ThumbBounds, Border3DStyle.Raised);
                        break;
                }
            }
            graphics.ResetClip();
            graphics.Dispose();
        }