public virtual void MouseDown(MouseEventArgs e, RoomEditorState state)
{
int x = (e.X + state.ScrollOffsetX) / state.ScaleFactor;
int y = (e.Y + state.ScrollOffsetY) / state.ScaleFactor;
_selectedObject = null;
for (int i = _objectBaselines.Count - 1; i >= 0; i--)
{
RoomObject obj = _objectBaselines[i];
int width = GetSpriteWidthForGameResolution(obj.Image);
int height = GetSpriteHeightForGameResolution(obj.Image);
if ((x >= obj.StartX) && (x < obj.StartX + width) &&
(y >= obj.StartY - height) && (y < obj.StartY))
{
_selectedObject = obj;
Factory.GUIController.SetPropertyGridObject(obj);
if (e.Button == MouseButtons.Right)
{
ShowContextMenu(e, state);
}
else
if (!obj.Locked)
{
_movingObjectWithMouse = true;
_mouseOffsetX = x - obj.StartX;
_mouseOffsetY = y - obj.StartY;
}
break;
}
}
if (_selectedObject == null)
{
Factory.GUIController.SetPropertyGridObject(_room);
if (e.Button == MouseButtons.Right)
{
ShowContextMenu(e, state);
}
}
}