public void SelectTimer(Timer timer) { if (!Selected || timer == null) { return; } SelectedTimer = timer; timer.RadioButton.Checked = true; TimerInfo timerInfo; TimerError error = SelectedTimer.GetTimerInfo(out timerInfo); List <Control> controls = new List <Control>() { FlowTimer.MainForm.ButtonStart, FlowTimer.MainForm.ButtonStop, }; if (error == TimerError.NoError) { FlowTimer.UpdatePCM(Array.ConvertAll(timerInfo.Offsets, x => (double)x), timerInfo.Interval, timerInfo.NumBeeps); if (!FlowTimer.IsTimerRunning) { FlowTimer.MainForm.LabelTimer.Text = (timerInfo.MaxOffset / 1000.0).ToFormattedString(); } controls.ForEach(control => control.Enabled = true); } else { FlowTimer.MainForm.LabelTimer.Text = "Error"; controls.ForEach(control => control.Enabled = false); } }
public void OnDataChange() { TimerError error = GetVariableInfo(out Info); double currentTime = double.Parse(FlowTimer.MainForm.LabelTimer.Text); FlowTimer.MainForm.ButtonSubmit.Enabled = error == TimerError.NoError && !Submitted && FlowTimer.IsTimerRunning && Info.Frame / Info.FPS + Info.Offset / 1000.0f >= currentTime + (Info.Interval * (Info.NumBeeps - 1) / 1000.0f); FlowTimer.MainForm.ButtonUndo.Enabled = Submitted && FlowTimer.IsTimerRunning; bool canAdjust = Submitted && currentTime < CurrentOffset - Info.Interval * (Info.NumBeeps - 1) / 1000.0f - 0.05; FlowTimer.MainForm.ButtonPlus.Enabled = canAdjust; FlowTimer.MainForm.ButtonMinus.Enabled = canAdjust; }