Ejemplo n.º 1
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;

            this.Renderer.DrawCheckBox(
                new NuGenPaintParams(
                    this,
                    g,
                    this.CheckBoxBounds,
                    this.ButtonStateTracker.GetControlState()
                    )
                );

            NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(
                this,
                g,
                this.TextBounds,
                this.StateTracker.GetControlState(),
                this.Text
                );

            textPaintParams.Font      = this.Font;
            textPaintParams.ForeColor = this.ForeColor;
            textPaintParams.TextAlign = this.TextAlign;

            this.Renderer.DrawText(textPaintParams);
        }
Ejemplo n.º 2
0
        /*
         * OnPaint
         */

        /// <summary>
        /// Raises the paint event.
        /// </summary>
        /// <param name="e">The <see cref="System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics          g            = e.Graphics;
            Rectangle         bounds       = this.ClientRectangle;
            NuGenControlState currentState = this.ButtonStateTracker.GetControlState();
            Image             image        = this.Image;
            ContentAlignment  imageAlign   = this.ImageAlign;
            Rectangle         imageBounds  = Rectangle.Empty;

            if (image != null)
            {
                imageBounds = this.LayoutManager.GetImageBounds(new NuGenImageBoundsParams(bounds, image, imageAlign));
                this.Renderer.DrawImage(new NuGenImagePaintParams(this, g, imageBounds, currentState, image));
            }

            Rectangle textBounds = NuGenControlPaint.TextBoundsFromImageBounds(
                bounds,
                imageBounds,
                imageAlign
                );

            NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(this, g, textBounds, currentState, this.Text);

            textPaintParams.Font      = this.Font;
            textPaintParams.ForeColor = this.ForeColor;
            textPaintParams.TextAlign = this.TextAlign;

            this.Renderer.DrawText(textPaintParams);
        }
Ejemplo n.º 3
0
        /// <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)
        {
            string text = this.SelectedPath;

            if (text != null)
            {
                Graphics  g      = e.Graphics;
                Font      font   = this.Font;
                Rectangle bounds = this.GetTextBounds();

                NuGenTextPaintParams pathPaintParams = new NuGenTextPaintParams(g);
                pathPaintParams.Bounds    = bounds;
                pathPaintParams.Font      = font;
                pathPaintParams.ForeColor = this.ForeColor;
                pathPaintParams.State     = this.StateTracker.GetControlState();
                pathPaintParams.Text      = text;
                pathPaintParams.TextAlign = this.RightToLeft == RightToLeft.Yes
                                        ? ContentAlignment.MiddleRight
                                        : ContentAlignment.MiddleLeft
                ;
                this.Renderer.DrawText(pathPaintParams);

                _toolTip.SetToolTip(
                    this
                    , g.MeasureString(text, font).Width > bounds.Width
                                                ? new NuGenToolTipInfo("", null, text)
                                                : null
                    );
            }

            base.OnPaint(e);
        }
Ejemplo n.º 4
0
        /*
         * OnPaint
         */

        /// <summary>
        /// Raises the <see cref="M:System.Windows.Forms.ButtonBase.OnPaint(System.Windows.Forms.PaintEventArgs)"></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;

            this.Renderer.DrawRadioButton(
                new NuGenPaintParams(
                    this,
                    g,
                    this.RadioButtonBounds,
                    this.ButtonStateTracker.GetControlState()
                    )
                );

            NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(
                this,
                g,
                this.TextBounds,
                this.StateTracker.GetControlState(),
                this.Text
                );

            textPaintParams.Font      = this.Font;
            textPaintParams.ForeColor = this.ForeColor;
            textPaintParams.TextAlign = this.TextAlign;

            this.Renderer.DrawText(textPaintParams);
        }
Ejemplo n.º 5
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.Renderer != null, "this.Renderer != null");

            Graphics          g            = e.Graphics;
            Rectangle         bounds       = this.ClientRectangle;
            NuGenControlState currentState = this.StateTracker.GetControlState();

            _labelRectangle = this.GetLabelRectangle(g, bounds);
            _frameRectangle = this.GetFrameRectangle(_labelRectangle, bounds);

            NuGenPaintParams paintParams = new NuGenPaintParams(g);

            paintParams.Bounds = _frameRectangle;
            paintParams.State  = currentState;

            if (this.Opaque)
            {
                this.Renderer.DrawBackground(paintParams);
            }

            this.Renderer.DrawFrame(paintParams);

            NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(g);

            textPaintParams.Bounds    = _labelRectangle;
            textPaintParams.Font      = this.Font;
            textPaintParams.ForeColor = this.ForeColor;
            textPaintParams.Text      = this.Text;
            textPaintParams.TextAlign = ContentAlignment.MiddleCenter;
            textPaintParams.State     = currentState;

            this.Renderer.DrawLabel(textPaintParams);
        }
Ejemplo n.º 6
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");

            Graphics          g             = e.Graphics;
            NuGenControlState currentState  = this.ButtonStateTracker.GetControlState();
            Rectangle         bounds        = this.ClientRectangle;
            Rectangle         contentBounds = this.LayoutManager.GetContentRectangle(bounds);

            NuGenPaintParams paintParams = new NuGenPaintParams(g);

            paintParams.Bounds = bounds;
            paintParams.State  = currentState;

            this.Renderer.DrawBackground(paintParams);
            this.Renderer.DrawShadow(paintParams);
            this.Renderer.DrawBorder(paintParams);

            Image            image       = this.Image;
            Rectangle        imageBounds = Rectangle.Empty;
            ContentAlignment imageAlign  = this.ImageAlign;

            if (image != null)
            {
                NuGenImagePaintParams imagePaintParams = new NuGenImagePaintParams(g);
                imagePaintParams.Bounds = imageBounds = this.LayoutManager.GetImageBounds(
                    new NuGenBoundsParams(
                        contentBounds
                        , imageAlign
                        , new Rectangle(Point.Empty, image.Size)
                        , this.RightToLeft
                        )
                    );
                imagePaintParams.Image = image;
                imagePaintParams.State = currentState;

                this.Renderer.DrawImage(imagePaintParams);
            }

            if (imageBounds != Rectangle.Empty)
            {
                imageBounds.Inflate(3, 3);
            }

            NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(g);

            textPaintParams.Bounds = this.LayoutManager.GetTextBounds(
                new NuGenBoundsParams(contentBounds, imageAlign, imageBounds, this.RightToLeft)
                );
            textPaintParams.Font      = this.Font;
            textPaintParams.ForeColor = this.ForeColor;
            textPaintParams.Text      = this.Text;
            textPaintParams.TextAlign = NuGenControlPaint.RTLContentAlignment(this.TextAlign, this.RightToLeft);
            textPaintParams.State     = currentState;

            this.Renderer.DrawText(textPaintParams);
        }
Ejemplo n.º 7
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");

            Graphics          g             = e.Graphics;
            NuGenControlState currentState  = this.ButtonStateTracker.GetControlState();
            Rectangle         bounds        = this.ClientRectangle;
            Rectangle         contentBounds = this.LayoutManager.GetContentRectangle(this.ClientRectangle);

            NuGenPaintParams paintParams = new NuGenPaintParams(this, g, bounds, currentState);

            this.Renderer.DrawBackground(paintParams);
            this.Renderer.DrawShadow(paintParams);
            this.Renderer.DrawBorder(paintParams);

            Image            image       = this.Image;
            Rectangle        imageBounds = Rectangle.Empty;
            ContentAlignment imageAlign  = this.ImageAlign;

            if (image != null)
            {
                NuGenImagePaintParams imagePaintParams = new NuGenImagePaintParams(
                    this,
                    g,
                    imageBounds = this.LayoutManager.GetImageBounds(new NuGenImageBoundsParams(contentBounds, image, imageAlign)),
                    currentState,
                    image
                    );

                this.Renderer.DrawImage(imagePaintParams);
            }

            NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(
                this,
                g,
                this.LayoutManager.GetTextBounds(new NuGenTextBoundsParams(contentBounds, imageBounds, imageAlign)),
                currentState,
                this.Text
                );

            textPaintParams.Font      = this.Font;
            textPaintParams.ForeColor = this.ForeColor;
            textPaintParams.TextAlign = this.TextAlign;

            this.Renderer.DrawText(textPaintParams);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// </summary>
        /// <param name="paintParams"></param>
        /// <exception cref="ArgumentNullException">
        /// <para><paramref name="paintParams"/> is <see langword="null"/>.</para>
        /// </exception>
        public void DrawText(NuGenTextPaintParams paintParams)
        {
            if (paintParams == null)
            {
                throw new ArgumentNullException("paintParams");
            }

            this.DrawText(
                paintParams.Graphics,
                paintParams.Bounds,
                paintParams.State,
                paintParams.Text,
                paintParams.Font,
                paintParams.ForeColor,
                paintParams.TextAlign
                );
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        /*
         * OnPaint
         */

        /// <summary>
        /// Raises the paint event.
        /// </summary>
        /// <param name="e">The <see cref="System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics          g            = e.Graphics;
            Rectangle         bounds       = this.ClientRectangle;
            NuGenControlState currentState = this.ButtonStateTracker.GetControlState();
            Image             image        = this.Image;
            ContentAlignment  imageAlign   = this.ImageAlign;
            Rectangle         imageBounds  = Rectangle.Empty;

            if (image != null)
            {
                NuGenImagePaintParams imagePaintParams = new NuGenImagePaintParams(g);
                imagePaintParams.Bounds = imageBounds = this.LayoutManager.GetImageBounds(
                    new NuGenBoundsParams(
                        bounds
                        , imageAlign
                        , new Rectangle(Point.Empty, image.Size)
                        , this.RightToLeft
                        )
                    );
                imagePaintParams.Image = image;
                imagePaintParams.State = currentState;

                this.Renderer.DrawImage(imagePaintParams);
            }

            NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(g);

            textPaintParams.Bounds = this.LayoutManager.GetTextBounds(
                new NuGenBoundsParams(
                    bounds
                    , imageAlign
                    , imageBounds
                    , this.RightToLeft
                    )
                );
            textPaintParams.Font      = this.Font;
            textPaintParams.ForeColor = this.ForeColor;
            textPaintParams.Text      = this.Text;
            textPaintParams.TextAlign = NuGenControlPaint.RTLContentAlignment(this.TextAlign, this.RightToLeft);
            textPaintParams.State     = currentState;

            this.Renderer.DrawText(textPaintParams);
        }
		/*
		 * DrawLabel
		 */

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

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

			this.DrawBackground(paintParams);
			this.DrawBorder(paintParams.Graphics, paintParams.Bounds, paintParams.State);

			this.DrawText(
				g, 
				bounds, 
				state, 
				paintParams.Text, 
				paintParams.Font, 
				paintParams.ForeColor, 
				paintParams.TextAlign);
		}
Ejemplo n.º 12
0
        /*
         * OnPaint
         */

        /// <summary>
        /// Raises the <see cref="M:System.Windows.Forms.ButtonBase.OnPaint(System.Windows.Forms.PaintEventArgs)"></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;
            Rectangle        bounds      = this.ClientRectangle;
            Rectangle        radioBounds = Rectangle.Empty;
            ContentAlignment radioAlign  = this.CheckAlign;

            NuGenRadioButtonPaintParams paintParams = new NuGenRadioButtonPaintParams(g);

            paintParams.Bounds = radioBounds = this.LayoutManager.GetRadioButtonBounds(
                new NuGenBoundsParams(
                    bounds
                    , radioAlign
                    , new Rectangle(Point.Empty, this.LayoutManager.GetRadioSize())
                    , this.RightToLeft
                    )
                );
            paintParams.Checked = this.Checked;
            paintParams.State   = this.ButtonStateTracker.GetControlState();

            this.Renderer.DrawRadioButton(paintParams);

            radioBounds.Inflate(3, 3);

            NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(paintParams);

            textPaintParams.Bounds = this.LayoutManager.GetTextBounds(
                new NuGenBoundsParams(bounds, radioAlign, radioBounds, 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);
        }
Ejemplo n.º 13
0
		/// <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;
			Rectangle bounds = this.ClientRectangle;

			if (this.Orientation == NuGenOrientationStyle.Horizontal)
			{
				bounds.X++;
				bounds.Width -= 2;
			}
			else
			{
				bounds.Y++;
				bounds.Height -= 2;
			}

			Rectangle contentBounds = this.LayoutManager.GetContentRectangle(bounds);
			NuGenControlState currentState = this.ButtonStateTracker.GetControlState();

			NuGenPaintParams paintParams = new NuGenPaintParams(e.Graphics);
			paintParams.Bounds = bounds;
			paintParams.State = currentState;

			if (currentState != NuGenControlState.Normal)
			{
				this.Renderer.DrawBackground(paintParams);
				
				NuGenPaintParams borderPaintParams = new NuGenPaintParams(paintParams);
				borderPaintParams.Bounds = NuGenControlPaint.BorderRectangle(borderPaintParams.Bounds);
				this.Renderer.DrawBorder(borderPaintParams);
			}

			Image image = this.Image;
			Rectangle imageBounds = Rectangle.Empty;
			ContentAlignment imageAlign = this.ImageAlign;

			if (image != null)
			{
				NuGenImagePaintParams imagePaintParams = new NuGenImagePaintParams(g);
				imagePaintParams.Bounds = imageBounds = this.LayoutManager.GetImageBounds(
					new NuGenBoundsParams(contentBounds
						, imageAlign
						, new Rectangle(Point.Empty, image.Size)
						, this.RightToLeft
					)
				);
				imagePaintParams.Image = image;
				imagePaintParams.State = currentState;

				this.Renderer.DrawImage(imagePaintParams);
			}

			if (imageBounds != Rectangle.Empty)
			{
				imageBounds.Inflate(3, 3);
			}

			NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(g);

			textPaintParams.Bounds = this.LayoutManager.GetTextBounds(
				new NuGenBoundsParams(contentBounds, imageAlign, imageBounds, this.RightToLeft)
			);
			textPaintParams.Font = this.Font;
			textPaintParams.ForeColor = this.ForeColor;
			textPaintParams.Text = this.Text;
			textPaintParams.TextAlign = NuGenControlPaint.RTLContentAlignment(this.TextAlign, this.RightToLeft);
			textPaintParams.State = currentState;

			this.Renderer.DrawText(textPaintParams);
		}
Ejemplo n.º 14
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.Renderer != null, "this.Renderer != null");
			
			Graphics g = e.Graphics;
			Rectangle bounds = this.ClientRectangle;
			NuGenControlState currentState = this.StateTracker.GetControlState();

			_labelRectangle = this.GetLabelRectangle(g, bounds);
			_frameRectangle = this.GetFrameRectangle(_labelRectangle, bounds);

			NuGenPaintParams paintParams = new NuGenPaintParams(g);
			paintParams.Bounds = _frameRectangle;
			paintParams.State = currentState;

			if (this.Opaque)
			{
				this.Renderer.DrawBackground(paintParams);
			}

			this.Renderer.DrawFrame(paintParams);

			NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(g);

			textPaintParams.Bounds = _labelRectangle;
			textPaintParams.Font = this.Font;
			textPaintParams.ForeColor = this.ForeColor;
			textPaintParams.Text = this.Text;
			textPaintParams.TextAlign = ContentAlignment.MiddleCenter;
			textPaintParams.State = currentState;

			this.Renderer.DrawLabel(textPaintParams);
		}
Ejemplo n.º 15
0
		/*
		 * OnPaint
		 */

		/// <summary>
		/// Raises the <see cref="M:System.Windows.Forms.ButtonBase.OnPaint(System.Windows.Forms.PaintEventArgs)"></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;
			Rectangle bounds = this.ClientRectangle;
			Rectangle radioBounds = Rectangle.Empty;
			ContentAlignment radioAlign = this.CheckAlign;

			NuGenRadioButtonPaintParams paintParams = new NuGenRadioButtonPaintParams(g);
			paintParams.Bounds = radioBounds = this.LayoutManager.GetRadioButtonBounds(
				new NuGenBoundsParams(
					bounds
					, radioAlign
					, new Rectangle(Point.Empty, this.LayoutManager.GetRadioSize())
					, this.RightToLeft
				)
			);
			paintParams.Checked = this.Checked;
			paintParams.State = this.ButtonStateTracker.GetControlState();

			this.Renderer.DrawRadioButton(paintParams);

			radioBounds.Inflate(3, 3);

			NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(paintParams);
			textPaintParams.Bounds = this.LayoutManager.GetTextBounds(
				new NuGenBoundsParams(bounds, radioAlign, radioBounds, 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);
		}
Ejemplo n.º 16
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");

			Graphics g = e.Graphics;
			NuGenControlState currentState = this.ButtonStateTracker.GetControlState();
			Rectangle bounds = this.ClientRectangle;
			Rectangle contentBounds = this.LayoutManager.GetContentRectangle(this.ClientRectangle);

			NuGenPaintParams paintParams = new NuGenPaintParams(this, g, bounds, currentState);

			this.Renderer.DrawBackground(paintParams);
			this.Renderer.DrawShadow(paintParams);
			this.Renderer.DrawBorder(paintParams);

			Image image = this.Image;
			Rectangle imageBounds = Rectangle.Empty;
			ContentAlignment imageAlign = this.ImageAlign;

			if (image != null)
			{
				NuGenImagePaintParams imagePaintParams = new NuGenImagePaintParams(
					this,
					g,
					imageBounds = this.LayoutManager.GetImageBounds(new NuGenImageBoundsParams(contentBounds, image, imageAlign)),
					currentState,
					image
				);

				this.Renderer.DrawImage(imagePaintParams);
			}

			NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(
				this,
				g,
				this.LayoutManager.GetTextBounds(new NuGenTextBoundsParams(contentBounds, imageBounds, imageAlign)),
				currentState,
				this.Text
			);
			textPaintParams.Font = this.Font;
			textPaintParams.ForeColor = this.ForeColor;
			textPaintParams.TextAlign = this.TextAlign;

			this.Renderer.DrawText(textPaintParams);
		}
Ejemplo n.º 17
0
        /// <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;
            Rectangle bounds = this.ClientRectangle;

            if (this.Orientation == NuGenOrientationStyle.Horizontal)
            {
                bounds.X++;
                bounds.Width -= 2;
            }
            else
            {
                bounds.Y++;
                bounds.Height -= 2;
            }

            Rectangle         contentBounds = this.LayoutManager.GetContentRectangle(bounds);
            NuGenControlState currentState  = this.ButtonStateTracker.GetControlState();

            NuGenPaintParams paintParams = new NuGenPaintParams(e.Graphics);

            paintParams.Bounds = bounds;
            paintParams.State  = currentState;

            if (currentState != NuGenControlState.Normal)
            {
                this.Renderer.DrawBackground(paintParams);

                NuGenPaintParams borderPaintParams = new NuGenPaintParams(paintParams);
                borderPaintParams.Bounds = NuGenControlPaint.BorderRectangle(borderPaintParams.Bounds);
                this.Renderer.DrawBorder(borderPaintParams);
            }

            Image            image       = this.Image;
            Rectangle        imageBounds = Rectangle.Empty;
            ContentAlignment imageAlign  = this.ImageAlign;

            if (image != null)
            {
                NuGenImagePaintParams imagePaintParams = new NuGenImagePaintParams(g);
                imagePaintParams.Bounds = imageBounds = this.LayoutManager.GetImageBounds(
                    new NuGenBoundsParams(contentBounds
                                          , imageAlign
                                          , new Rectangle(Point.Empty, image.Size)
                                          , this.RightToLeft
                                          )
                    );
                imagePaintParams.Image = image;
                imagePaintParams.State = currentState;

                this.Renderer.DrawImage(imagePaintParams);
            }

            if (imageBounds != Rectangle.Empty)
            {
                imageBounds.Inflate(3, 3);
            }

            NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(g);

            textPaintParams.Bounds = this.LayoutManager.GetTextBounds(
                new NuGenBoundsParams(contentBounds, imageAlign, imageBounds, this.RightToLeft)
                );
            textPaintParams.Font      = this.Font;
            textPaintParams.ForeColor = this.ForeColor;
            textPaintParams.Text      = this.Text;
            textPaintParams.TextAlign = NuGenControlPaint.RTLContentAlignment(this.TextAlign, this.RightToLeft);
            textPaintParams.State     = currentState;

            this.Renderer.DrawText(textPaintParams);
        }
Ejemplo n.º 18
0
		/// <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)
		{
			NuGenPaintParams paintParams = new NuGenPaintParams(e.Graphics);
			paintParams.Bounds = this.ClientRectangle;
			paintParams.State = this.ButtonStateTracker.GetControlState();

			switch (paintParams.State)
			{
				case NuGenControlState.Pressed:
				case NuGenControlState.Hot:
				{
					_cwRotateButton.Visible = _ccwRotateButton.Visible = true;
					break;
				}
				default:
				{
					_cwRotateButton.Visible = _ccwRotateButton.Visible = false;
					break;
				}
			}

			this.Renderer.DrawBackground(paintParams);
			this.Renderer.DrawBorder(paintParams);

			NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(paintParams);

			using (Font font = this.Renderer.GetFont(textPaintParams.Bounds))
			{
				textPaintParams.Bounds = this.LayoutManager.GetTextBounds(textPaintParams.Bounds, font.Size);
				textPaintParams.Font = font;
				textPaintParams.ForeColor = this.Renderer.GetForeColor(textPaintParams.State);
				textPaintParams.Text = this.Text;
				textPaintParams.TextAlign = this.TextAlign;

				this.Renderer.DrawText(textPaintParams);
			}

			Image image = this.Image;

			if (image != null)
			{
				NuGenImagePaintParams imagePaintParams = new NuGenImagePaintParams(paintParams);
				imagePaintParams.Bounds = this.LayoutManager.GetImageBounds(imagePaintParams.Bounds, image.Size);
				imagePaintParams.Image = image;

				this.Renderer.DrawImage(imagePaintParams);
				this.Renderer.DrawBorder(imagePaintParams);
			}

			base.OnPaint(e);
		}
Ejemplo n.º 19
0
        /// <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)
        {
            if (!_shouldRender)
            {
                return;
            }

            int i;
            int x;
            int y;
            int space;
            int size;
            int width  = this.Width;
            int height = this.Height;

            Graphics g = e.Graphics;

            g.TextRenderingHint = TextRenderingHint.AntiAlias;

            /*
             * Fisheye
             */

            y = _borderY;
            int  y1 = 0;
            int  y2 = height - _borderY;
            bool start;

            size = 0;

            if (_focusLock)
            {
                start = true;
                y     = _flFocusPosition;
                for (i = _focusIndex - 1; i >= 0; i--)
                {
                    size  = _flSizeLUT[i];
                    space = _flSpaceLUT[i];

                    if (size == _minFontSize)
                    {
                        y1 = y + size + space;
                        break;
                    }

                    y -= size + space;
                }

                y = _flFocusPosition;

                for (i = _focusIndex; i < this.Items.Count; i++)
                {
                    size  = _flSizeLUT[i];
                    space = _flSpaceLUT[i];

                    if (size == _minFontSize)
                    {
                        y2 = y;
                        break;
                    }

                    y += size + space;
                }

                if (y1 < _borderY)
                {
                    y1 = _borderY;
                }
            }
            else
            {
                start = true;

                for (i = 0; i < this.Items.Count; i++)
                {
                    size  = _sizeLUT[_focusIndex][i];
                    space = _spaceLUT[_focusIndex][i];

                    if (start)
                    {
                        if (size > _minFontSize)
                        {
                            y1    = y;
                            start = false;
                        }
                    }
                    else
                    {
                        if (size == _minFontSize)
                        {
                            y2 = y - size;
                            break;
                        }
                    }

                    y += size + space;
                }
            }

            if (this.Items.Count > 0 && !_noFishEye)
            {
                int expanderLeft   = width / 2;
                int expanderTop    = y1;
                int expanderWidth  = width / 2 - _borderRight;
                int expanderHeight = y2 - y1;

                if (expanderWidth > 0 && expanderHeight > 0)
                {
                    NuGenPaintParams expanderPaintParams = new NuGenPaintParams(g);
                    expanderPaintParams.Bounds = new Rectangle(
                        expanderLeft
                        , expanderTop
                        , expanderWidth
                        , expanderHeight
                        );

                    if (_focusLock)
                    {
                        expanderPaintParams.State = NuGenControlState.Hot;
                    }
                    else
                    {
                        expanderPaintParams.State = NuGenControlState.Normal;
                    }

                    this.Renderer.DrawFisheyeExpander(expanderPaintParams);
                }
            }

            /*
             * Items
             */

            x = _borderLeft;
            y = _borderY;

            NuGenTextPaintParams itemPaintParams = new NuGenTextPaintParams(g);

            itemPaintParams.ForeColor = this.ForeColor;
            itemPaintParams.State     = this.StateTracker.GetControlState();
            itemPaintParams.TextAlign = ContentAlignment.MiddleLeft;

            List <string> sortedItems = this.GetSortedItems(this.Items);

            Debug.Assert(sortedItems != null, "sortedItems != null");

            if (!_focusLock /* Normal mode. */)
            {
                for (i = 0; i < sortedItems.Count; i++)
                {
                    size  = _sizeLUT[_focusIndex][i];
                    space = _spaceLUT[_focusIndex][i];

                    // Draw focused element with a background hilight
                    if (_selectedIndex == i)
                    {
                        NuGenPaintParams selPaintParams = new NuGenPaintParams(itemPaintParams);
                        selPaintParams.Bounds = this.LayoutManager.GetSelectionFrameBounds(
                            _borderLeft, y, width - (_borderLeft + _borderRight) - 1, size + space
                            );
                        selPaintParams.State = NuGenControlState.Hot;

                        this.Renderer.DrawSelectionFrame(selPaintParams);
                    }                     // if

                    itemPaintParams.Text   = sortedItems[i];
                    itemPaintParams.Font   = _fonts[size - 1];
                    itemPaintParams.Bounds = this.GetTextBounds(g, itemPaintParams.Text, itemPaintParams.Font, x, y);

                    this.Renderer.DrawText(itemPaintParams);
                    y += space + size;
                }                 // for

                foreach (KeyValuePair <string, int> pair in _labelLUT)
                {
                    itemPaintParams.Text   = pair.Key;
                    itemPaintParams.Font   = _boldFonts[_maxFontSize - 1];
                    itemPaintParams.Bounds = this.GetTextBounds(
                        g
                        , itemPaintParams.Text
                        , itemPaintParams.Font
                        , _labelBorderLeft
                        , pair.Value - _sizeLUT[0][0]
                        );

                    this.Renderer.DrawText(itemPaintParams);
                }            // foreach
            }
            else             /* Fisheye mode. */
            {
                if (_focusIndex > 0 /* First render from focus up. */)
                {
                    y = _flFocusPosition - _flSizeLUT[_focusIndex - 1] - _flSpaceLUT[_focusIndex - 1];

                    for (i = _focusIndex - 1; i >= 0; i--)
                    {
                        if (y < _borderY)
                        {
                            break;
                        }

                        size  = _flSizeLUT[i];
                        space = _flSpaceLUT[i];

                        // Draw focused element with a background hilight.
                        if (_selectedIndex == i)
                        {
                            NuGenPaintParams selPaintParams = new NuGenPaintParams(itemPaintParams);
                            selPaintParams.Bounds = this.LayoutManager.GetSelectionFrameBounds(
                                _borderLeft, y, width - (_borderLeft + _borderRight), size + space
                                );
                            selPaintParams.State = NuGenControlState.Hot;

                            this.Renderer.DrawSelectionFrame(selPaintParams);
                        }                         // if

                        itemPaintParams.Text   = sortedItems[i];
                        itemPaintParams.Font   = _fonts[size - 1];
                        itemPaintParams.Bounds = this.GetTextBounds(g, itemPaintParams.Text, itemPaintParams.Font, x, y);

                        this.Renderer.DrawText(itemPaintParams);

                        if (i > 0)
                        {
                            y -= _flSizeLUT[i - 1] + _flSpaceLUT[i - 1];
                        }
                    }             // for
                }                 // if

                /* Then render from focus down. */

                y = _flFocusPosition;

                for (i = _focusIndex; i < sortedItems.Count; i++)
                {
                    if (y > height - _borderY)
                    {
                        break;
                    }

                    size  = _flSizeLUT[i];
                    space = _flSpaceLUT[i];

                    // Draw focused element with a background hilight
                    if (_selectedIndex == i)
                    {
                        NuGenPaintParams selPaintParams = new NuGenPaintParams(itemPaintParams);
                        selPaintParams.Bounds = this.LayoutManager.GetSelectionFrameBounds(
                            _borderLeft, y, width - (_borderLeft + _borderRight), size + space
                            );
                        selPaintParams.State = NuGenControlState.Hot;

                        this.Renderer.DrawSelectionFrame(selPaintParams);
                    }

                    itemPaintParams.Text   = sortedItems[i];
                    itemPaintParams.Font   = _fonts[size - 1];
                    itemPaintParams.Bounds = this.GetTextBounds(g, itemPaintParams.Text, itemPaintParams.Font, x, y);

                    this.Renderer.DrawText(itemPaintParams);

                    y += space + size;
                }                 // for
            }

            base.OnPaint(e);
        }
Ejemplo n.º 20
0
		/// <summary>
		/// </summary>
		/// <param name="paintParams"></param>
		/// <exception cref="ArgumentNullException">
		/// <para><paramref name="paintParams"/> is <see langword="null"/>.</para>
		/// </exception>
		public void DrawText(NuGenTextPaintParams paintParams)
		{
			if (paintParams == null)
			{
				throw new ArgumentNullException("paintParams");
			}

			this.DrawText(
				paintParams.Graphics,
				paintParams.Bounds,
				paintParams.State,
				paintParams.Text,
				paintParams.Font,
				paintParams.ForeColor,
				paintParams.TextAlign
			);
		}
		/*
		 * DrawHeaderText
		 */

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

			this.DrawText(paintParams);
		}
		/*
		 * DrawText
		 */

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

			Graphics g = paintParams.Graphics;

			using (NuGenGrfxMode mode = new NuGenGrfxMode(g))
			{
				g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

				using (StringFormat sf = new StringFormat())
				{
					sf.Trimming = StringTrimming.EllipsisCharacter;

					base.DrawText(
						paintParams.Graphics,
						paintParams.Bounds,
						paintParams.State,
						paintParams.Text,
						paintParams.Font,
						paintParams.ForeColor,
						sf
					);
				}
			}
		}
		/// <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)
		{
			string text = this.SelectedPath;

			if (text != null)
			{
				Graphics g = e.Graphics;
				Font font = this.Font;
				Rectangle bounds = this.GetTextBounds();

				NuGenTextPaintParams pathPaintParams = new NuGenTextPaintParams(g);
				pathPaintParams.Bounds = bounds;
				pathPaintParams.Font = font;
				pathPaintParams.ForeColor = this.ForeColor;
				pathPaintParams.State = this.StateTracker.GetControlState();
				pathPaintParams.Text = text;
				pathPaintParams.TextAlign = this.RightToLeft == RightToLeft.Yes
					? ContentAlignment.MiddleRight
					: ContentAlignment.MiddleLeft
					;
				this.Renderer.DrawText(pathPaintParams);

				_toolTip.SetToolTip(
					this
					, g.MeasureString(text, font).Width > bounds.Width
						? new NuGenToolTipInfo("", null, text)
						: null
				);
			}

			base.OnPaint(e);
		}
Ejemplo n.º 24
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);
		}
            /*
             * OnPaint
             */

            protected override void OnPaint(PaintEventArgs e)
            {
                Graphics g = e.Graphics;

                Rectangle bounds       = this.ClientRectangle;
                Size      shadowSize   = this.LayoutManager.GetShadowSize();
                Rectangle shadowBounds = new Rectangle(
                    bounds.Left + shadowSize.Width,
                    bounds.Top + shadowSize.Height,
                    bounds.Width - shadowSize.Width,
                    bounds.Height - shadowSize.Height
                    );
                Rectangle bodyBounds = new Rectangle(
                    bounds.Left,
                    bounds.Top,
                    bounds.Width - shadowSize.Width,
                    bounds.Height - shadowSize.Height
                    );

                NuGenPaintParams paintParams = new NuGenPaintParams(g);

                paintParams.State = _state;

                paintParams.Bounds = shadowBounds;
                this.Renderer.DrawShadow(paintParams);

                paintParams.Bounds = bodyBounds;
                this.Renderer.DrawBackground(paintParams);
                this.Renderer.DrawBorder(paintParams);

                if (_tooltipInfo != null)
                {
                    NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(paintParams);
                    textPaintParams.TextAlign = ContentAlignment.MiddleLeft;
                    textPaintParams.ForeColor = this.ForeColor;

                    NuGenImagePaintParams imagePaintParams = new NuGenImagePaintParams(paintParams);

                    if (_tooltipInfo.IsHeaderVisible)
                    {
                        textPaintParams.Bounds = _layoutDescriptor.HeaderBounds;
                        textPaintParams.Font   = _headerFont;
                        textPaintParams.Text   = _tooltipInfo.Header;

                        this.Renderer.DrawHeaderText(textPaintParams);
                    }

                    if (_tooltipInfo.IsTextVisible)
                    {
                        textPaintParams.Bounds = _layoutDescriptor.TextBounds;
                        textPaintParams.Font   = _textFont;
                        textPaintParams.Text   = _tooltipInfo.Text;

                        this.Renderer.DrawText(textPaintParams);
                    }

                    if (_tooltipInfo.IsImageVisible)
                    {
                        imagePaintParams.Bounds = _layoutDescriptor.ImageBounds;
                        imagePaintParams.Image  = _tooltipInfo.Image;

                        this.Renderer.DrawImage(imagePaintParams);
                    }

                    if (_tooltipInfo.IsRemarksHeaderVisible)
                    {
                        textPaintParams.Bounds = _layoutDescriptor.RemarksHeaderBounds;
                        textPaintParams.Font   = _headerFont;
                        textPaintParams.Text   = _tooltipInfo.RemarksHeader;

                        this.Renderer.DrawHeaderText(textPaintParams);

                        if (_tooltipInfo.IsRemarksVisible)
                        {
                            textPaintParams.Bounds = _layoutDescriptor.RemarksBounds;
                            textPaintParams.Font   = _textFont;
                            textPaintParams.Text   = _tooltipInfo.Remarks;

                            this.Renderer.DrawText(textPaintParams);
                        }

                        if (_tooltipInfo.IsRemarksImageVisible)
                        {
                            imagePaintParams.Bounds = _layoutDescriptor.RemarksImageBounds;
                            imagePaintParams.Image  = _tooltipInfo.RemarksImage;

                            this.Renderer.DrawImage(imagePaintParams);
                        }

                        paintParams.Bounds = _layoutDescriptor.BevelBounds;
                        this.Renderer.DrawBevel(paintParams);
                    }
                }
            }
Ejemplo n.º 26
0
		/// <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)
		{
			if (!_shouldRender)
			{
				return;
			}

			int i;
			int x;
			int y;
			int space;
			int size;
			int width = this.Width;
			int height = this.Height;

			Graphics g = e.Graphics;
			g.TextRenderingHint = TextRenderingHint.AntiAlias;

			/*
			 * Fisheye
			 */

			y = _borderY;
			int y1 = 0;
			int y2 = height - _borderY;
			bool start;
			size = 0;

			if (_focusLock)
			{
				start = true;
				y = _flFocusPosition;
				for (i = _focusIndex - 1; i >= 0; i--)
				{
					size = _flSizeLUT[i];
					space = _flSpaceLUT[i];

					if (size == _minFontSize)
					{
						y1 = y + size + space;
						break;
					}

					y -= size + space;
				}

				y = _flFocusPosition;

				for (i = _focusIndex; i < this.Items.Count; i++)
				{
					size = _flSizeLUT[i];
					space = _flSpaceLUT[i];

					if (size == _minFontSize)
					{
						y2 = y;
						break;
					}

					y += size + space;
				}

				if (y1 < _borderY)
				{
					y1 = _borderY;
				}
			}
			else
			{
				start = true;

				for (i = 0; i < this.Items.Count; i++)
				{
					size = _sizeLUT[_focusIndex][i];
					space = _spaceLUT[_focusIndex][i];

					if (start)
					{
						if (size > _minFontSize)
						{
							y1 = y;
							start = false;
						}
					}
					else
					{
						if (size == _minFontSize)
						{
							y2 = y - size;
							break;
						}
					}

					y += size + space;
				}
			}

			if (this.Items.Count > 0 && !_noFishEye)
			{
				int expanderLeft = width / 2;
				int expanderTop = y1;
				int expanderWidth = width / 2 - _borderRight;
				int expanderHeight = y2 - y1;

				if (expanderWidth > 0 && expanderHeight > 0)
				{
					NuGenPaintParams expanderPaintParams = new NuGenPaintParams(g);
					expanderPaintParams.Bounds = new Rectangle(
						expanderLeft
						, expanderTop
						, expanderWidth
						, expanderHeight
						);

					if (_focusLock)
					{
						expanderPaintParams.State = NuGenControlState.Hot;
					}
					else
					{
						expanderPaintParams.State = NuGenControlState.Normal;
					}

					this.Renderer.DrawFisheyeExpander(expanderPaintParams);
				}
			}

			/*
			 * Items
			 */

			x = _borderLeft;
			y = _borderY;

			NuGenTextPaintParams itemPaintParams = new NuGenTextPaintParams(g);
			itemPaintParams.ForeColor = this.ForeColor;
			itemPaintParams.State = this.StateTracker.GetControlState();
			itemPaintParams.TextAlign = ContentAlignment.MiddleLeft;

			List<string> sortedItems = this.GetSortedItems(this.Items);
			Debug.Assert(sortedItems != null, "sortedItems != null");

			if (!_focusLock /* Normal mode. */)
			{
				for (i = 0; i < sortedItems.Count; i++)
				{
					size = _sizeLUT[_focusIndex][i];
					space = _spaceLUT[_focusIndex][i];

					// Draw focused element with a background hilight
					if (_selectedIndex == i)
					{
						NuGenPaintParams selPaintParams = new NuGenPaintParams(itemPaintParams);
						selPaintParams.Bounds = this.LayoutManager.GetSelectionFrameBounds(
							_borderLeft, y, width - (_borderLeft + _borderRight) - 1, size + space
						);
						selPaintParams.State = NuGenControlState.Hot;

						this.Renderer.DrawSelectionFrame(selPaintParams);
					} // if

					itemPaintParams.Text = sortedItems[i];
					itemPaintParams.Font = _fonts[size - 1];
					itemPaintParams.Bounds = this.GetTextBounds(g, itemPaintParams.Text, itemPaintParams.Font, x, y);

					this.Renderer.DrawText(itemPaintParams);
					y += space + size;
				} // for

				foreach (KeyValuePair<string, int> pair in _labelLUT)
				{
					itemPaintParams.Text = pair.Key;
					itemPaintParams.Font = _boldFonts[_maxFontSize - 1];
					itemPaintParams.Bounds = this.GetTextBounds(
						g
						, itemPaintParams.Text
						, itemPaintParams.Font
						, _labelBorderLeft
						, pair.Value - _sizeLUT[0][0]
					);

					this.Renderer.DrawText(itemPaintParams);
				} // foreach
			}
			else /* Fisheye mode. */
			{
				if (_focusIndex > 0 /* First render from focus up. */)
				{
					y = _flFocusPosition - _flSizeLUT[_focusIndex - 1] - _flSpaceLUT[_focusIndex - 1];

					for (i = _focusIndex - 1; i >= 0; i--)
					{
						if (y < _borderY)
						{
							break;
						}

						size = _flSizeLUT[i];
						space = _flSpaceLUT[i];

						// Draw focused element with a background hilight.
						if (_selectedIndex == i)
						{
							NuGenPaintParams selPaintParams = new NuGenPaintParams(itemPaintParams);
							selPaintParams.Bounds = this.LayoutManager.GetSelectionFrameBounds(
								_borderLeft, y, width - (_borderLeft + _borderRight), size + space
							);
							selPaintParams.State = NuGenControlState.Hot;

							this.Renderer.DrawSelectionFrame(selPaintParams);
						} // if

						itemPaintParams.Text = sortedItems[i];
						itemPaintParams.Font = _fonts[size - 1];
						itemPaintParams.Bounds = this.GetTextBounds(g, itemPaintParams.Text, itemPaintParams.Font, x, y);

						this.Renderer.DrawText(itemPaintParams);

						if (i > 0)
						{
							y -= _flSizeLUT[i - 1] + _flSpaceLUT[i - 1];
						}
					} // for
				} // if

				/* Then render from focus down. */

				y = _flFocusPosition;

				for (i = _focusIndex; i < sortedItems.Count; i++)
				{
					if (y > height - _borderY)
					{
						break;
					}

					size = _flSizeLUT[i];
					space = _flSpaceLUT[i];

					// Draw focused element with a background hilight
					if (_selectedIndex == i)
					{
						NuGenPaintParams selPaintParams = new NuGenPaintParams(itemPaintParams);
						selPaintParams.Bounds = this.LayoutManager.GetSelectionFrameBounds(
							_borderLeft, y, width - (_borderLeft + _borderRight), size + space
						);
						selPaintParams.State = NuGenControlState.Hot;

						this.Renderer.DrawSelectionFrame(selPaintParams);
					}

					itemPaintParams.Text = sortedItems[i];
					itemPaintParams.Font = _fonts[size - 1];
					itemPaintParams.Bounds = this.GetTextBounds(g, itemPaintParams.Text, itemPaintParams.Font, x, y);

					this.Renderer.DrawText(itemPaintParams);

					y += space + size;
				} // for
			}

			base.OnPaint(e);
		}
Ejemplo n.º 27
0
		/*
		 * OnPaint
		 */

		/// <summary>
		/// Raises the paint event.
		/// </summary>
		/// <param name="e">The <see cref="System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param>
		protected override void OnPaint(PaintEventArgs e)
		{
			Graphics g = e.Graphics;
			Rectangle bounds = this.ClientRectangle;
			NuGenControlState currentState = this.ButtonStateTracker.GetControlState();
			Image image = this.Image;
			ContentAlignment imageAlign = this.ImageAlign;
			Rectangle imageBounds = Rectangle.Empty;

			if (image != null)
			{
				NuGenImagePaintParams imagePaintParams = new NuGenImagePaintParams(g);
				imagePaintParams.Bounds = imageBounds = this.LayoutManager.GetImageBounds(
					new NuGenBoundsParams(
						bounds
						, imageAlign
						, new Rectangle(Point.Empty, image.Size)
						, this.RightToLeft
					)
				);
				imagePaintParams.Image = image;
				imagePaintParams.State = currentState;

				this.Renderer.DrawImage(imagePaintParams);
			}

			NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(g);

			textPaintParams.Bounds = this.LayoutManager.GetTextBounds(
				new NuGenBoundsParams(
					bounds
					, imageAlign
					, imageBounds
					, this.RightToLeft
				)
			);
			textPaintParams.Font = this.Font;
			textPaintParams.ForeColor = this.ForeColor;
			textPaintParams.Text = this.Text;
			textPaintParams.TextAlign = NuGenControlPaint.RTLContentAlignment(this.TextAlign, this.RightToLeft);
			textPaintParams.State = currentState;

			this.Renderer.DrawText(textPaintParams);
		}
Ejemplo n.º 28
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;

			this.Renderer.DrawCheckBox(
				new NuGenPaintParams(
					this,
					g,
					this.CheckBoxBounds,
					this.ButtonStateTracker.GetControlState()
				)
			);

			NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(
				this,
				g,
				this.TextBounds,
				this.StateTracker.GetControlState(),
				this.Text
			);

			textPaintParams.Font = this.Font;
			textPaintParams.ForeColor = this.ForeColor;
			textPaintParams.TextAlign = this.TextAlign;

			this.Renderer.DrawText(textPaintParams);
		}
			/*
			 * OnPaint
			 */

			protected override void OnPaint(PaintEventArgs e)
			{
				Graphics g = e.Graphics;

				Rectangle bounds = this.ClientRectangle;
				Size shadowSize = this.LayoutManager.GetShadowSize();
				Rectangle shadowBounds = new Rectangle(
					bounds.Left + shadowSize.Width,
					bounds.Top + shadowSize.Height,
					bounds.Width - shadowSize.Width,
					bounds.Height - shadowSize.Height
				);
				Rectangle bodyBounds = new Rectangle(
					bounds.Left,
					bounds.Top,
					bounds.Width - shadowSize.Width,
					bounds.Height - shadowSize.Height
				);

				NuGenPaintParams paintParams = new NuGenPaintParams(g);
				paintParams.State = _state;

				paintParams.Bounds = shadowBounds;
				this.Renderer.DrawShadow(paintParams);

				paintParams.Bounds = bodyBounds;
				this.Renderer.DrawBackground(paintParams);
				this.Renderer.DrawBorder(paintParams);

				if (_tooltipInfo != null)
				{
					NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(paintParams);
					textPaintParams.TextAlign = ContentAlignment.MiddleLeft;
					textPaintParams.ForeColor = this.ForeColor;

					NuGenImagePaintParams imagePaintParams = new NuGenImagePaintParams(paintParams);

					if (_tooltipInfo.IsHeaderVisible)
					{
						textPaintParams.Bounds = _layoutDescriptor.HeaderBounds;
						textPaintParams.Font = _headerFont;
						textPaintParams.Text = _tooltipInfo.Header;

						this.Renderer.DrawHeaderText(textPaintParams);
					}

					if (_tooltipInfo.IsTextVisible)
					{
						textPaintParams.Bounds = _layoutDescriptor.TextBounds;
						textPaintParams.Font = _textFont;
						textPaintParams.Text = _tooltipInfo.Text;

						this.Renderer.DrawText(textPaintParams);
					}

					if (_tooltipInfo.IsImageVisible)
					{
						imagePaintParams.Bounds = _layoutDescriptor.ImageBounds;
						imagePaintParams.Image = _tooltipInfo.Image;

						this.Renderer.DrawImage(imagePaintParams);
					}

					if (_tooltipInfo.IsRemarksHeaderVisible)
					{
						textPaintParams.Bounds = _layoutDescriptor.RemarksHeaderBounds;
						textPaintParams.Font = _headerFont;
						textPaintParams.Text = _tooltipInfo.RemarksHeader;

						this.Renderer.DrawHeaderText(textPaintParams);

						if (_tooltipInfo.IsRemarksVisible)
						{
							textPaintParams.Bounds = _layoutDescriptor.RemarksBounds;
							textPaintParams.Font = _textFont;
							textPaintParams.Text = _tooltipInfo.Remarks;

							this.Renderer.DrawText(textPaintParams);
						}

						if (_tooltipInfo.IsRemarksImageVisible)
						{
							imagePaintParams.Bounds = _layoutDescriptor.RemarksImageBounds;
							imagePaintParams.Image = _tooltipInfo.RemarksImage;

							this.Renderer.DrawImage(imagePaintParams);
						}

						paintParams.Bounds = _layoutDescriptor.BevelBounds;
						this.Renderer.DrawBevel(paintParams);
					}
				}
			}
Ejemplo n.º 30
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");

			Graphics g = e.Graphics;
			NuGenControlState currentState = this.ButtonStateTracker.GetControlState();
			Rectangle bounds = this.ClientRectangle;
			Rectangle contentBounds = this.LayoutManager.GetContentRectangle(bounds);

			NuGenPaintParams paintParams = new NuGenPaintParams(g);
			paintParams.Bounds = bounds;
			paintParams.State = currentState;

			this.Renderer.DrawBackground(paintParams);
			this.Renderer.DrawShadow(paintParams);
			this.Renderer.DrawBorder(paintParams);

			Image image = this.Image;
			Rectangle imageBounds = Rectangle.Empty;
			ContentAlignment imageAlign = this.ImageAlign;

			if (image != null)
			{
				NuGenImagePaintParams imagePaintParams = new NuGenImagePaintParams(g);
				imagePaintParams.Bounds = imageBounds = this.LayoutManager.GetImageBounds(
					new NuGenBoundsParams(
						contentBounds
						, imageAlign
						, new Rectangle(Point.Empty, image.Size)
						, this.RightToLeft
						)
					);
				imagePaintParams.Image = image;
				imagePaintParams.State = currentState;

				this.Renderer.DrawImage(imagePaintParams);
			}

			if (imageBounds != Rectangle.Empty)
			{
				imageBounds.Inflate(3, 3);
			}

			NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(g);

			textPaintParams.Bounds = this.LayoutManager.GetTextBounds(
				new NuGenBoundsParams(contentBounds, imageAlign, imageBounds, this.RightToLeft)
			);
			textPaintParams.Font = this.Font;
			textPaintParams.ForeColor = this.ForeColor;
			textPaintParams.Text = this.Text;
			textPaintParams.TextAlign = NuGenControlPaint.RTLContentAlignment(this.TextAlign, this.RightToLeft);
			textPaintParams.State = currentState;

			this.Renderer.DrawText(textPaintParams);
		}
Ejemplo n.º 31
0
		/*
		 * OnPaint
		 */

		/// <summary>
		/// Raises the <see cref="M:System.Windows.Forms.ButtonBase.OnPaint(System.Windows.Forms.PaintEventArgs)"></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;

			this.Renderer.DrawRadioButton(
				new NuGenPaintParams(
					this,
					g,
					this.RadioButtonBounds,
					this.ButtonStateTracker.GetControlState()
				)
			);

			NuGenTextPaintParams textPaintParams = new NuGenTextPaintParams(
				this,
				g,
				this.TextBounds,
				this.StateTracker.GetControlState(),
				this.Text
			);

			textPaintParams.Font = this.Font;
			textPaintParams.ForeColor = this.ForeColor;
			textPaintParams.TextAlign = this.TextAlign;

			this.Renderer.DrawText(textPaintParams);
		}