private void pb_Level_Paint(object sender, PaintEventArgs e)
{
if (currentState != State.NO_EDITS)
{
//Draw the background image
string background_file = currdir + "\\" +
currentlySelectedRoom.BackgroundFilename + ".png";
//System.Drawing.Image image = Image.FromFile(background_file);
//e.Graphics.DrawImage(image, 0, 0, pb_Level.Width, pb_Level.Height);
//Draw some stuff to draw around the currently selected object, if there is one
if (currentlySelectedObject != null)
{
XnaRectangle BB = currentlySelectedObject.getBBRelativeToWorld();
//First, draw a big red box around the object, with a little bit of slack around the edges.
System.Drawing.RectangleF selectionRect = new System.Drawing.RectangleF(
BB.X - EditorConstants.SELECTION_BOX_SLACK,
BB.Y - EditorConstants.SELECTION_BOX_SLACK,
BB.Width + 2 * EditorConstants.SELECTION_BOX_SLACK,
BB.Height + 2 * EditorConstants.SELECTION_BOX_SLACK
);
e.Graphics.FillRectangle(
Brushes.Red, selectionRect);
//Now, draw the actual bounding box in white.
Pen pen = new Pen(Color.White, EditorConstants.BOUNDING_BOX_WIDTH);
e.Graphics.DrawRectangle(pen, BB.X, BB.Y, BB.Width, BB.Height);
//Finally, draw the little box in the corner of the bounding box where the user
// can click to drag.
e.Graphics.FillRectangle(Brushes.White, resizeObjectBox);
}
//Now actually draw the images on the screen.
foreach (SpaceObject obj in currentlySelectedRoom.Objects)
{
if (obj is Door)
{
drawDoor((Door)obj, e);
}
else
{
drawSpaceObject(obj, e);
}
}
//Finally, if the room is the current room of the world, then draw the player, if it exists.
if (currentState == State.EDITING_WORLD && world.CurrentRoom == currentlySelectedRoom
&& world.player != null)
{
drawSpaceObject(world.player, e);
}
}
else
{
e.Graphics.FillRectangle(Brushes.Black, pb_Level.Bounds);
}
}