this code draw a square and after drag it, but when I drag the object, there is a strange effect, a flicker effect, can you help me to remove it???
private int x;
private int y;
private int xscale = 150;
private int yscale = 150;
private void Aggiorna(Color colore)
{
Graphics d = panel1.CreateGraphics();
d.Clear(Color.White);
d.FillRectangle(new SolidBrush(colore), new Rectangle(x, y, xscale, yscale));
d.Dispose();
this.Invalidate(new Rectangle(x, y, xscale, yscale), false);
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
x = Convert.ToInt32(numericUpDown1.Value);
Aggiorna(Color.Red);
}
private void numericUpDown2_ValueChanged(object sender, EventArgs e)
{
y = Convert.ToInt32(numericUpDown2.Value);
Aggiorna(Color.Red);
}
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (MouseButtons == MouseButtons.Left)
{
numericUpDown1.Value = MousePosition.X - (150 / 2);
numericUpDown2.Value = MousePosition.Y - 20 - (150 / 2);
}
}
HEEEEEEEEEEELPPPP!!!!
Tags: