private void Progress(object novo) { try { ProgressBarMeu bar = novo as ProgressBarMeu; if (bar == null || bar.Equals(null)) { invokeCircularProgressBar(); return; } for (bar.Value = 0; bar.Value < bar.Maximum; bar.Value = bar.Value + 3) { Invoke((Action) delegate { label5.Text = bar.Value.ToString(); }); Thread.Sleep(100); } Invoke((Action) delegate { bar.Dispose(); }); invokeCircularProgressBar(); } catch { invokeCircularProgressBar(); } }
private void ponto(object sender, EventArgs e) { ProgressBarMeu a = sender as ProgressBarMeu; Invoke((Action) delegate { if (a.Value >= 93 && a.Value <= 100) { Pontos.Text = (30 + Convert.ToInt32(Pontos.Text)) + ""; } else { Pontos.Text = (3 + Convert.ToInt32(Pontos.Text)) + ""; } a.Value = a.Maximum; a.Dispose(); }); }
private void invokeCircularProgressBar(ProgressBarMeu circularBar = null) { contador++; if (contador >= 6) { if (Convert.ToInt32(Pontos.Text) >= 100) { stado.Text = "perfect"; } else { stado.Text = "boa"; } Invoke((Action) delegate { stado.Visible = true; label7.Text = DateTime.Now.Millisecond.ToString(); }); return; } int[] top = new int[] { 121, 278, 182, 233, 155, 310 }; int[] left = new int[] { 295, 311, 433, 365, 387, 400, 423, 335, 456, 478 }; ProgressBarMeu teste = new ProgressBarMeu(); teste.Text = string.Empty; teste.Click += ponto; if (repetidotop < 183) { repetidotop = top[new Random().Next(4, 6)]; } else { repetidotop = top[new Random().Next(0, 3)]; } if (repetidoleft < 387) { repetidoleft = left[new Random().Next(5, 10)]; } else { repetidoleft = left[new Random().Next(0, 4)]; } teste.Top = repetidotop; teste.Left = repetidoleft; teste.Width = 50; teste.Height = 50; teste.Maximum = 100; teste.Value = 0; try { Invoke((Action) delegate { Controls.Add(teste); }); } catch (InvalidOperationException ex) { Close(); } catch (InvalidAsynchronousStateException ex) { Close(); } Thread Progressbar = new Thread(Progress); Progressbar.Start(teste); }