private void DrawText(Graphics g, string text) { if (ShowPercentageText) { TextRenderer.DrawText(g, text, Font, ClientRectangle.LocationOffset(0, 1), Color.Black, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); TextRenderer.DrawText(g, text, Font, ClientRectangle, ForeColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter); } }
private void DrawText(Graphics g) { TextFormatFlags tff; switch (TextAlign) { case ContentAlignment.TopLeft: tff = TextFormatFlags.Top | TextFormatFlags.Left; break; case ContentAlignment.MiddleLeft: tff = TextFormatFlags.VerticalCenter | TextFormatFlags.Left; break; case ContentAlignment.BottomLeft: tff = TextFormatFlags.Bottom | TextFormatFlags.Left; break; case ContentAlignment.TopCenter: tff = TextFormatFlags.Top | TextFormatFlags.HorizontalCenter; break; default: case ContentAlignment.MiddleCenter: tff = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter; break; case ContentAlignment.BottomCenter: tff = TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter; break; case ContentAlignment.TopRight: tff = TextFormatFlags.Top | TextFormatFlags.Right; break; case ContentAlignment.MiddleRight: tff = TextFormatFlags.VerticalCenter | TextFormatFlags.Right; break; case ContentAlignment.BottomRight: tff = TextFormatFlags.Bottom | TextFormatFlags.Right; break; } if (AutoEllipsis) { tff |= TextFormatFlags.EndEllipsis; } if (TextShadowColor.A > 0) { TextRenderer.DrawText(g, Text, Font, ClientRectangle.LocationOffset(0, 1), TextShadowColor, tff); } TextRenderer.DrawText(g, Text, Font, ClientRectangle, ForeColor, tff); }