public override void Paint(Graphics g) { base.Paint(g); if (m_pressed.Value) { m_drawPressed(Area, g); } else if (m_hovered.Value) { m_drawHovered(Area, g); } else { m_drawNeutral(Area, g); } if (m_text != null) { using (var textRenderer = new NativeTextRenderer(g)) { string text = m_text(); Size textSize = textRenderer.MeasureString(text, m_font); int offset = m_pressed.Value ? 1 : 0; PointF textLocation = new PointF((Area.Width - textSize.Width) / 2 + offset, (Area.Height - textSize.Height) / 2 + offset); textRenderer.DrawString(text, m_font, Color.White, textLocation.Round()); } } }