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

DrawExpandCollapseGlyph() private method

Draws the expand or collapse glyph. The glyph drawn depends on the visible state of the hosted control.
private DrawExpandCollapseGlyph ( Graphics g ) : void
g System.Drawing.Graphics
return void
		private void DrawExpandCollapseGlyph(Graphics g)
		{
			// Determine the rectangle in which the expanding/collapsing button will be drawn.
			Rectangle rc = new Rectangle(0, 0, m_glyphButtonWidth, m_button.Height);
			if (RightToLeft == RightToLeft.No)
				rc.X = (m_button.ClientRectangle.Right - rc.Width);

			VisualStyleElement element;

			if (m_drawHot)
			{
				element = (m_control.Visible ?
					VisualStyleElement.ExplorerBar.NormalGroupCollapse.Hot :
					VisualStyleElement.ExplorerBar.NormalGroupExpand.Hot);
			}
			else
			{
				element = (m_control.Visible ?
					VisualStyleElement.ExplorerBar.NormalGroupCollapse.Normal :
					VisualStyleElement.ExplorerBar.NormalGroupExpand.Normal);
			}

			if (PaintingHelper.CanPaintVisualStyle(element))
			{
				VisualStyleRenderer renderer = new VisualStyleRenderer(element);
				renderer.DrawBackground(g, rc);
			}
			else
			{
				Image glyph = (m_expanded ? Properties.Resources.kimidExplorerBarCollapseGlyph :
					Properties.Resources.kimidExplorerBarEpandGlyph);

				if (RightToLeft == RightToLeft.No)
					rc.X = rc.Right - (glyph.Width + 1);

				rc.Y += (m_button.Height - glyph.Height) / 2;
				rc.Width = glyph.Width;
				rc.Height = glyph.Height;
				g.DrawImage(glyph, rc);
			}
		}