/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void OnPaint(PaintEventArgs e)
		{
			base.OnPaintBackground(e);

			if (m_fParentIsToolstrip)
			{
				PaintOnToolbar(e);
				return;
			}

			if (!Application.RenderWithVisualStyles)
				ControlPaint.DrawBorder3D(e.Graphics, ClientRectangle, Border3DStyle.Sunken);
			else
			{
				VisualStyleRenderer renderer;

				renderer = new VisualStyleRenderer(Enabled ?
					VisualStyleElement.TextBox.TextEdit.Normal :
					VisualStyleElement.TextBox.TextEdit.Disabled);

				renderer.DrawBackground(e.Graphics, ClientRectangle, e.ClipRectangle);

				// When the textbox background is drawn in normal mode (at least when the
				// theme is one of the standard XP themes), it's drawn with a white background
				// and not the System Window background color. Therefore, we need to create
				// a rectangle that doesn't include the border. Then fill it with the text
				// box's background color.
				Rectangle rc = renderer.GetBackgroundExtent(e.Graphics, ClientRectangle);
				int dx = (rc.Width - ClientRectangle.Width) / 2;
				int dy = (rc.Height - ClientRectangle.Height) / 2;
				rc = ClientRectangle;
				rc.Inflate(-dx, -dy);

				using (SolidBrush br = new SolidBrush(txtScrRef.BackColor))
					e.Graphics.FillRectangle(br, rc);
			}
		}
Exemple #2
0
			public SizeF method_0(string text)
			{
				SizeF result;
				using (var graphics = CreateGraphics())
				{
					var normal = VisualStyleElement.ToolTip.Standard.Normal;
					if (Application.RenderWithVisualStyles && VisualStyleRenderer.IsElementDefined(normal))
					{
						var renderer = new VisualStyleRenderer(normal);
						var textExtent = renderer.GetTextExtent(graphics, text, TextFormatFlags.Default);
						result = renderer.GetBackgroundExtent(graphics, textExtent).Size;
					}
					else
					{
						SizeF sizeF = TextRenderer.MeasureText(graphics, text, Font, new Size(SystemInformation.PrimaryMonitorSize.Width, 2147483647), _tfFlags);
						sizeF.Width -= 2f;
						sizeF.Height += 2f;
						result = sizeF;
					}
				}
				return result;
			}