Пример #1
0
 /** <summary> Saves as the maze design. </summary> */
 private void SaveAs(object sender, EventArgs e)
 {
     if (fileName == "")
     {
         saveFileDialog.InitialDirectory = "";
         saveFileDialog.FileName         = "Untitled";
     }
     else
     {
         saveFileDialog.InitialDirectory = Path.GetDirectoryName(fileName);
         saveFileDialog.FileName         = Path.GetFileNameWithoutExtension(fileName);
     }
     string[] errors = this.mazeEditor1.MazeErrors;
     if (errors.Length == 0)
     {
         if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
         {
             fileName = saveFileDialog.FileName;
             this.mazeEditor1.SaveMaze(maze);
             maze.Save(fileName);
             changed = false;
         }
     }
     else
     {
         ErrorMessageBox.Show(this, errors[0], errors.Length >= 2 ? errors[1] : "");
     }
 }
Пример #2
0
 /** <summary> Saves the maze design. </summary> */
 private void Save(object sender, EventArgs e)
 {
     if (fileName == "")
     {
         SaveAs(null, null);
     }
     else
     {
         string[] errors = this.mazeEditor1.MazeErrors;
         if (errors.Length == 0)
         {
             this.mazeEditor1.SaveMaze(maze);
             maze.Save(fileName);
             changed = false;
         }
         else
         {
             ErrorMessageBox.Show(this, errors[0], errors.Length >= 2 ? errors[1] : "");
         }
     }
 }
Пример #3
0
 /** <summary> Opens the maze design. </summary> */
 private void Open(object sender, EventArgs e)
 {
     if (fileName == "")
     {
         openFileDialog.InitialDirectory = "";
         openFileDialog.FileName         = "";
     }
     else
     {
         openFileDialog.InitialDirectory = Path.GetDirectoryName(fileName);
         openFileDialog.FileName         = Path.GetFileNameWithoutExtension(fileName);
     }
     if (!changed || WarningMessageBox.Show(this, "Maze has been changed.", "Are you sure you want to continue?") == DialogResult.Yes)
     {
         if (openFileDialog.ShowDialog(this) == DialogResult.OK)
         {
             try {
                 TrackDesign newMaze = TrackDesign.FromFile(openFileDialog.FileName);
                 if (newMaze.TrackType == TrackTypes.HedgeMaze)
                 {
                     fileName  = openFileDialog.FileName;
                     changed   = false;
                     this.maze = newMaze;
                     this.mazeEditor1.LoadMaze(newMaze);
                     UpdateMazeSize();
                 }
                 else
                 {
                     ErrorMessageBox.Show(this, "Failed to load maze.", "The track design is not a maze.");
                 }
             }
             catch (Exception) {
                 ErrorMessageBox.Show(this, "Failed to load maze.", "Track design may be invalid.");
             }
         }
     }
 }