/// <summary>
        /// the animation of the solve maze command
        /// </summary>
        /// <param name="mazeSolvePath"></param>
        internal void SolveMazeAnimation(string mazeSolvePath)
        {
            foreach (char ch in mazeSolvePath)
            {
                Thread.Sleep(150);
                MazeBoard.Moves move = MazeBoard.Moves.Default;
                switch (ch)
                {
                case '0': move = MazeBoard.Moves.Left;
                    break;

                case '1':
                    move = MazeBoard.Moves.Right;
                    break;

                case '2':
                    move = MazeBoard.Moves.Up;
                    break;

                case '3':
                    move = MazeBoard.Moves.Down;
                    break;
                }
                MazeName.MoveAnimation(move);
            }
            this.Dispatcher.Invoke((Action)(() =>
            {
                this.Stack.IsEnabled = true;
            }));
        }
 /// <summary>
 /// event when clicking the solve maze button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void SolveMaze_Click(object sender, RoutedEventArgs e)
 {
     MazeName.Solve       = true;
     this.Stack.IsEnabled = false;
     //set the client image to start point (the point of the solve path)
     MazeName.RestartGame(sender, e);
     vm.SolveMaze();
 }
        /// <summary>
        /// event when clicking the restart game button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RestartGame_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Are you sure you want to restart?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                MazeName.RestartGame(sender, e);
            }
        }
示例#4
0
 public IHttpActionResult SolveMaze(MazeName NameParam)
 {
     try
     {
         Searcher <Position>          algorithm       = new BestFirstSearch <Position>(new StateComparerByCost <Position>());
         Solution <State <Position> > sol             = this.mazeModel.Solve(NameParam.Name, algorithm);
         MazeSolutionAdapter          solutionAdapter = new MazeSolutionAdapter(sol);
         return(Ok(JObject.Parse(solutionAdapter.ToJson(NameParam.Name))));
     }
     catch (ArgumentException)
     {
         // Content bla bla BadRequest blabla
         return(NotFound());
     }
 }
 /// <summary>
 /// event for pressing the keys
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Window_KeyDown(object sender, KeyEventArgs e)
 {
     MazeName.GridMazeBoard_KeyDown(sender, e);
 }