Beispiel #1
0
 /// <summary>
 /// Closes the scene.
 /// </summary>
 public void CloseScene()
 {
     model = null;
     for (int i = pnlDraw.Controls.Count - 1; i >= 0; i--)
     {
         pnlDraw.Controls.Remove(pnlDraw.Controls[i]);
     }
     for (int i = pnlGroupFloors.Controls.Count - 1; i >= 0; i--)
     {
         pnlGroupFloors.Controls.Remove(pnlGroupFloors.Controls[i]);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Loads the scene.
        /// </summary>
        /// <param name="_other">The _other.</param>
        private void LoadScene(Scene _other)
        {
            floors = new List<Floor>();
            this.name = _other.name;
            this.floorWidth = _other.floorWidth;
            this.floorHeight = _other.floorHeight;

            foreach (Floor floor in _other.floors)
            {
                AddFloor();
                floors[floors.Count - 1] = floor;
            }
        }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Validator"/> class.
 /// </summary>
 /// <param name="_scene">The _scene.</param>
 public Validator(Scene _scene)
 {
     sceneToValidate = _scene;
 }
Beispiel #4
0
 /// <summary>
 /// Handles the Click event of the saveCloseToolStripMenuItem control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 private void saveCloseToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (CurrentModel != null)
     {
         saveToolStripMenuItem_Click(sender, e);
         view.CloseScene();
         CurrentModel = null;
     }
 }
Beispiel #5
0
            /// <summary>
            /// Handles the Click event of the newSceneToolStripMenuItem control.
            /// </summary>
            /// <param name="sender">The source of the event.</param>
            /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
            private void newSceneToolStripMenuItem_Click(object sender, EventArgs e)
            {
                if (CurrentModel != null)
                {
                    closeToolStripMenuItem_Click(sender, e);
                }
                using (SceneCreation form = new SceneCreation())
                {
                    DialogResult dialogResult = form.ShowDialog();
                    if (dialogResult == DialogResult.OK)
                    {
                        int terrainWidth = form.TerrainWidth;
                        int terrainHeight = form.TerrainHeight;
                        Tile.TileType type = form.TileType;

                        view.InitializeView(terrainWidth, terrainHeight);

                        CurrentModel = new Scene();
                        CurrentModel.name = form.SceneName;
                        CurrentModel.floorWidth = terrainWidth;
                        CurrentModel.floorHeight = terrainHeight;
                        CurrentModel.LoadFromFile(CurrentModel.name + ".xml");
                        CurrentModel.SetAllTiles(type);

                        SetAllTileViewEvents();
                    }
                }
            }
Beispiel #6
0
 /// <summary>
 /// Handles the Click event of the loadToolStripMenuItem control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 private void loadToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (CurrentModel != null)
     {
         closeToolStripMenuItem_Click(sender, e);
     }
     using (OpenFileDialog dialog = new OpenFileDialog())
     {
         try
         {
             if (dialog.ShowDialog() == DialogResult.OK)
             {
                 CurrentModel = new Scene();
                 CurrentModel.LoadFromFile(dialog.FileName);
                 view.InitializeView(CurrentModel.floorWidth, CurrentModel.floorHeight);
                 SetAllTileViewEvents();
                 CurrentModel.SetEvents();
                 CurrentModel.SelectFloor(0);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
         }
     }
 }
Beispiel #7
0
 /// <summary>
 /// Handles the Click event of the closeToolStripMenuItem control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 private void closeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (CurrentModel != null)
     {
         DialogResult result = MessageBox.Show("Voulez-vous sauvegarder avant de quitter?", "Quitter", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
         if (result == DialogResult.Yes)
         {
             saveCloseToolStripMenuItem_Click(sender, e);
         }
         if (result == DialogResult.No)
         {
             view.CloseScene();
         }
         CurrentModel = null;
     }
 }