protected override void OnPaintBackground(PaintEventArgs pevent) { //Simulate Transparency var g = pevent.Graphics.BeginContainer(); var translateRect = Bounds; pevent.Graphics.TranslateTransform(-Left, -Top); var pe = new PaintEventArgs(pevent.Graphics, translateRect); InvokePaintBackground(Parent, pe); InvokePaint(Parent, pe); pevent.Graphics.ResetTransform(); pevent.Graphics.EndContainer(g); pevent.Graphics.SmoothingMode = SmoothingMode.AntiAlias; var dp = GetPaintPattern(ButtonState); var path = new GraphicsPath(); path.AddRoundedRectPath(Squeeze(pevent.ClipRectangle), new Size(CornerRadius, CornerRadius), RoundCorners); //Draw the Button Background pevent.Graphics.FillPath(dp.Fill, path); //...and border pevent.Graphics.DrawPath(dp.Line, path); // Get the Rectangle to be used for Content var xy = Math.Max(Convert.ToSingle(CornerRadius - (CornerRadius / Math.Sqrt(2))), pad); contentRect = RectangleF.Inflate(pevent.ClipRectangle, -xy, -xy); }
public void Draw(CommandLink ctrl, PushButtonState state, PaintEventArgs e) { var m = new Measurements(ctrl, state, e.Graphics); e.Graphics.Clear(ctrl.Parent.BackColor); var gp = new GraphicsPath(); gp.AddRoundedRectPath(m.client, new Size(rndRectRadius, rndRectRadius)); e.Graphics.FillPath(m.dp.Fill, gp); e.Graphics.DrawPath(m.dp.Line, gp); e.Graphics.DrawImage(m.img, m.imgRect); TextRenderer.DrawText(e.Graphics, ctrl.Text, largeFont, m.txtRect, m.dp.Text, m.tff); if (m.noteRect.Size != SizeF.Empty) { TextRenderer.DrawText(e.Graphics, ctrl.NoteText, smallFont, m.noteRect, m.dp.Text, m.tff); } }