Ejemplo n.º 1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["connectionString"]);
            AttendanceMapper mapper = new AttendanceMapper(connection);
            AttendanceService service = new AttendanceService(mapper);

            MainWindow view = new MainWindow(service);
            view.Show();
        }
Ejemplo n.º 2
0
 private void GameOver()
 {
     timer.Stop();
     timer = null;
     MessageBox.Show("Peli ohi! Sait " + score + " pistettä.");
     MainWindow main = new MainWindow();
     Application.Current.MainWindow = main;
     this.Close();
     main.Show();
 }
Ejemplo n.º 3
0
 private void KeyPressed(object sender, KeyEventArgs e)
 {
     switch (e.Key)
     {
         // Exit to main menu
         case Key.Escape:
             {
                 timer.Stop();
                 timer = null;
                 MainWindow main = new MainWindow();
                 Application.Current.MainWindow = main;
                 this.Close();
                 main.Show();
             }
             break;
         // Pause / Unpause
         case Key.P:
             {
                 if (timer.IsEnabled)
                 {
                     timer.Stop();
                     this.Title = "Paused";
                 }
                 else
                 {
                     timer.Start();
                     this.Title = "Bonus points: " + score.ToString();
                 }
             }
             break;
         case Key.Up:
             {
                 if (snake.Direction != (int)MovementDirection.Down)
                     snake.Direction = (int)MovementDirection.Up;
             }
             break;
         case Key.Down:
             {
                 if (snake.Direction != (int)MovementDirection.Up)
                     snake.Direction = (int)MovementDirection.Down;
             }
             break;
         case Key.Left:
             {
                 if (snake.Direction != (int)MovementDirection.Right)
                     snake.Direction = (int)MovementDirection.Left;
             }
             break;
         case Key.Right:
             {
                 if (snake.Direction != (int)MovementDirection.Left)
                     snake.Direction = (int)MovementDirection.Right;
             }
             break;
         default: { } break;
     }
 }
Ejemplo n.º 4
0
        private void KeyPressed(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
            // Exit to main menu
            case Key.Escape:
            {
                timer.Stop();
                timer = null;
                MainWindow main = new MainWindow();
                Application.Current.MainWindow = main;
                this.Close();
                main.Show();
            }
            break;

            // Pause / Unpause
            case Key.P:
            {
                if (timer.IsEnabled)
                {
                    timer.Stop();
                    this.Title = "Paused";
                }
                else
                {
                    timer.Start();
                    this.Title = "Bonus points: " + score.ToString();
                }
            }
            break;

            case Key.Up:
            {
                if (snake.Direction != (int)MovementDirection.Down)
                {
                    snake.Direction = (int)MovementDirection.Up;
                }
            }
            break;

            case Key.Down:
            {
                if (snake.Direction != (int)MovementDirection.Up)
                {
                    snake.Direction = (int)MovementDirection.Down;
                }
            }
            break;

            case Key.Left:
            {
                if (snake.Direction != (int)MovementDirection.Right)
                {
                    snake.Direction = (int)MovementDirection.Left;
                }
            }
            break;

            case Key.Right:
            {
                if (snake.Direction != (int)MovementDirection.Left)
                {
                    snake.Direction = (int)MovementDirection.Right;
                }
            }
            break;

            default: { } break;
            }
        }