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;
                }
            }
        }
        private void glRoomView_DragDrop(object sender, DragEventArgs e)
        {
            // This is where we will capture the data for the gameObject dropped into the form
            // Function fires when user releases the mouse button after entering the control.

            // Receive the data
            GLControl destination = (GLControl)sender;
            String objName = (String)e.Data.GetData(typeof(String));

            Point mouseLoc = glRoomView.PointToClient(MousePosition);
            mouseLoc.Y = glRoomView.Height - mouseLoc.Y; // Convert ref from upper left corner to lower left

            // Load offsets from file
            using (BinaryReader reader = new BinaryReader(File.Open(project.Resources[objName], FileMode.Open)))
            {
                int elem;
                reader.ReadString();
                reader.ReadString();
                if (reader.ReadBoolean())
                {
                    reader.ReadInt32();
                    reader.ReadInt32();
                }
                elem = reader.ReadInt32();

                Vector2[] offsets = new Vector2[elem];

                for (int i = 0; i < elem; i++)
                {
                    offsets[i] = new Vector2(reader.ReadInt32(), reader.ReadInt32());
                }

                // Create a new GameObject
                GameObject newObj = new GameObject(objName, new Vector2(mouseLoc.X, mouseLoc.Y), offsets, new float[] { 0f, 0f, currentRoom.width, currentRoom.height });
                newObj.depth = Convert.ToSingle(txtLayer.Text); // Convert to float

                currentRoom.Objects.Add(new Vector3(mouseLoc.X, mouseLoc.Y, Convert.ToSingle(txtLayer.Text)), newObj);
                txtXPos.Text = mouseLoc.X.ToString();
                txtYPos.Text = mouseLoc.Y.ToString();
            }

            updateRenderList();

            currentRoom.Objects[new Vector3(mouseLoc.X, mouseLoc.Y, Convert.ToSingle(txtLayer.Text))].sprite.Position = new Vector3(mouseLoc.X/(float)Width, mouseLoc.Y/(float)Height, 0f);

            glRoomView.Invalidate();
            glRoomView.Update();
        }