/// <summary> /// Apresenta mensagem de Fim do Jogo e pede para registar o score /// </summary> public void GanhouJogo() { Temporizador.Stop(); if (M_Options.SoundOnOrOFF == true) { Thread soundThread = new Thread(Sound.PlayWinning); soundThread.IsBackground = true; soundThread.Start(); } // Abre uma messabox que informa o utilizador que ganhou o jogo MessageBox.Show("Muito bem: " + GetTimeString(), "Ganhou!", MessageBoxButtons.OK, MessageBoxIcon.Information); //soundThread.Abort(); if (M_Status.PlayingWithTheOnlineBoard == true) { Server.RegistarResultado(Program.M_Grelha._Dificuldade.ToString(), Program.M_Grelha.TimerCounter.ToString(), "true", Program.M_Status.ID); //Server.RegistarResultado(Program.M_Grelha.dificuldade.ToString(), Program.M_Grelha.timerCounter.ToString(), "True", Program.M_Status.ID); } if (V_Vencedor.ShowDialog() == DialogResult.OK) { // O jogo acaba V_MineSweeperGame.Close(); } }
private void Temporizador_Tick(object sender, EventArgs e) { SegundosRestantes--; ControlesPergunta.ForEach(cp => cp.AtualizarCronometro(TimeSpan.FromSeconds(SegundosRestantes))); if (SegundosRestantes > 0) { return; } PerguntaAtual++; if (PerguntaAtual == Questoes.Count) { Temporizador.Stop(); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else { SegundosRestantes = TempoResposta; foreach (var uc in ControlesPergunta) { uc.AtualizarQuestao(Questoes[PerguntaAtual]); } } }
private void Temporizador_Tick(object sender, EventArgs e) { Temporizador.Stop(); this.Grafico.Series["ChartLinea"].Points.AddXY("SEG", 10); this.Grafico.Series["ChartLinea"].Points.AddXY("TER", 20); this.Grafico.Series["ChartLinea"].Points.AddXY("QUA", 30); this.Grafico.Series["ChartLinea"].Points.AddXY("QUI", 40); this.Grafico.Series["ChartLinea"].Points.AddXY("SEX", 50); this.Grafico.Series["ChartLinea"].Points.AddXY("SAB", 40); this.Grafico.Series["ChartLinea"].Points.AddXY("DOM", 20); }
private void Temporizador_Tick(object sender, EventArgs e) { Temporizador.Stop(); this.Grafico.Series["ChartLinea"].Points.AddXY("LUNES", 10); this.Grafico.Series["ChartLinea"].Points.AddXY("MARTES", 20); this.Grafico.Series["ChartLinea"].Points.AddXY("MIERCOLES", 30); this.Grafico.Series["ChartLinea"].Points.AddXY("JUEVES", 40); this.Grafico.Series["ChartLinea"].Points.AddXY("VIERNES", 50); this.Grafico.Series["ChartLinea"].Points.AddXY("SABADO", 40); this.Grafico.Series["ChartLinea"].Points.AddXY("DOMINGO", 20); }
private void Temporizador_Tick(object sender, EventArgs e) { Temporizador.Stop(); //for(ifn) this.Grafico.Series["ChartLinea"].Points.AddXY("Domingo", 80); this.Grafico.Series["ChartLinea"].Points.AddXY("Lunes", 10); this.Grafico.Series["ChartLinea"].Points.AddXY("Martes", 13); this.Grafico.Series["ChartLinea"].Points.AddXY("Miercoles", 54); this.Grafico.Series["ChartLinea"].Points.AddXY("Jueves", 34); this.Grafico.Series["ChartLinea"].Points.AddXY("Viernes", 60); this.Grafico.Series["ChartLinea"].Points.AddXY("Sábado", 87); }
private void Temporizador_Tick(object sender, EventArgs e) { Temporizador.Stop(); //AHI PONEMOS EL NOMBRE DE LA SERIE QUE COLOCAMOS EN LA PROPIEDAD SERIES DEL GRAFICO this.GraficoIngresos.Series["ChartLinea"].Points.AddXY("LUN", 100000); this.GraficoIngresos.Series["ChartLinea"].Points.AddXY("MAR", 50000); this.GraficoIngresos.Series["ChartLinea"].Points.AddXY("MIE", 150000); this.GraficoIngresos.Series["ChartLinea"].Points.AddXY("JUE", 300000); this.GraficoIngresos.Series["ChartLinea"].Points.AddXY("VIE", 300000); this.GraficoIngresos.Series["ChartLinea"].Points.AddXY("SAB", 50000); this.GraficoIngresos.Series["ChartLinea"].Points.AddXY("DOM", 100000); }
private void Save() { Action act; if (!guardado && !cerrando) { act = () => Title = "Autoguardando...un momento"; Dispatcher.BeginInvoke(act); ISave(NOMBREARCHIVOAUTOGUARDADO); act = () => Title = "Tareas Pendientes"; Dispatcher.BeginInvoke(act); temporizadorAutoSave.Stop(); } }
/// <summary> /// Reset ao jogo /// </summary> public void V_MineSweeperGame_AskToResetBoard() { ResetModel(); Temporizador.Stop(); Temporizador.Dispose(); Temporizador = new Timer(); SetupTimer(); V_MineSweeperGame.AtualizaNumeroMinasDisponiveis(M_Grelha.NumMinasTotal); if (Program.M_Options.ModoJogo == GameMode.Inverso) { RevealPiecesWithAdjacentMines(); } //SetupTimer(); }
private void Temporizador_Tick(object sender, EventArgs e) { int inc = 1; // incremento int tpHecho = 0, carga = 1000; // la cuenta es hasta 1000 int cuenta = Convert.ToInt32(etContador.Text) + inc; etContador.Text = Convert.ToString(cuenta); // Mostrar progreso tpHecho = (int)((float)cuenta / carga * 100); if (tpHecho > bpCuenta.Value) { bpCuenta.Value = tpHecho; } if (cuenta == carga) { Temporizador.Stop(); } }
/// <summary> /// <para>Temporizador</para> /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Temporizador_Tick(object sender, EventArgs e) { try { if (progressBarBorde.Value >= 100) { Temporizador.Stop(); Login login = new Login(configuracionActual); //Login login = new Login(); this.Hide(); login.Show(); } else { progressBarBorde.Value += 1; ProcesarTexto(); } } catch (Exception) { return; } }
private void Temporizador_Tick(object sender, EventArgs e) { Temporizador.Stop(); }
private void button1_Click(object sender, EventArgs e) { Temporizador.Stop(); }
//-----------------Eventos ui-------------------// //Inicia los temporizadores con los valores introducidos en los campos de texto. private void Comenzar_click(object sender, RoutedEventArgs e) { bool tiempoProductivoValido = EsValido(TiempoProductivomTextBox.Text); bool tiempoDescansoValido = EsValido(TiempoDescansomTextBox.Text); bloque.ResetBloque(); if (temporizador.Enabled()) { temporizador.Stop(); } if (TemporizadorGrafico.IsEnabled()) { TemporizadorGrafico.StopTemporizador(); } if (tiempoProductivoValido && tiempoDescansoValido) { bloque.MinutosProductivos = Int32.Parse(TiempoProductivomTextBox.Text); bloque.MinutosDescanso = Int32.Parse(TiempoDescansomTextBox.Text); //Setup hora temporizador grafico if (!bloque.ProductivoCumplido) { if (bloque.MinutosProductivos >= 60) { TemporizadorGrafico.Hora = (int)Math.Floor((decimal)(bloque.MinutosProductivos / 60)); } else { TemporizadorGrafico.Hora = 0; } TemporizadorGrafico.Minuto = bloque.MinutosProductivos % 60; } else { if (bloque.MinutosDescanso >= 60) { TemporizadorGrafico.Hora = (int)Math.Floor((decimal)(bloque.MinutosDescanso / 60)); } else { TemporizadorGrafico.Hora = 0; } TemporizadorGrafico.Minuto = bloque.MinutosDescanso % 60; } //Setup temporizador if (!bloque.ProductivoCumplido) { temporizador.Minutos = bloque.MinutosProductivos; } else { temporizador.Minutos = bloque.MinutosDescanso; } (sender as Button).IsEnabled = false; (sender as Button).Visibility = Visibility.Hidden; temporizador.Start(); TemporizadorGrafico.StartTemporizador(); bloque.EstadoBloque = (int)Clases.Estado.Productivo; this.Dispatcher.Invoke(ActualizarLabelEstado); PausaContBtn.IsEnabled = true; PausaContBtn.Visibility = Visibility.Visible; PausaContBtn.ToolTip = "Pausar el contador"; DetenerBtn.IsEnabled = true; DetenerBtn.Visibility = Visibility.Visible; TiempoProductivomTextBox.IsEnabled = false; TiempoDescansomTextBox.IsEnabled = false; } else { if (!tiempoProductivoValido) { ErrorProd.Visibility = Visibility.Visible; PreviewLblTiempoProd.Content = ""; } if (!tiempoDescansoValido) { ErrorDesc.Visibility = Visibility.Visible; PreviewLblTiempoDesc.Content = ""; } } }
/// <summary> /// Tratamento do evento clicar no botão, a função vai desencadear o fucionamento do jogo consoante o modo de jogo (Modo Normal ou Inverso). /// Faz o tratamento do botão esquerdo assim como do botão direito. /// </summary> /// <param name="sender">Botão</param> /// <param name="e">Foi premido rato esquerdo ou direito</param> public void OnButtonClicked(object sender, MouseEventArgs e) { // Se o Jogador se encontra a jogar no Modo normal, os botões funcionam desta maneira... if (Program.M_Options.ModoJogo == GameMode.Normal) { // Botão esquerdo, abre espaço if (e.Button == MouseButtons.Left) { Temporizador.Start(); //// Obter Botão premido e guardar var botaoAtual = (sender as Button); // Obtém as Coordenadas do Tile GetCoordinates(botaoAtual, out int x, out int y); Tile currentTile = GetTile(new System.Drawing.Point(x, y)); if (currentTile.TemMina == true) { // Jogo perdido Temporizador.Stop(); V_MineSweeperGame.ChangeButtonBackGround(botaoAtual, Resources.bomb); Reveal(); BombaFimJogo(); // O jogo acaba V_MineSweeperGame_AskToResetBoard(); } else if (currentTile.Vazio == false && currentTile.Aberto == false) { ButtonChangeBackground(botaoAtual, currentTile); currentTile.Aberto = true; if (M_Options.SoundOnOrOFF == true) { Thread soundThread = new Thread(Sound.PlayOpenTile) { IsBackground = true }; soundThread.Start(); } // Se a condição for verdadeira a condição acaba if (TestarFim(currentTile) == true) { GanhouJogo(); } //soundThread.Abort(); } // O jogo tem que abrir todos os vazios adjacentes. // Primeira Questão: Como pedir os botões adjacentes ao view? else if (currentTile.Vazio == true && currentTile.Aberto == false) { Flood_Fill(currentTile, V_MineSweeperGame.GetButton(currentTile.Ponto)); } } // Botão direito, coloca flag else if (e.Button == MouseButtons.Right) { Button botaoAtual = sender as Button; GetCoordinates(botaoAtual, out int x, out int y); // Obtém as Coordenadas do Tile Tile currentTile = GetTile(new System.Drawing.Point(x, y)); if (currentTile.Aberto != true) { if (M_Options.SoundOnOrOFF == true) { Thread soundThread = new Thread(Sound.PlayPutFlag) { IsBackground = true }; soundThread.Start(); } if (currentTile.Flagged == true) { V_MineSweeperGame.ChangeButtonBackGround(botaoAtual, Resources.unopened); currentTile.Flagged = false; M_Grelha.NumFlags--; V_MineSweeperGame.AtualizaNumeroMinasDisponiveis(M_Grelha.NumMinasTotal - M_Grelha.NumFlags); } else if (currentTile.Flagged == false) { V_MineSweeperGame.ChangeButtonBackGround(botaoAtual, Resources.flag1); currentTile.Flagged = true; M_Grelha.NumFlags++; V_MineSweeperGame.AtualizaNumeroMinasDisponiveis(M_Grelha.NumMinasTotal - M_Grelha.NumFlags); } //soundThread.Abort(); } else { return; } } } // O jogo funciona em modo inverso, o jogador tem que detetar o posicionamento das minas else if (Program.M_Options.ModoJogo == GameMode.Inverso) { if (e.Button == MouseButtons.Left) { Temporizador.Start(); Button botaoAtual = sender as Button; GetCoordinates(botaoAtual, out int x, out int y); // Obtém as Coordenadas do Tile Tile currentTile = GetTile(new System.Drawing.Point(x, y)); if (currentTile.Aberto != true) { if (M_Options.SoundOnOrOFF == true) { Thread soundThread = new Thread(Sound.PlayPutFlag) { IsBackground = true }; soundThread.Start(); } if (currentTile.Flagged == true) { V_MineSweeperGame.ChangeButtonBackGround(botaoAtual, Resources.unopened); currentTile.Flagged = false; M_Grelha.NumFlags--; V_MineSweeperGame.AtualizaNumeroMinasDisponiveis(M_Grelha.NumMinasTotal - M_Grelha.NumFlags); } else if (currentTile.Flagged == false) { if (Program.M_Grelha.NumMinasTotal == M_Grelha.NumFlags) { return; } V_MineSweeperGame.ChangeButtonBackGround(botaoAtual, Resources.flag1); currentTile.Flagged = true; M_Grelha.NumFlags++; V_MineSweeperGame.AtualizaNumeroMinasDisponiveis(M_Grelha.NumMinasTotal - M_Grelha.NumFlags); } //soundThread.Abort(); } if (TestarFimModoInverso(currentTile) == true) { GanhouJogo(); } else { return; } } else if (e.Button == MouseButtons.Right) { return; } } }
private void frmPrincipal_MouseLeave(object sender, EventArgs e) { Contador = 0; Temporizador.Enabled = false; Temporizador.Stop(); }