I have a custom user control with a picture box on it. Then, draw a circle on the control in Paint
event.
var size = TextRenderer.MeasureText(this.UnreadCount.ToString(), lblDisplayname.Font);
var rec = new Rectangle(0, 0, size.Width, size.Width);
var smallFont = new Font(lblDisplayname.Font.Name, lblDisplayname.Font.Size - 1);
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
format.FormatFlags = StringFormatFlags.DirectionRightToLeft;
format.LineAlignment = StringAlignment.Center;
using (LinearGradientBrush b = new LinearGradientBrush(
rec,
Color.FromArgb(242, 37, 37),
Color.FromArgb(178, 30, 30),
45F))
{
e.Graphics.FillEllipse(b, rec);
e.Graphics.DrawString(this.UnreadCount.ToString(), smallFont, Brushes.White, rec, format);
}
Then, later in the implementation, I set the image of the control's picture box.
MyControl ctrl = new MyControl();
ctrl.picImage.Image = Image.FromFile(imagePath);
ctrl.Refresh();
The issue is that: the picture box's image overlap the drawn circle. current issue Requirement is that: The circle is needed to display fully overlapping the image. What might be causing my issue?