// Display option to calibration private void btnInformar_Click(object sender, EventArgs e) { var choosedCalibration = new ChooseCalibration(); choosedCalibration.ShowDialog(); waitAlert(0); }
// Start private void btn_start_Click(object sender, EventArgs e) { if (FileExist(Dados.PathFile)) { var chooseForm = new ChooseCalibration(); chooseForm.ShowDialog(); } else { messageInformation("Informar Calibração"); } }
// Loop to monitor data private void timer_Tick(object sender, EventArgs e) { // Program Run... if (FileExist(Dados.PathFile) && TakeLine(Dados.PathFile) > 0) { string dateCalibrationAux = ""; switch (nextCalibrationId()) { case 1: dateCalibrationAux = Properties.Settings.Default.LimitBluetooth; Dados.Nick = "Bluetooth"; break; case 2: dateCalibrationAux = Properties.Settings.Default.LimitWifi; Dados.Nick = "Wifi"; break; case 3: dateCalibrationAux = Properties.Settings.Default.LimitAccess; Dados.Nick = "Bluetooth/Wifi"; break; } TimeSpan ts = dateResult(dateCalibrationAux, true); // Display counterdown to calibration eta.Text = $"E.T.A: {ts.Days} Dia(s), {ts.Hours}:{ts.Minutes}:{ts.Seconds} para calibrar o {Dados.Nick}."; // Open Alert to info calibration if (ts.Days <= 1 && Dados.EnableMonitor) { if (dateResult(Dados.WaitNextNotice, true).Milliseconds <= 0) { AlertCalibration(dateCalibrationAux); } } else { ts = dateResult(Dados.LastAccess, false); int segundos = (int)ts.TotalSeconds; if (1 >= segundos) { if (Application.OpenForms.OfType <NoticeCalibration>().Count() <= 0) { var chooseForm = new ChooseCalibration(); chooseForm.ShowDialog(); } } } // Save the last calibration time by id DateTime plusDate; switch (Dados.BtnId) { case 1: Dados.TimeNow = DateTime.Now.ToString(); Properties.Settings.Default.LastBluetooth = Dados.TimeNow; plusDate = ParseDate(Dados.TimeNow); Properties.Settings.Default.LimitBluetooth = plusDate.AddDays(7).ToString(); Properties.Settings.Default.Save(); Dados.BtnId = 0; break; case 2: Dados.TimeNow = DateTime.Now.ToString(); Properties.Settings.Default.LastWifi = Dados.TimeNow; plusDate = ParseDate(Dados.TimeNow); Properties.Settings.Default.LimitWifi = plusDate.AddDays(7).ToString(); Properties.Settings.Default.Save(); Dados.BtnId = 0; break; case 3: Dados.TimeNow = DateTime.Now.ToString(); Properties.Settings.Default.LastAccess = Dados.TimeNow; plusDate = ParseDate(Dados.TimeNow); Properties.Settings.Default.LimitAccess = plusDate.AddDays(7).ToString(); Properties.Settings.Default.Save(); Dados.BtnId = 0; break; } } else { // Alert application from lost file if (Application.OpenForms.OfType <LostFile>().Count() <= 0) { if (Dados.PathFile != " ") { txt_path.Clear(); eta.Text = "Não existe arquivo selecionado!"; var lostForm = new LostFile(); lostForm.ShowDialog(); } } } }