Example #1
0
        private void RecreateRegion()
        {
            var bounds = new Rectangle(ClientRectangle.Location, ClientRectangle.Size);

            Region = new Region(RoundedDrawing.RoundedRect(bounds, cornerRadius));
            Invalidate();
        }
Example #2
0
        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);
        }