Exemplo n.º 1
0
        /// <summary>
        /// Opens a windows with text and two buttons. The text content is "message",
        /// the first button content is "firstButton" and the second button content
        /// is "secondButton".
        /// One button closes the program. The other close the window and opens the main
        /// window(starting window).
        /// </summary>
        /// <param name="message"> The text from above. </param>
        /// <param name="firstButton"> The content from above. </param>
        /// <param name="secondButton"> The content from above. </param>
        private void GameEnded(string message, string firstButton, string secondButton)
        {
            MudalWindow window = new MudalWindow()
            {
                //Set data context.
                DataContext = this
            };

            MudalMessage      = message;
            MudalFirstButton  = firstButton;
            MudalSecondButton = secondButton;
            //Set methods that will run for each button.
            window.OnFirstButton = new RoutedEventHandler((object sender, RoutedEventArgs args) =>
            {
                //Return to main menu.
                MainWindow mainWindow = new MainWindow();
                mainWindow.Show();
                //Close mudal window.
                window.Close();
            });

            window.OnSecondButton = new RoutedEventHandler((object sender, RoutedEventArgs args) =>
            {
                //Close the window.
                window.Close();
            });
            try
            {
                Done();
            } catch (NullReferenceException) { }
            window.Show();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Restart the game.
        /// </summary>
        public void Restart()
        {
            MudalWindow win = new MudalWindow();

            win.DataContext   = this;
            MudalMessage      = "Are you sure?";
            MudalFirstButton  = "Continue";
            MudalSecondButton = "Cancel";
            win.OnFirstButton = new RoutedEventHandler((object sender, RoutedEventArgs args) =>
            {
                board.RestartGame();
                win.Close();
            });

            //Don't do anything if cancel is chosen.
            win.OnSecondButton = new RoutedEventHandler((object sender, RoutedEventArgs args) => {
                win.Close();
            });
            win.Show();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Activate animation that solves the maze.
        /// </summary>
        /// <param name="solution"></param>
        public void Solve(string solution)
        {
            MudalWindow win = new MudalWindow();

            win.DataContext   = this;
            MudalMessage      = "Are you sure?";
            MudalFirstButton  = "Continue";
            MudalSecondButton = "Cancel";
            win.OnFirstButton = new RoutedEventHandler((object sender, RoutedEventArgs args) =>
            {
                //Return to start point of maze.
                board.RestartGame();
                board.AnimateSolution(solution);
                win.Close();
            });

            //Don't do anything if cancel is chosen.
            win.OnSecondButton = new RoutedEventHandler((object sender, RoutedEventArgs args) => {
                win.Close();
            });
            win.Show();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Opens a mudali window that asks the user if his sure and offers two
        /// choice buttons. One will close this window and open a MainWindow intance,
        /// the other closes the mudali window.
        /// </summary>
        /// <param name="sender"> Irrelevant. </param>
        /// <param name="e"> Irrelevant. </param>
        private void MainMenuClick(object sender, RoutedEventArgs e)
        {
            MudalWindow win = new MudalWindow()
            {
                DataContext = maze
            };

            maze.MudalMessage      = "Are you sure?";
            maze.MudalFirstButton  = "Continue";
            maze.MudalSecondButton = "Cancel";
            win.OnFirstButton      = new RoutedEventHandler((object send, RoutedEventArgs args) =>
            {
                MainWindow window = new MainWindow();
                window.Show();
                this.Close();
                win.Close();
            });

            //Don't do anything if cancel is chosen.
            win.OnSecondButton = new RoutedEventHandler((object send, RoutedEventArgs args) => {
                win.Close();
            });
            win.Show();
        }