System.Windows.Forms.ToolStripLabel.OnPaint C# (CSharp) Method

OnPaint() protected method

protected OnPaint ( System e ) : void
e System
return void
		protected override void OnPaint (System.Windows.Forms.PaintEventArgs e)
		{
			if (this.Owner != null) {
				Color font_color = this.Enabled ? this.ForeColor : SystemColors.GrayText;
				Image draw_image = this.Enabled ? this.Image : ToolStripRenderer.CreateDisabledImage (this.Image);

				this.Owner.Renderer.DrawLabelBackground (new System.Windows.Forms.ToolStripItemRenderEventArgs (e.Graphics, this));

				Rectangle text_layout_rect;
				Rectangle image_layout_rect;

				this.CalculateTextAndImageRectangles (out text_layout_rect, out image_layout_rect);

				if (this.IsOnDropDown) {
					if (this.ShowMargin)
						text_layout_rect = new Rectangle (35, text_layout_rect.Top, text_layout_rect.Width, text_layout_rect.Height);
					else
						text_layout_rect = new Rectangle (7, text_layout_rect.Top, text_layout_rect.Width, text_layout_rect.Height);
					if (image_layout_rect != Rectangle.Empty)
						image_layout_rect = new Rectangle (new Point (4, 3), base.GetImageSize ());
				}

				if (image_layout_rect != Rectangle.Empty)
					this.Owner.Renderer.DrawItemImage (new System.Windows.Forms.ToolStripItemImageRenderEventArgs (e.Graphics, this, draw_image, image_layout_rect));
				if (text_layout_rect != Rectangle.Empty)
					if (this.is_link) {
						if (this.Pressed)		// Mouse Down
						{
							switch (this.link_behavior) {
								case LinkBehavior.SystemDefault:
								case LinkBehavior.AlwaysUnderline:
								case LinkBehavior.HoverUnderline:
									this.Owner.Renderer.DrawItemText (new System.Windows.Forms.ToolStripItemTextRenderEventArgs (e.Graphics, this, this.Text, text_layout_rect, this.active_link_color, new Font (this.Font, FontStyle.Underline), this.TextAlign));
									break;
								case LinkBehavior.NeverUnderline:
									this.Owner.Renderer.DrawItemText (new System.Windows.Forms.ToolStripItemTextRenderEventArgs (e.Graphics, this, this.Text, text_layout_rect, this.active_link_color, this.Font, this.TextAlign));
									break;
							}
						}
						else if (this.Selected)		// Hover
						{
							switch (this.link_behavior) {
								case LinkBehavior.SystemDefault:
								case LinkBehavior.AlwaysUnderline:
								case LinkBehavior.HoverUnderline:
									this.Owner.Renderer.DrawItemText (new System.Windows.Forms.ToolStripItemTextRenderEventArgs (e.Graphics, this, this.Text, text_layout_rect, this.link_color, new Font (this.Font, FontStyle.Underline), this.TextAlign));
									break;
								case LinkBehavior.NeverUnderline:
									this.Owner.Renderer.DrawItemText (new System.Windows.Forms.ToolStripItemTextRenderEventArgs (e.Graphics, this, this.Text, text_layout_rect, this.link_color, this.Font, this.TextAlign));
									break;
							}
						}
						else {

							if (this.link_visited)		// Normal, Visited
							{
								switch (this.link_behavior) {
									case LinkBehavior.SystemDefault:
									case LinkBehavior.AlwaysUnderline:
										this.Owner.Renderer.DrawItemText (new System.Windows.Forms.ToolStripItemTextRenderEventArgs (e.Graphics, this, this.Text, text_layout_rect, this.visited_link_color, new Font (this.Font, FontStyle.Underline), this.TextAlign));
										break;
									case LinkBehavior.NeverUnderline:
									case LinkBehavior.HoverUnderline:
										this.Owner.Renderer.DrawItemText (new System.Windows.Forms.ToolStripItemTextRenderEventArgs (e.Graphics, this, this.Text, text_layout_rect, this.visited_link_color, this.Font, this.TextAlign));
										break;
								}
							}
							else				// Normal
							{
								switch (this.link_behavior) {
									case LinkBehavior.SystemDefault:
									case LinkBehavior.AlwaysUnderline:
										this.Owner.Renderer.DrawItemText (new System.Windows.Forms.ToolStripItemTextRenderEventArgs (e.Graphics, this, this.Text, text_layout_rect, this.link_color, new Font (this.Font, FontStyle.Underline), this.TextAlign));
										break;
									case LinkBehavior.NeverUnderline:
									case LinkBehavior.HoverUnderline:
										this.Owner.Renderer.DrawItemText (new System.Windows.Forms.ToolStripItemTextRenderEventArgs (e.Graphics, this, this.Text, text_layout_rect, this.link_color, this.Font, this.TextAlign));
										break;
								}

							}
						}
					} else
						this.Owner.Renderer.DrawItemText (new System.Windows.Forms.ToolStripItemTextRenderEventArgs (e.Graphics, this, this.Text, text_layout_rect, font_color, this.Font, this.TextAlign));
			}

			// call Paint handlers last.
			base.OnPaint (e);
		}