Exemplo n.º 1
0
 /** <summary> Creates a new maze design. </summary> */
 private void New(object sender, EventArgs e)
 {
     if (!changed || WarningMessageBox.Show(this, "Maze has been changed.", "Are you sure you want to continue?") == DialogResult.Yes)
     {
         maze           = CreateNewMaze();
         maze.TrackType = TrackTypes.HedgeMaze;
         mazeEditor1.LoadMaze(maze);
         mazeEditor1.ResizeMaze(new Size(10, 10));
         changed  = false;
         fileName = "";
     }
 }
Exemplo n.º 2
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.");
             }
         }
     }
 }
 public static DialogResult Show(Form parent, string text1, string text2)
 {
     using (var form = new WarningMessageBox(text1, text2)) {
         return(form.ShowDialog(parent));
     }
 }