i have picture of mouse , and one is a background image which contains a grid( 20X20). i have a thread which move the position of mouse picture on the background image and then DrawCircle display that image in the picturebox.
now i want to create more than one thread and move more than one mouse images on the same background.For one mouse it is okay. but for 2 or more its looks like that mouse are blinking.
while they move but the movement is not look like realistic.
following is the code of DrawCircle. where p is the point where i want to display, r is the image of mouse to be displayed in picturebox with the name of pbox and bkmg is the bckground image on which all the mouses's images should be display.
any idea or solution please.
if it is not possible or not a good idea so anyone could please give me a reasonable idea for the solution other than picture box.
private delegate void DrawCircleDelegate(Point pp, Bitmap r, PictureBox pbox,Bitmap bkmg);
public void DrawCircle(Point p, Bitmap ratImage, PictureBox pbox, Bitmap bkmg)
{
if (InvokeRequired)
{
DrawCircleDelegate drwCircle = new DrawCircleDelegate((pp, r, q,s) => DrawCircle(p, ratImage, pbox,bkmg));
this.BeginInvoke(drwCircle, new object[] { p, ratImage, pbox,bkmg });
}
lock (_locker)
{
Bitmap tempbitmap = (Bitmap)bkmg.Clone ();
Graphics g = Graphics.FromImage(tempbitmap);
if (ratImage == null)
g.FillEllipse(Brushes.Green, p.X - 15, p.Y - 15, 30, 30);
else
g.DrawImage(ratImage, p.X - 15, p.Y - 15, 30, 30);
pbox.Image = tempbitmap;
}
}