コード例 #1
0
ファイル: Controller.cs プロジェクト: SamuelDaigle/MapEditor
            /// <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();
                    }
                }
            }
コード例 #2
0
ファイル: Controller.cs プロジェクト: SamuelDaigle/MapEditor
 /// <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);
         }
     }
 }