Advertisement
Guest User

Untitled

a guest
Mar 20th, 2013
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.91 KB | None | 0 0
  1. private void spin_ValueChanged(object sender, EventArgs e) {
  2.             intervalChanged(spinMinutes, spinSeconds, spinMilliseconds);
  3.             lblInterval.Text = "Interval (milliseconds): " + Interval(spinMinutes, spinSeconds, spinMilliseconds);
  4.         }
  5.  
  6.         private void spinSeq_ValueChanged(object sender, EventArgs e) {
  7.             intervalChanged(spinSeqMinutes, spinSeqSeconds, spinSeqMilliseconds);
  8.             lblInterval.Text = "Interval (milliseconds): " + Interval(spinSeqMinutes, spinSeqSeconds, spinSeqMilliseconds);
  9.         }
  10.         #endregion
  11.  
  12.         private bool intervalUpdating = false;
  13.         private void intervalChanged(NumericUpDown m_, NumericUpDown s_, NumericUpDown ms_) {
  14.             if (intervalUpdating)
  15.                 return;
  16.  
  17.             intervalUpdating = true;
  18.  
  19.             // adding time
  20.             if (ms_.Value >= 1000) {
  21.                 var val = (int)ms_.Value / 1000;
  22.                 s_.Value += val;
  23.                 ms_.Value = (ms_.Value - (val * 1000));
  24.             }
  25.  
  26.             if (s_.Value >= 60) {
  27.                 var val = (int)s_.Value / 60;
  28.                 m_.Value += val;
  29.                 s_.Value = (s_.Value - (val * 60));
  30.             }
  31.  
  32.             if (m_.Value >= 60) {
  33.                 m_.Value = 60;
  34.             }
  35.  
  36.             // subtracting time
  37.             if (ms_.Value < 0) {
  38.                 s_.DownButton();
  39.                 ms_.Value = 999;
  40.             }
  41.  
  42.             if (s_.Value < 0) {
  43.                 m_.DownButton();
  44.                 s_.Value = 59;
  45.             }
  46.  
  47.             // warn if too fast
  48.             if (Interval(spinMinutes, spinSeconds, spinMilliseconds) < 250) {
  49.                 MessageBox.Show("Intervals below a quarter of a second are strongly discouraged.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  50.                 ms_.Value = 250;
  51.             }
  52.  
  53.             intervalUpdating = false;
  54.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement