private void Tool_ImportRoom_Click(object sender, EventArgs e)
        {
            int selectedRoom = RoomListBox.Items.Count;
            OpenFileDialog input = new OpenFileDialog();
            input.CheckFileExists = true;
            input.CheckPathExists = true;
            input.AddExtension = true;
            input.DefaultExt = ".rm";
            input.Filter = "Room file (*.rm)|*.rm";
            if (DialogResult.OK == input.ShowDialog())
            {
                StreamReader inFile = new StreamReader(input.FileName.ToString());

                // Import every room
                Room newRoom = new Room();
                newRoom.x = Convert.ToInt32(inFile.ReadLine());
                newRoom.y = Convert.ToInt32(inFile.ReadLine());
                newRoom.width = Convert.ToInt32(inFile.ReadLine());
                newRoom.height = Convert.ToInt32(inFile.ReadLine());
                newRoom.backgroundID = Convert.ToInt32(inFile.ReadLine());
                newRoom.checkpoint = Convert.ToBoolean(Convert.ToInt32(inFile.ReadLine()));
                newRoom.checkpointX = Convert.ToInt32(inFile.ReadLine());
                newRoom.checkpointY = (float)Convert.ToDecimal(inFile.ReadLine());
                roomList.Add(newRoom);
                RoomListBox.Items.Add(newRoom);
                _updateRoom(-1, newRoom.x, newRoom.y, newRoom.height, newRoom.width, newRoom.checkpoint, newRoom.checkpointX, newRoom.checkpointY, newRoom.backgroundID);

                // Import every wall
                int numWallTiles = Convert.ToInt32(inFile.ReadLine());
                for (int wallIter = 0; wallIter < numWallTiles; wallIter++)
                {
                    Wall newWall = new Wall();
                    newWall.x = Convert.ToInt32(inFile.ReadLine());
                    newWall.y = Convert.ToInt32(inFile.ReadLine());
                    newWall.size = Convert.ToInt32(inFile.ReadLine());
                    newWall.horizontal = Convert.ToBoolean(Convert.ToInt32(inFile.ReadLine()));
                    roomList[selectedRoom].wallTiles.Add(newWall);
                    //WallListBox.Items.Add(newRoom.info);
                    _updateWallTile(selectedRoom, -1, newWall.x, newWall.y, newWall.horizontal, newWall.size);
                }

                // Import every light
                int numLights = Convert.ToInt32(inFile.ReadLine());
                for (int lightIter = 0; lightIter < numLights; lightIter++)
                {
                    Light newLight = new Light();
                    newLight.type = (Light.LightType)Convert.ToInt32(inFile.ReadLine());
                    newLight.x = (float)Convert.ToDecimal(inFile.ReadLine());
                    newLight.y = (float)Convert.ToDecimal(inFile.ReadLine());
                    newLight.z = (float)Convert.ToDecimal(inFile.ReadLine());
                    newLight.red = (float)Convert.ToDecimal(inFile.ReadLine());
                    newLight.green = (float)Convert.ToDecimal(inFile.ReadLine());
                    newLight.blue = (float)Convert.ToDecimal(inFile.ReadLine());
                    newLight.radius = (float)Convert.ToDecimal(inFile.ReadLine());
                    newLight.intensity = (float)Convert.ToDecimal(inFile.ReadLine());
                    roomList[selectedRoom].lights.Add(newLight);
                    //RoomLightListBox.Items.Add(newLight);
                    _updateLight(selectedRoom, -1, (int)newLight.type, newLight.x, newLight.y, newLight.z, newLight.red, newLight.green, newLight.blue, newLight.radius, newLight.intensity);
                }

                // Import every game object
                int numGameObjects = Convert.ToInt32(inFile.ReadLine());
                for (int objectIter = 0; objectIter < numGameObjects; objectIter++)
                {
                    GameObject newObject = new GameObject();
                    newObject.x = Convert.ToInt32(inFile.ReadLine());
                    newObject.y = Convert.ToInt32(inFile.ReadLine());
                    newObject.objectID = Convert.ToInt32(inFile.ReadLine());
                    newObject.rotation = Convert.ToInt32(inFile.ReadLine());
                    newObject.flag = Convert.ToInt32(inFile.ReadLine());
                    roomList[selectedRoom].objects.Add(newObject);
                    //GameObjectListBox.Items.Add(newObject);
                    _updateGameObject(selectedRoom, -1, newObject.x, newObject.y, newObject.rotation, newObject.objectID);
                }

                // Import every door
                int numDoors = Convert.ToInt32(inFile.ReadLine());
                for (int doorIter = 0; doorIter < numDoors; doorIter++)
                {
                    Door newDoor = new Door();
                    newDoor.x = Convert.ToInt32(inFile.ReadLine());
                    newDoor.y = Convert.ToInt32(inFile.ReadLine());
                    newDoor.breakable = Convert.ToBoolean(Convert.ToInt32(inFile.ReadLine()));
                    newDoor.rotation = Convert.ToInt32(inFile.ReadLine());
                    newDoor.roomID = Convert.ToInt32(inFile.ReadLine());
                    newDoor.roomX = (float)Convert.ToDecimal(inFile.ReadLine());
                    newDoor.roomY = (float)Convert.ToDecimal(inFile.ReadLine());
                    roomList[selectedRoom].doors.Add(newDoor);
                    //DoorListBox.Items.Add(newDoor.info);
                    _updateDoor(selectedRoom, -1, newDoor.roomID, newDoor.breakable, newDoor.x, newDoor.y, newDoor.roomX, newDoor.roomY, newDoor.rotation);
                }

                // Import every platform
                int numPlatforms = Convert.ToInt32(inFile.ReadLine());
                for (int platformIter = 0; platformIter < numPlatforms; platformIter++)
                {
                    MovingPlatform newPlatform = new MovingPlatform();
                    int waypointCount = Convert.ToInt32(inFile.ReadLine());
                    newPlatform.x = (float)Convert.ToDecimal(inFile.ReadLine());
                    newPlatform.y = (float)Convert.ToDecimal(inFile.ReadLine());
                    for (int waypointIter = 0; waypointIter < waypointCount - 1; waypointIter++)
                    {
                        Base newWaypoint = new Base();
                        newWaypoint.x = (float)Convert.ToDecimal(inFile.ReadLine());
                        newWaypoint.y = (float)Convert.ToDecimal(inFile.ReadLine());
                        newPlatform.waypoints.Add(newWaypoint);
                    }
                    newPlatform.rotation = Convert.ToInt32(inFile.ReadLine());
                    newPlatform.speed = Convert.ToInt32(inFile.ReadLine());
                    roomList[selectedRoom].movingPlatforms.Add(newPlatform);
                    //MovingPlatformListBox.Items.Add(newPlatform);
                    _updateMovingPlatform(selectedRoom, -1, newPlatform.x, newPlatform.y, newPlatform.endX, newPlatform.endY, newPlatform.rotation, newPlatform.speed);
                }

                // Import every
                int numEnemies = Convert.ToInt32(inFile.ReadLine());
                for (int enemyIter = 0; enemyIter < numEnemies; enemyIter++)
                {
                    Enemy newEnemy = new Enemy();
                    newEnemy.x = (float)Convert.ToDecimal(inFile.ReadLine());
                    newEnemy.y = (float)Convert.ToDecimal(inFile.ReadLine());
                    newEnemy.endX = (float)Convert.ToDecimal(inFile.ReadLine());
                    newEnemy.endY = (float)Convert.ToDecimal(inFile.ReadLine());
                    newEnemy.type = (Enemy.EnemyType)Convert.ToInt32(inFile.ReadLine());
                    newEnemy.speed = Convert.ToInt32(inFile.ReadLine());
                    roomList[selectedRoom].enemies.Add(newEnemy);
                    //EnemyListBox.Items.Add(newEnemy);
                    _updateEnemy(selectedRoom, -1, (int)newEnemy.type, newEnemy.x, newEnemy.y, newEnemy.endX, newEnemy.endY, newEnemy.speed);
                }

                // Import every BG Object
                int numBGObjects = Convert.ToInt32(inFile.ReadLine());
                for (int BGOjectIter = 0; BGOjectIter < numBGObjects; BGOjectIter++)
                {
                    BackgroundObject newBackgroundObject = new BackgroundObject();
                    newBackgroundObject.x = (float)Convert.ToDecimal(inFile.ReadLine());
                    newBackgroundObject.y = (float)Convert.ToDecimal(inFile.ReadLine());
                    newBackgroundObject.z = (float)Convert.ToDecimal(inFile.ReadLine());
                    newBackgroundObject.rotation = Convert.ToInt32(inFile.ReadLine());
                    Convert.ToInt32(inFile.ReadLine()); // quick replace. see save out for more comment
                    Convert.ToInt32(inFile.ReadLine());
                    newBackgroundObject.objectID = Convert.ToInt32(inFile.ReadLine());
                    roomList[selectedRoom].backgroundObjects.Add(newBackgroundObject);
                    //BackgroundObjectListBox.Items.Add(newBackgroundObject);
                    _updateBackgroundObject(selectedRoom, -1, newBackgroundObject.objectID, newBackgroundObject.x, newBackgroundObject.y, newBackgroundObject.z, newBackgroundObject.rotation, 0.0f, 0.0f);
                }
                int numCrushers = Convert.ToInt32(inFile.ReadLine());
                for (int objectIter = 0; objectIter < numCrushers; objectIter++)
                {
                    Crusher newCrusher = new Crusher();
                    newCrusher.x = (float)Convert.ToDecimal(inFile.ReadLine());
                    newCrusher.y = (float)Convert.ToDecimal(inFile.ReadLine());
                    newCrusher.z = (float)Convert.ToDecimal(inFile.ReadLine());
                    newCrusher.height = (float)Convert.ToDecimal(inFile.ReadLine());
                    newCrusher.speed = (float)Convert.ToDecimal(inFile.ReadLine());
                    roomList[selectedRoom].crushers.Add(newCrusher);
                    //CrusherListBox.Items.Add(newCrusher);
                    _updateCrusher(selectedRoom, -1, newCrusher.x, newCrusher.y, newCrusher.z, newCrusher.height, newCrusher.speed);
                }
                //
                int numLasers = Convert.ToInt32(inFile.ReadLine());
                for (int objectIter = 0; objectIter < numLasers; objectIter++)
                {
                    Laser newLaser = new Laser();
                    newLaser.x = (float)Convert.ToDecimal(inFile.ReadLine());
                    newLaser.y = (float)Convert.ToDecimal(inFile.ReadLine());
                    newLaser.z = (float)Convert.ToDecimal(inFile.ReadLine());
                    newLaser.length = (float)Convert.ToDecimal(inFile.ReadLine());
                    newLaser.timeOn = (float)Convert.ToDecimal(inFile.ReadLine());
                    newLaser.timeOff = (float)Convert.ToDecimal(inFile.ReadLine());
                    newLaser.horizontal = Convert.ToBoolean(Convert.ToInt32(inFile.ReadLine()));
                    roomList[selectedRoom].lasers.Add(newLaser);
                    //LaserListBox.Items.Add(newLaser);
                    _updateLaser(selectedRoom, -1, newLaser.horizontal, newLaser.x, newLaser.y, newLaser.z, newLaser.length, newLaser.timeOn, newLaser.timeOff);
                }
                //
                int numPickups = Convert.ToInt32(inFile.ReadLine());
                for (int objectIter = 0; objectIter < numPickups; objectIter++)
                {
                    Pickup newPickup = new Pickup();
                    newPickup.x = (float)Convert.ToDecimal(inFile.ReadLine());
                    newPickup.y = (float)Convert.ToDecimal(inFile.ReadLine());
                    newPickup.z = (float)Convert.ToDecimal(inFile.ReadLine());
                    newPickup.type = (Pickup.PickupTypes)Convert.ToInt32(inFile.ReadLine());
                    roomList[selectedRoom].pickups.Add(newPickup);
                    //PickupListBox.Items.Add(newPickup);
                    _updatePickup(selectedRoom, -1, newPickup.x, newPickup.y, newPickup.z, (int)newPickup.type);
                }
                int numFans = Convert.ToInt32(inFile.ReadLine());
                for (int objectIter = 0; objectIter < numFans; objectIter++)
                {
                    WindFan newFan = new WindFan();
                    newFan.x = (float)Convert.ToDecimal(inFile.ReadLine());
                    newFan.y = (float)Convert.ToDecimal(inFile.ReadLine());
                    newFan.z = (float)Convert.ToDecimal(inFile.ReadLine());
                    newFan.rotation = (float)Convert.ToDecimal(inFile.ReadLine());
                    newFan.speed = (float)Convert.ToDecimal(inFile.ReadLine());
                    newFan.length = (float)Convert.ToDecimal(inFile.ReadLine());
                    roomList[selectedRoom].windFans.Add(newFan);
                    //WindFanListBox.Items.Add(newFan);
                    _updateWindFan(selectedRoom, -1, newFan.x, newFan.y, newFan.z, newFan.rotation, newFan.length, newFan.speed);
                }
                inFile.Close();
            }
        }
 private void AddWallButton_Click(object sender, EventArgs e)
 {
     // If not valid index return
     int selectedRoom = RoomListBox.SelectedIndex;
     if (selectedRoom == -1)
         return;
     // Create a new light
     Wall newWall = new Wall();
     // Add to C#
     roomList[selectedRoom].wallTiles.Add(newWall);
     // Add to list box
     WallListBox.Items.Add(newWall);
     // Add to C++
     _updateWallTile(selectedRoom, -1, newWall.x, newWall.y, newWall.horizontal, newWall.size);
 }