private void glRoomView_MouseDown(object sender, MouseEventArgs e)
{
// First, get the coordinate of the click
Point clickPt = glRoomView.PointToClient(MousePosition);
clickPt.Y = glRoomView.Height - clickPt.Y; // Convert ref from upper left corner to lower left
// Clear previous selection
selectedSpr = null;
selectedObj = null;
// Check if the point is inside
foreach (GameObject obj in currentRoom.Objects.Values)
{
if (obj.IsInside(clickPt))
{
// Select the object for editing
selectedSpr = obj.sprite;
selectedObj = obj;
// Store the original position of the object before moving it
// so that the dictionaries can be accessed and updated
originalPos = new Vector3(selectedObj.getMinX(), selectedObj.getMinY(), selectedObj.depth);
// Display selected object's data in Room Viewer
txtXPos.Text = obj.getMinX().ToString();
txtYPos.Text = obj.getMinY().ToString();
mouseDown = true;
// Redraw so user can see selected object
glRoomView.Invalidate();
glRoomView.Update();
// break out to avoid conflicts
break;
}
}
}