/*
		 * DrawCheckBox
		 */

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

			Graphics g = paintParams.Graphics;
			Rectangle bounds = paintParams.Bounds;
			NuGenControlState currentState = paintParams.State;
			CheckState checkState = paintParams.CheckState;

			if (checkState == CheckState.Indeterminate && currentState != NuGenControlState.Disabled)
			{
				this.DrawBackground(g, bounds, NuGenControlState.Pressed);
			}
			else
			{
				this.DrawBackground(paintParams);
			}

			this.DrawBorder(g, bounds, currentState);

			if (checkState == CheckState.Checked)
			{
				this.DrawCheck(g, bounds, currentState);
			}
		}
Example #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)
		{
			Debug.Assert(this.ButtonStateTracker != null, "this.ButtonStateTracker != null");
			Debug.Assert(this.Renderer != null, "this.Renderer != null");
			Debug.Assert(this.StateTracker != null, "this.StateTracker != null");

			Graphics g = e.Graphics;
			Rectangle bounds = this.ClientRectangle;
			Rectangle checkBounds = Rectangle.Empty;
			ContentAlignment checkAlign = this.CheckAlign;
			
			NuGenCheckBoxPaintParams paintParams = new NuGenCheckBoxPaintParams(g);
			paintParams.Bounds = checkBounds = this.LayoutManager.GetCheckBoxBounds(
				new NuGenBoundsParams(
					bounds
					, checkAlign
					, new Rectangle(Point.Empty, this.LayoutManager.GetCheckSize())
					, this.RightToLeft
				)
			);
			paintParams.CheckState = this.CheckState;
			paintParams.State = this.ButtonStateTracker.GetControlState();

			checkBounds.Inflate(3, 3);

			this.Renderer.DrawCheckBox(paintParams);

			NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(paintParams);
			textPaintParams.Bounds = this.LayoutManager.GetTextBounds(
				new NuGenBoundsParams(
					bounds
					, checkAlign
					, checkBounds
					, this.RightToLeft
				)
			);
			textPaintParams.Font = this.Font;
			textPaintParams.ForeColor = this.ForeColor;
			textPaintParams.Text = this.Text;
			textPaintParams.TextAlign = NuGenControlPaint.RTLContentAlignment(this.TextAlign, this.RightToLeft);
			textPaintParams.State = this.StateTracker.GetControlState();

			this.Renderer.DrawText(textPaintParams);
		}