//----------------------------------------------------------------------------- /// <summary> /// Setz Timer auf 0 /// </summary> /// <param name="Number"> /// Timernummer /// </param> /// <param name="Mode"> /// CTimer.Unit.Sec /// </param> public void SetTimer(int Number, CTimer.Unit Mode = CTimer.Unit.mSec) { try { long[] longArray; longArray = new long[2]; longArray[0] = DateTime.Now.Ticks; longArray[1] = (long)Mode; this.timerDictionary.Add(Number, longArray); } catch { this.timerDictionary[Number][0] = DateTime.Now.Ticks; this.timerDictionary[Number][1] = (long)Mode; } }
//----------------------------------------------------------------------------- /// <summary> /// Gibt wie lange es dauerte zwischen einem Zeitpunkt in der Vergangenheit und jetzt in mSec und Sec /// </summary> /// <param name="TimeInThePast"> /// Startzeitpunkt /// </param> /// <param name="Unit"> /// mSec = 0 /// Sec = 1 /// </param> /// <returns> /// Zeitdauer (abhänig von Unit) /// </returns> public double GetDuration(DateTime TimeInThePast, CTimer.Unit Mode = CTimer.Unit.mSec) { TimeSpan timeSpan; double dValue; timeSpan = DateTime.Now - TimeInThePast; if (Mode == CTimer.Unit.mSec) { dValue = timeSpan.TotalMilliseconds; } else { dValue = timeSpan.TotalSeconds; } return(dValue); }
//----------------------------------------------------------------------------- /// <summary> /// Setzt Countdown auf den Wert gleich Value /// mit GetCountdown wird gewartet bis Coundown abgelaufen ist. /// Wird benutz um die bestimmte Delays abzuhalten und zwischen SetCountdown und WaitCountdownUp was zu machen /// </summary> /// <param name="Number"> /// Countdown Nummer /// </param> /// <param name="Value"> /// Wert für Countdown /// </param> /// <param name="Unit"> /// 0 - Milisek; 1 - Sek /// </param> public void SetCountdown(int Number, double Value, CTimer.Unit Mode = CTimer.Unit.mSec) { try { long[] longArray; longArray = new long[3]; longArray[0] = DateTime.Now.Ticks; longArray[1] = (long)Mode; longArray[2] = (long)Value; this.countdownDictionary.Add(Number, longArray); } catch { this.countdownDictionary[Number][0] = DateTime.Now.Ticks; this.countdownDictionary[Number][1] = (long)Mode; this.countdownDictionary[Number][2] = (long)Value; } return; }