private void SetDefaultValues(DigitalMicroWave microwave) { txtPotency.Value = (Decimal)microwave.Potency; dtpTimer.MinDate = new DateTime(1753, 1, 1); dtpTimer.MaxDate = new DateTime(1753, 1, 1).AddSeconds(120); SetWatch(microwave.TimeLeft); }
/// <summary> /// Handles events comming from the mirowave running job /// </summary> /// <param name="sender">Microwave</param> /// <param name="e">arguments</param> static void JobRunningEventHandler(Object sender, JobRunningEventArgs e) { DigitalMicroWave microwave = (DigitalMicroWave)sender; FormMain mainform = (FormMain)Application.OpenForms[0]; switch (microwave.Status) { case MicroWaveStatus.Ready: mainform.InvokeAnywhere(c => MessageBox.Show(c, "AQUECIDA")); // passing form as owner so MessageBox behave as modal mainform.InvokeAnywhere(c => c.SetWatch(microwave.TimeLeft)); mainform.InvokeAnywhere(c => c.btnStart.Text = "START"); break; case MicroWaveStatus.Running: mainform.InvokeAnywhere(c => c.txtInputString.Text = c.txtInputString.Text + microwave.CurrentJob.Dotz); if (microwave.CurrentJob != null) { mainform.InvokeAnywhere(c => c._timerReadOnly = false); mainform.InvokeAnywhere(c => c.SetWatch(microwave.CurrentJob.TimeLeft)); mainform.InvokeAnywhere(c => c._timerReadOnly = true); } break; case MicroWaveStatus.DoorOpen: break; case MicroWaveStatus.JobLess: break; } }
public DigitalMicroWave Initialize() { try { var fullpath = _repo.GetCurrentPath(_templateFileName); var savedTemplates = _repo.ReadTemplatesFromFile(fullpath); this._microwave = new DigitalMicroWave(savedTemplates, _defaultTime, _defaultPotency); _autoEvent = new AutoResetEvent(false); if (_timer == null) { _timer = new Timer(this._microwave.Tick, _autoEvent, 1000, 1000); } return(this._microwave); } catch (Exception ex) { throw new Exception($"Falha ao tentar inicializar o microondas:{ex.Message}", ex); } }