private void RecreateRegion() { var bounds = new Rectangle(ClientRectangle.Location, ClientRectangle.Size); Region = new Region(RoundedDrawing.RoundedRect(bounds, cornerRadius)); Invalidate(); }
protected override void OnPaint(PaintEventArgs pevent) { base.OnPaint(pevent); Graphics g = pevent.Graphics; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; g.SmoothingMode = SmoothingMode.HighQuality; Brush brush = new SolidBrush(labelColor); RoundedDrawing.FillRoundedRectangle(g, brush, new Rectangle(0, 0, Width, Height), roundedRadius); SizeF stringSize = g.MeasureString(Text, Font); g.DrawString(Text, Font, new SolidBrush(ForeColor), (Width - stringSize.Width) / 2, (Height - stringSize.Height) / 2); }