コード例 #1
0
 private void ControlButtonVisible()
 {
     if (mazeRepo.Count() > 0)
     {
         btnEditMaze.IsEnabled   = true;
         btnDeleteMaze.IsEnabled = true;
         btnLearn.IsEnabled      = true;
         //btnPlay.IsEnabled = true;
     }
     else
     {
         btnEditMaze.IsEnabled   = false;
         btnDeleteMaze.IsEnabled = false;
         btnLearn.IsEnabled      = false;
         //btnPlay.IsEnabled = false;
     }
 }
コード例 #2
0
        public MazeCreator(int mazeId = -1)
        {
            InitializeComponent();

            var repo = new MazeRepo();

            if (mazeId != -1) //we are editing the maze
            {
                generated = false;
                MazeId    = mazeId;
                editMode  = true;

                ResetGrid();
                var mazeToEdit = repo.GetByID(mazeId);
                width  = mazeToEdit.Width;
                height = mazeToEdit.Height;
                generator.GoalLocation          = mazeToEdit.GoalPosition;
                generator.StartingPosition      = mazeToEdit.StartingPosition;
                generator.TheMazeGrid           = mazeToEdit.Grid;
                generator.PerfectGameMovesCount = mazeToEdit.PerfectGameMovesCount;

                mazeName             = mazeToEdit.Name;
                txtBoxHeight.Text    = height.ToString();
                txtBoxWidth.Text     = width.ToString();
                txtBoxMazeName.Text  = mazeToEdit.Name;
                lblMoveCount.Content = $"Perfect Move Count: {mazeToEdit.PerfectGameMovesCount}";
                this.Title           = $"Maze Designer Editing {mazeToEdit.Name}";

                initializeGrid(mazeGrid, width, height);
                generateMaze(mazeGrid);
            }
            else
            {
                editMode = false;
                ResetGrid();
                //initialize the grid with all the blocks
                initializeGrid(mazeGrid, width, height);
                //build the maze
                generator.Generate(width, height);
                //Generate the maze in the UI
                generateMaze(mazeGrid);
                int mazeCount = repo.Count();
                txtBoxMazeName.Text = $"New Maze({mazeCount + 1})";
                generated           = true;
            }
        }