This is more of a why doesn’t this work question. I obviously must be missing something because I cannot for the life of me figure out why calculating the width and height values give me the same static value that I started with. But when I substitute hardcoded values it works just fine. So obviously my calculations are bad but I cannot seem to figure out why. Can anyone help? If you need more info please ask.
if(objectList[selectedIndex].Selected == true)
{
//The width would be mouselocationx - objectlocationx
//The height would be mouselocationy - objectlocationy
//Off set the position so it doesnt snap to mouse location
//WHY THE *%$!! DOESNT THIS WORK!!?!?!?!?!?!?
//int width = e.X - objectList[selectedIndex].X;
//int height = e.Y - objectList[selectedIndex].Y;
//Why is this so hard??
//Point location = objectList[selectedIndex].Location;
//location.X = e.X - (e.X - objectList[selectedIndex].Location.X);
//location.Y = e.Y - (e.Y - objectList[selectedIndex].Location.Y);
objectList[selectedIndex].X = e.Location.X - 12;
objectList[selectedIndex].Y = e.Location.Y - 12;
objectLocationXLabel.Text = "OBJX: " + objectList[selectedIndex].X.ToString();
objectLocationYLabel.Text = "OBJY: " + objectList[selectedIndex].Y.ToString();
panel1.Invalidate();
}
It’s not at all clear what you want to do. But there are at least two issues with your commented code:
is equivalent to
Pointis a value type. So when you do this:locationis modified, but notobjectList[selectedIndex].Location.Edit in response to comment: I think you must determine the offset in the
MouseDownevent, store it in a member and use it inMouseMove.