Hi All,
I'm building a C# game that will handle drag and drop of images and labels in a visual studio form, but when I drag around a component, the form takes big performance hit. For example, I have some images moving around on the form (pictureboxes) and these stop moving while I'm draging a component around. This is how I implemented the dragging:
private bool is_dragging = false;
private int click_offset_y;
private int click_offset_x;
private void label1_MouseDown(object sender, MouseEventArgs e)
{
is_dragging = true;
click_offset_x = e.X;
click_offset_y = e.Y;
}
private void label1_MouseMove(object sender, MouseEventArgs e)
{
if (is_dragging == true)
{
label1.Left = e.X + label1.Left - click_offset_x;
label1.Top = e.Y + label1.Top - click_offset_y;
}
Invalidate();
}
private void label1_MouseUp(object sender, MouseEventArgs e)
{
is_dragging = false;
}
Any help would be much appreciated.