void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.WindowGame2 = ((View.Window2)(target)); return; case 2: this.btnRobo = ((System.Windows.Controls.Button)(target)); return; case 3: this.btnContinuar = ((System.Windows.Controls.Button)(target)); #line 241 "..\..\Window2.xaml" this.btnContinuar.Click += new System.Windows.RoutedEventHandler(this.btnContinuar_click); #line default #line hidden return; case 4: this.btnStop = ((System.Windows.Controls.Button)(target)); #line 257 "..\..\Window2.xaml" this.btnStop.Click += new System.Windows.RoutedEventHandler(this.btnParar_click); #line default #line hidden return; case 5: this.btnRanking = ((System.Windows.Controls.Button)(target)); #line 273 "..\..\Window2.xaml" this.btnRanking.Click += new System.Windows.RoutedEventHandler(this.btnRanking_click); #line default #line hidden return; case 6: this.pbUsuario = ((System.Windows.Controls.ProgressBar)(target)); return; case 7: this.pbMedia = ((System.Windows.Controls.ProgressBar)(target)); return; case 8: this.lblUsuario_Copy2 = ((System.Windows.Controls.Label)(target)); return; case 9: this.label = ((System.Windows.Controls.Label)(target)); return; case 10: this.txtUsuario = ((System.Windows.Controls.TextBox)(target)); return; case 11: this.txtPontoUsuario = ((System.Windows.Controls.TextBox)(target)); return; case 12: this.txtPontoMedia = ((System.Windows.Controls.TextBox)(target)); return; } this._contentLoaded = true; }
public void Contagem() { nuvem1.Visibility = Visibility.Collapsed; nuvem2.Visibility = Visibility.Collapsed; nuvem3.Visibility = Visibility.Collapsed; DispatcherTimer timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 1); //intervalo de tempo, hora, min, segundo //timer.Tick += new EventHandler(timer_Tick); int hora = 00; int min = 00; int sec = 09; //FUNÇÃO TICK DE 1 SEGUNDO timer.Tick += (s, a) => { string tempo = Convert.ToString(hora) + ":" + Convert.ToString(min) + ":" + Convert.ToString(sec); //quando chegar em 10 segundos muda cor if (txtTime.Text == "00:10") { retTime.Fill = Brushes.Red; } if (txtTime.Text == "00:09") { retTime.Fill = Brushes.White; } if (txtTime.Text == "00:08") { retTime.Fill = Brushes.Red; } if (txtTime.Text == "00:07") { retTime.Fill = Brushes.White; } if (txtTime.Text == "00:06") { retTime.Fill = Brushes.Red; } if (txtTime.Text == "00:05") { retTime.Fill = Brushes.White; } if (txtTime.Text == "00:04") { retTime.Fill = Brushes.Red; } if (txtTime.Text == "00:03") { retTime.Fill = Brushes.White; } if (txtTime.Text == "00:02") { retTime.Fill = Brushes.Red; } if (txtTime.Text == "00:01") { retTime.Fill = Brushes.White; } //QUANDO TIMER ZERAR, FECHA TELA 1 E ABRE TELA 2 if (txtTime.Text == "00:00") { try { timer.Stop(); //realiza a contagem dos pontos // count-1: parametro para indice da jogada bll.InserirPontos(Convert.ToInt32(lblPontos.Content), count - 1); Aviso aviso = new Aviso("Pontos cadastrados!"); aviso.Show(); //abre proxima janela //envia usuario e indice da rodada Window2 janela2 = new Window2(usuario, count - 1); if (!janela2.Activate()) { janela2.Show(); } //fecha janela principal WindowGame1.Close(); } catch { //quando fechar a janela 2, inicializa janela principal WindowGame1.Initialized += WindowGame1_Initialized; } } else { txtTime.Text = Convert.ToDateTime(tempo).ToString("mm:ss"); } if (sec > 0) { sec--; } else if (sec <= 0) { min--; sec = 59; } }; timer.Start(); }