private void painting_clicked_insert(MouseEventArgs e)
{
DrawPoint mouse = pb_Level.PointToClient(MousePosition);
// Remove the object under the cursor.
if (e.Button == MouseButtons.Right)
{
foreach (SpaceObject obj in currentlySelectedRoom.Objects.Reverse<SpaceObject>())
{
XnaRectangle bb = obj.getBBRelativeToWorld();
/*texture = Image.FromFile(currdir + "\\" + obj.TextureName + ".png");
if (mouse.X > obj.Position.X && mouse.X < (obj.Position.X + texture.Width) &&
mouse.Y > obj.Position.Y && mouse.Y < (obj.Position.Y + texture.Height))*/
if (bb.Contains(Conversion.PointToPoint(mouse)))
{
currentlySelectedRoom.Objects.Remove(obj);
if (obj == currentlySelectedObject)
{
currentlySelectedObject = null;
}
break;
}
}
}
// Add an object.
if (e.Button == MouseButtons.Left)
{
if (rb_Doors.Checked)
{
makeDoor(mouse);
}
else
{
object textureName = lb_TextureList.SelectedItem;
if (textureName != null)
{
texture = Image.FromFile(currdir + "\\" + textureDir + textureName.ToString());
MakeSpaceObject(textureDir + textureName.ToString(), texture, mouse);
}
}
}
}