Esempio n. 1
0
        /// <summary>
        /// Handles the Click event of the solveMazeBtn control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
        private void SolveMazeBtn_Click(object sender, RoutedEventArgs e)
        {
            string name     = menuVm.VM_MazeName;
            string algoType = Properties.Settings.Default.SearchAlgorithm.ToString();

            menuVm.SolveMaze(name, algoType);
            menuVm.MovePlayerInSol();
            EndGame win = new EndGame();

            win.ShowDialog();
            this.Close();
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the KeyDown event of the Window control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            string direction = "other";

            switch (e.Key)
            {
            case Key.Up:
            {
                direction = "up";
                break;
            }

            case Key.Down:
            {
                direction = "down";
                break;
            }

            case Key.Left:
            {
                direction = "left";
                break;
            }

            case Key.Right:
            {
                direction = "right";
                break;
            }

            default:
                break;
            }
            menuVm.MovePlayer(direction);
            //if we reached to goal pos
            if (mazeBoard.CurrentPos == mazeBoard.GoalPos)
            {
                EndGame win = new EndGame();
                win.ShowDialog();
                this.Close();
            }
        }