SIL.FieldWorks.Common.Controls.ExplorerBarItem.m_button_Paint C# (CSharp) Method

m_button_Paint() public method

We don't want a typical looking button. Therefore, draw it ourselves.
public m_button_Paint ( object sender, PaintEventArgs e ) : void
sender object
e PaintEventArgs
return void
		void m_button_Paint(object sender, PaintEventArgs e)
		{
			DrawButtonBackground(e.Graphics);

			// Draw the item's glyph.
			DrawExpandCollapseGlyph(e.Graphics);

			Rectangle rc = m_button.ClientRectangle;

			// Draw the item's text.
			TextFormatFlags flags = TextFormatFlags.VerticalCenter |
				TextFormatFlags.EndEllipsis;

			rc.Inflate(-2, 0);
			rc.Width -= m_glyphButtonWidth;
			TextRenderer.DrawText(e.Graphics, m_button.Text, Font,
				rc, SystemColors.WindowText, flags);

			rc = m_button.ClientRectangle;

			// Draw a line separating the button area from what collapses and expands below it.
			Color clr1 = ColorHelper.CalculateColor(Color.White, SystemColors.MenuHighlight, 90);
			Point pt1 = new Point(rc.X + 1, rc.Bottom - 3);
			Point pt2 = new Point(rc.Right, rc.Bottom - 3);
			using (LinearGradientBrush br = new LinearGradientBrush(pt1, pt2,
				clr1, SystemColors.Window))
			{
				e.Graphics.DrawLine(new Pen(br, 1), pt1, pt2);
			}

			rc.Inflate(-1, -1);
			if (m_button.Focused)
				ControlPaint.DrawFocusRectangle(e.Graphics, rc);
		}