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

            Graphics           g            = paintParams.Graphics;
            Rectangle          bounds       = paintParams.Bounds;
            NuGenControlState  state        = paintParams.State;
            TickStyle          tickStyle    = paintParams.TickStyle;
            INuGenValueTracker valueTracker = paintParams.ValueTracker;

            /* Track */

            Rectangle valueRect = new Rectangle(
                bounds.Left,
                bounds.Top,
                (int)(NuGenSmoothTrackBarRenderer.GetStep(bounds, valueTracker) * (valueTracker.Value - valueTracker.Minimum)),
                bounds.Height
                );

            if (
                valueRect.Width > 0 &&
                valueRect.Height > 0
                )
            {
                this.DrawBackground(
                    g,
                    valueRect,
                    state == NuGenControlState.Normal || state == NuGenControlState.Focused ? NuGenControlState.Hot : state
                    );
            }

            this.DrawBorder(g, bounds, state);

            /* TickLines */

            if ((tickStyle & TickStyle.BottomRight) > 0)
            {
                this.DrawTickLines(
                    g,
                    NuGenSmoothTrackBarRenderer.GetTickLinesBounds(bounds, TickStyle.BottomRight),
                    state,
                    TickStyle.BottomRight,
                    valueTracker
                    );
            }

            if ((tickStyle & TickStyle.TopLeft) > 0)
            {
                this.DrawTickLines(
                    g,
                    NuGenSmoothTrackBarRenderer.GetTickLinesBounds(bounds, TickStyle.TopLeft),
                    state,
                    TickStyle.TopLeft,
                    valueTracker
                    );
            }
        }
        /*
         * GetStep
         */

        private static float GetStep(Rectangle bounds, INuGenValueTracker valueTracker)
        {
            Debug.Assert(valueTracker != null, "valueTracker != null");

            float interval = valueTracker.Maximum - valueTracker.Minimum;

            return((float)bounds.Width / interval);
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="NuGenTrackBarPaintParams"/> class.
		/// </summary>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="g"/> is <see langword="null"/>.</para>
		/// -or-
		/// <para><paramref name="valueTracker"/> is <see langword="null"/>.</para>
		/// </exception>
		public NuGenTrackBarPaintParams(Graphics g, INuGenValueTracker valueTracker)
			: base(g)
		{
			if (valueTracker == null)
			{
				throw new ArgumentNullException("valueTracker");
			}

			_valueTracker = valueTracker;
		}
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NuGenTrackBarPaintParams"/> class.
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="g"/> is <see langword="null"/>.</para>
        /// -or-
        /// <para><paramref name="valueTracker"/> is <see langword="null"/>.</para>
        /// </exception>
        public NuGenTrackBarPaintParams(Graphics g, INuGenValueTracker valueTracker)
            : base(g)
        {
            if (valueTracker == null)
            {
                throw new ArgumentNullException("valueTracker");
            }

            _valueTracker = valueTracker;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="NuGenTrackBarPaintParams"/> class.
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="sender"/> is <see langword="null"/>.</para>
        /// -or-
        /// <para><paramref name="g"/> is <see langword="null"/>.</para>
        /// -or-
        /// <para><paramref name="valueTracker"/> is <see langword="null"/>.</para>
        /// </exception>
        public NuGenTrackBarPaintParams(
            object sender,
            Graphics g,
            Rectangle bounds,
            NuGenControlState state,
            INuGenValueTracker valueTracker,
            TickStyle tickStyle
            )
            : base(sender, g, bounds, state)
        {
            if (valueTracker == null)
            {
                throw new ArgumentNullException("valueTracker");
            }

            _valueTracker = valueTracker;
            _tickStyle    = tickStyle;
        }
        /*
         * DrawTickLines
         */

        private void DrawTickLines(
            Graphics g,
            Rectangle bounds,
            NuGenControlState state,
            TickStyle tickStyle,
            INuGenValueTracker valueTracker
            )
        {
            Debug.Assert(g != null, "g != null");
            Debug.Assert(valueTracker != null, "valueTracker != null");

            float step          = NuGenSmoothTrackBarRenderer.GetStep(bounds, valueTracker) * valueTracker.SmallChange;
            float currentOffset = bounds.Left;

            this.DrawLargeTickLine(g, bounds, state, currentOffset, tickStyle);

            while ((currentOffset += step) < bounds.Right)
            {
                this.DrawSmallTickLine(g, bounds, state, currentOffset, tickStyle);
            }

            this.DrawLargeTickLine(g, bounds, state, bounds.Right, tickStyle);
        }
		/*
		 * DrawTickLines
		 */

		private void DrawTickLines(
			Graphics g,
			Rectangle bounds,
			NuGenControlState state,
			TickStyle tickStyle,
			INuGenValueTracker valueTracker
			)
		{
			Debug.Assert(g != null, "g != null");
			Debug.Assert(valueTracker != null, "valueTracker != null");

			float step = NuGenSmoothTrackBarRenderer.GetStep(bounds, valueTracker) * valueTracker.SmallChange;
			float currentOffset = bounds.Left;

			this.DrawLargeTickLine(g, bounds, state, currentOffset, tickStyle);

			while ((currentOffset += step) < bounds.Right)
			{
				this.DrawSmallTickLine(g, bounds, state, currentOffset, tickStyle);
			}

			this.DrawLargeTickLine(g, bounds, state, bounds.Right, tickStyle);
		}
		/*
		 * GetStep
		 */

		private static float GetStep(Rectangle bounds, INuGenValueTracker valueTracker)
		{
			Debug.Assert(valueTracker != null, "valueTracker != null");

			float interval = valueTracker.Maximum - valueTracker.Minimum;
			return (float)bounds.Width / interval;
		}