Exemplo n.º 1
0
        protected virtual void OnDrawTicks(IntPtr hdc)
        {
            Graphics graphics = Graphics.FromHdc(hdc);

            if (((this.OwnerDrawParts & TrackBarOwnerDrawParts.Ticks) == TrackBarOwnerDrawParts.Ticks) && !this.DesignMode)
            {
                Rectangle bounds;
                Rectangle rectangle2;
                if (this.Orientation == Orientation.Horizontal)
                {
                    rectangle2 = new Rectangle(this.ChannelBounds.Left + (this.ThumbBounds.Width / 2), this.ThumbBounds.Top - 6, this.ChannelBounds.Width - this.ThumbBounds.Width, this.ThumbBounds.Height + 10);
                    bounds     = rectangle2;
                }
                else
                {
                    rectangle2 = new Rectangle(this.ThumbBounds.Left - (this.ThumbBounds.Height / 2), this.ChannelBounds.Top + 6, this.ThumbBounds.Width + 10, this.ChannelBounds.Height - this.ThumbBounds.Height);
                    bounds     = rectangle2;
                }
                TrackBarDrawItemEventArgs e = new TrackBarDrawItemEventArgs(graphics, bounds, (TrackBarItemState)this.ThumbState);
                if (this.DrawTicks != null)
                {
                    this.DrawTicks(this, e);
                }
            }
            else
            {
                if (this.TickStyle == TickStyle.None)
                {
                    return;
                }
                if (this.ThumbBounds.Equals(Rectangle.Empty))
                {
                    return;
                }
                Color black = Color.Black;
                if (VisualStylesEnabled)
                {
                    IntPtr hTheme = NativeMethods.OpenThemeData(this.Handle, "TRACKBAR");
                    if (!hTheme.Equals(IntPtr.Zero))
                    {
                        int pColor = 0;
                        if (NativeMethods.GetThemeColor(hTheme, 9, this.ThumbState, 0xcc, ref pColor) == 0)
                        {
                            black = ColorTranslator.FromWin32(pColor);
                        }
                        NativeMethods.CloseThemeData(hTheme);
                    }
                }
                if (this.Orientation == Orientation.Horizontal)
                {
                    this.DrawHorizontalTicks(graphics, black);
                }
                else
                {
                    this.DrawVerticalTicks(graphics, black);
                }
            }
            graphics.Dispose();
        }
Exemplo n.º 2
0
        protected virtual void OnDrawChannel(IntPtr hdc)
        {
            Graphics graphics = Graphics.FromHdc(hdc);

            if (((this.OwnerDrawParts & TrackBarOwnerDrawParts.Channel) == TrackBarOwnerDrawParts.Channel) && !this.DesignMode)
            {
                TrackBarDrawItemEventArgs e = new TrackBarDrawItemEventArgs(graphics, this.ChannelBounds, (TrackBarItemState)this.ThumbState);
                if (this.DrawChannel != null)
                {
                    this.DrawChannel(this, e);
                }
            }
            else
            {
                if (this.ChannelBounds.Equals(Rectangle.Empty))
                {
                    return;
                }
                if (VisualStylesEnabled)
                {
                    IntPtr hTheme = NativeMethods.OpenThemeData(this.Handle, "TRACKBAR");
                    if (!hTheme.Equals(IntPtr.Zero))
                    {
                        NativeMethods.RECT pRect = new NativeMethods.RECT(this.ChannelBounds);
                        bool flag = NativeMethods.DrawThemeBackground(hTheme, hdc, 1, 1, ref pRect, ref pRect) == 0;
                        NativeMethods.CloseThemeData(hTheme);
                        if (flag)
                        {
                            return;
                        }
                    }
                }
                ControlPaint.DrawBorder3D(graphics, this.ChannelBounds, Border3DStyle.Sunken);
            }
            graphics.Dispose();
        }
Exemplo n.º 3
0
        protected virtual void OnDrawThumb(IntPtr hdc)
        {
            Graphics graphics = Graphics.FromHdc(hdc);

            graphics.Clip = new Region(this.ThumbBounds);
            if (((this.OwnerDrawParts & TrackBarOwnerDrawParts.Thumb) == TrackBarOwnerDrawParts.Thumb) && !this.DesignMode)
            {
                TrackBarDrawItemEventArgs e = new TrackBarDrawItemEventArgs(graphics, this.ThumbBounds, (TrackBarItemState)this.ThumbState);
                if (this.DrawThumb != null)
                {
                    this.DrawThumb(this, e);
                }
            }
            else
            {
                int iPartId = 0;
                if (this.ThumbBounds.Equals(Rectangle.Empty))
                {
                    return;
                }
                switch (this.TickStyle)
                {
                case TickStyle.None:
                case TickStyle.BottomRight:
                    if (this.Orientation != Orientation.Horizontal)
                    {
                        iPartId = 8;
                        break;
                    }
                    iPartId = 4;
                    break;

                case TickStyle.TopLeft:
                    if (this.Orientation != Orientation.Horizontal)
                    {
                        iPartId = 7;
                        break;
                    }
                    iPartId = 5;
                    break;

                case TickStyle.Both:
                    if (this.Orientation != Orientation.Horizontal)
                    {
                        iPartId = 6;
                        break;
                    }
                    iPartId = 3;
                    break;
                }
                if (VisualStylesEnabled)
                {
                    IntPtr hTheme = NativeMethods.OpenThemeData(this.Handle, "TRACKBAR");
                    if (!hTheme.Equals(IntPtr.Zero))
                    {
                        NativeMethods.RECT pRect = new NativeMethods.RECT(this.ThumbBounds);
                        bool flag = NativeMethods.DrawThemeBackground(hTheme, hdc, iPartId, this.ThumbState, ref pRect, ref pRect) == 0;
                        NativeMethods.CloseThemeData(hTheme);
                        if (flag)
                        {
                            graphics.ResetClip();
                            graphics.Dispose();
                            return;
                        }
                    }
                }
                switch (iPartId)
                {
                case 4:
                    this.DrawPointerDown(graphics);
                    goto Label_01AD;

                case 5:
                    this.DrawPointerUp(graphics);
                    goto Label_01AD;

                case 7:
                    this.DrawPointerLeft(graphics);
                    goto Label_01AD;

                case 8:
                    this.DrawPointerRight(graphics);
                    goto Label_01AD;
                }
                if ((this.ThumbState == 3) || !this.Enabled)
                {
                    ControlPaint.DrawButton(graphics, this.ThumbBounds, ButtonState.All);
                }
                else
                {
                    graphics.FillRectangle(SystemBrushes.Control, this.ThumbBounds);
                }
                ControlPaint.DrawBorder3D(graphics, this.ThumbBounds, Border3DStyle.Raised);
            }
Label_01AD:
            graphics.ResetClip();
            graphics.Dispose();
        }