/// <summary>
        /// </summary>
        /// <param name="paintParams"></param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="paintParams"/> is <see langword="null"/>.</para>
        /// </exception>
        public void DrawTrackButton(NuGenTrackButtonPaintParams paintParams)
        {
            if (paintParams == null)
            {
                throw new ArgumentNullException("paintParams");
            }

            Graphics          g         = paintParams.Graphics;
            Rectangle         bounds    = paintParams.Bounds;
            NuGenControlState state     = paintParams.State;
            TickStyle         tickStyle = paintParams.Style;

            Rectangle borderRectangle = NuGenControlPaint.BorderRectangle(bounds);

            using (NuGenGrfxMode mode = new NuGenGrfxMode(g))
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;

                using (GraphicsPath gp = NuGenSmoothTrackBarRenderer.GetGraphicsPath(borderRectangle, tickStyle))
                {
                    /* Background */

                    using (
                        Brush brush = this.GetBackgroundBrush(
                            borderRectangle,
                            state == NuGenControlState.Normal || state == NuGenControlState.Focused
                                                                        ? NuGenControlState.Hot
                                                                        : state
                            )
                        )
                    {
                        g.FillPath(brush, gp);
                    }

                    /* Body */

                    Rectangle bodyRectangle = Rectangle.Inflate(borderRectangle, 0, -3);

                    using (GraphicsPath bgp = NuGenSmoothTrackBarRenderer.GetBodyGraphicsPath(borderRectangle, tickStyle))
                        using (Brush brush = this.GetBackgroundBrush(bodyRectangle, state))
                        {
                            g.FillPath(brush, bgp);
                        }

                    /* Border */

                    using (Pen pen = this.GetBorderPen(state))
                    {
                        g.DrawPath(pen, gp);
                    }
                }
            }
        }
Пример #2
0
            /*
             * OnPaint
             */

            /// <summary>
            /// Raises the <see cref="E:System.Windows.Forms.Control.Paint"></see> event.
            /// </summary>
            /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"></see> that contains the event data.</param>
            protected override void OnPaint(PaintEventArgs e)
            {
                Graphics g = e.Graphics;

                if (this.Orientation == NuGenOrientationStyle.Vertical)
                {
                    NuGenControlPaint.Make90CCWGraphics(g, this.ClientRectangle);
                }

                NuGenTrackButtonPaintParams paintParams = new NuGenTrackButtonPaintParams(g);

                paintParams.Bounds = NuGenControlPaint.OrientationAgnosticRectangle(
                    this.ClientRectangle,
                    this.Orientation
                    );
                paintParams.State = this.ButtonStateTracker.GetControlState();
                paintParams.Style = this.TickStyle;

                this.Renderer.DrawTrackButton(paintParams);
            }