示例#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)
        {
            Graphics g = e.Graphics;

            using (SolidBrush sb = new SolidBrush(this.BackColor))
            {
                g.FillRectangle(sb, this.ClientRectangle);
            }

            NuGenTabButtonPaintParams tabItemParams = new NuGenTabButtonPaintParams(g, this.ClientRectangle);

            tabItemParams.Font          = this.Font;
            tabItemParams.Image         = this.Image;
            tabItemParams.ImageBounds   = this.ImageBounds;
            tabItemParams.IsRightToLeft = this.RightToLeft == RightToLeft.Yes;
            tabItemParams.Text          = this.Text;

            float textHeight = g.MeasureString(this.Text, this.Font).Height;

            tabItemParams.TextBounds = new Rectangle(
                this.ClientRectangle.Left + this.ImageBounds.Right + 5,
                this.ClientRectangle.Top + this.ClientRectangle.Height / 2 - (int)(textHeight / 2.0f),
                this.ClientRectangle.Width - this.ImageBounds.Width - this.CloseButton.Width - 20,
                (int)textHeight
                );

            if (!this.Enabled)
            {
                tabItemParams.State = TabItemState.Disabled;
            }
            else
            {
                switch (this.TabStateTracker.GetControlState(this))
                {
                case NuGenControlState.Hot:
                {
                    tabItemParams.State = TabItemState.Hot;
                    break;
                }

                case NuGenControlState.Pressed:
                {
                    tabItemParams.State = TabItemState.Selected;
                    break;
                }
                }
            }

            Debug.Assert(this.TabRenderer != null, "this.TabRenderer != null");
            this.TabRenderer.DrawTabButton(tabItemParams);
        }
示例#2
0
        /*
         * DrawTabButton
         */

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

            Graphics g = paintParams.Graphics;

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

            if (Application.RenderWithVisualStyles)
            {
                this.DrawTabButtonBackgroundUsingVisualStyles(g, paintParams.Bounds, paintParams.State);
            }
            else
            {
                this.DrawTabButtonBackground(g, paintParams.Bounds, paintParams.State);
            }

            Rectangle textBounds = paintParams.TextBounds;

            if (textBounds.Width > 10)
            {
                Debug.Assert(paintParams.Font != null, "tabItemParams.Font != null");
                this.DrawTabButtonText(
                    g,
                    paintParams.Text,
                    textBounds,
                    paintParams.Font,
                    paintParams.ForeColor,
                    paintParams.State != TabItemState.Disabled
                    );
            }

            Image tabItemImage = paintParams.Image;

            if (tabItemImage != null)
            {
                this.DrawTabButtonImage(
                    g,
                    tabItemImage,
                    paintParams.ImageBounds,
                    paintParams.State != TabItemState.Disabled
                    );
            }
        }
示例#3
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;

			using (SolidBrush sb = new SolidBrush(this.BackColor))
			{
				g.FillRectangle(sb, this.ClientRectangle);
			}

			NuGenTabButtonPaintParams tabItemParams = new NuGenTabButtonPaintParams(g, this.ClientRectangle);
			
			tabItemParams.Font = this.Font;
			tabItemParams.Image = this.Image;
			tabItemParams.ImageBounds = this.ImageBounds;
			tabItemParams.IsRightToLeft = this.RightToLeft == RightToLeft.Yes;
			tabItemParams.Text = this.Text;

			float textHeight = g.MeasureString(this.Text, this.Font).Height;
			
			tabItemParams.TextBounds = new Rectangle(
				this.ClientRectangle.Left + this.ImageBounds.Right + 5,
				this.ClientRectangle.Top + this.ClientRectangle.Height / 2 - (int)(textHeight / 2.0f),
				this.ClientRectangle.Width - this.ImageBounds.Width - this.CloseButton.Width - 20,
				(int)textHeight
			);

			if (!this.Enabled)
			{
				tabItemParams.State = TabItemState.Disabled;
			}
			else
			{
				switch (this.TabStateTracker.GetControlState(this))
				{
					case NuGenControlState.Hot:
					{
						tabItemParams.State = TabItemState.Hot;
						break;
					}
					case NuGenControlState.Pressed:
					{
						tabItemParams.State = TabItemState.Selected;
						break;
					}
				}
			}

			Debug.Assert(this.TabRenderer != null, "this.TabRenderer != null");
			this.TabRenderer.DrawTabButton(tabItemParams);
		}
		/*
		 * DrawTabButton
		 */

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

			Graphics g = paintParams.Graphics;
			Debug.Assert(g != null, "g != null");

			if (Application.RenderWithVisualStyles)
			{
				this.DrawTabButtonBackgroundUsingVisualStyles(g, paintParams.Bounds, paintParams.State);
			}
			else
			{
				this.DrawTabButtonBackground(g, paintParams.Bounds, paintParams.State);
			}

			Rectangle textBounds = paintParams.TextBounds;

			if (textBounds.Width > 10)
			{
				Debug.Assert(paintParams.Font != null, "tabItemParams.Font != null");
				this.DrawTabButtonText(
					g,
					paintParams.Text,
					textBounds,
					paintParams.Font,
					paintParams.ForeColor,
					paintParams.State != TabItemState.Disabled
				);
			}

			Image tabItemImage = paintParams.Image;

			if (tabItemImage != null)
			{
				this.DrawTabButtonImage(
					g,
					tabItemImage,
					paintParams.ImageBounds,
					paintParams.State != TabItemState.Disabled
				);
			}
		}