Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void spin_ValueChanged(object sender, EventArgs e) {
- intervalChanged(spinMinutes, spinSeconds, spinMilliseconds);
- lblInterval.Text = "Interval (milliseconds): " + Interval(spinMinutes, spinSeconds, spinMilliseconds);
- }
- private void spinSeq_ValueChanged(object sender, EventArgs e) {
- intervalChanged(spinSeqMinutes, spinSeqSeconds, spinSeqMilliseconds);
- lblInterval.Text = "Interval (milliseconds): " + Interval(spinSeqMinutes, spinSeqSeconds, spinSeqMilliseconds);
- }
- #endregion
- private bool intervalUpdating = false;
- private void intervalChanged(NumericUpDown m_, NumericUpDown s_, NumericUpDown ms_) {
- if (intervalUpdating)
- return;
- intervalUpdating = true;
- // adding time
- if (ms_.Value >= 1000) {
- var val = (int)ms_.Value / 1000;
- s_.Value += val;
- ms_.Value = (ms_.Value - (val * 1000));
- }
- if (s_.Value >= 60) {
- var val = (int)s_.Value / 60;
- m_.Value += val;
- s_.Value = (s_.Value - (val * 60));
- }
- if (m_.Value >= 60) {
- m_.Value = 60;
- }
- // subtracting time
- if (ms_.Value < 0) {
- s_.DownButton();
- ms_.Value = 999;
- }
- if (s_.Value < 0) {
- m_.DownButton();
- s_.Value = 59;
- }
- // warn if too fast
- if (Interval(spinMinutes, spinSeconds, spinMilliseconds) < 250) {
- MessageBox.Show("Intervals below a quarter of a second are strongly discouraged.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- ms_.Value = 250;
- }
- intervalUpdating = false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement