示例#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();
        }
 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();
 }
 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;
     }
 }
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     this.windowMainWindow = ((Tehtava5.MainWindow)(target));
     return;
     case 2:
     this.lblId = ((System.Windows.Controls.Label)(target));
     return;
     case 3:
     this.txtBoxId = ((System.Windows.Controls.TextBox)(target));
     
     #line 12 "..\..\MainWindow.xaml"
     this.txtBoxId.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.textBox_TextChanged);
     
     #line default
     #line hidden
     return;
     case 4:
     this.btnRetrieveDataTable = ((System.Windows.Controls.Button)(target));
     
     #line 13 "..\..\MainWindow.xaml"
     this.btnRetrieveDataTable.Click += new System.Windows.RoutedEventHandler(this.btnRetrieveDataTable_Click);
     
     #line default
     #line hidden
     return;
     case 5:
     this.btnRetrieveDataView = ((System.Windows.Controls.Button)(target));
     
     #line 14 "..\..\MainWindow.xaml"
     this.btnRetrieveDataView.Click += new System.Windows.RoutedEventHandler(this.btnRetrieveDataView_Click);
     
     #line default
     #line hidden
     return;
     case 6:
     this.btnRetrieveTypedDataSet = ((System.Windows.Controls.Button)(target));
     
     #line 15 "..\..\MainWindow.xaml"
     this.btnRetrieveTypedDataSet.Click += new System.Windows.RoutedEventHandler(this.btnRetrieveTypedDataSet_Click);
     
     #line default
     #line hidden
     return;
     case 7:
     this.dataGrid = ((System.Windows.Controls.DataGrid)(target));
     return;
     }
     this._contentLoaded = true;
 }