public bool ManualAdjustment(TimeSpan changeTimespan, bool addTime) { var shouldRestart = false; if (IsRunning) { StopTimer(); shouldRestart = true; } var calculatedNewTime = addTime ? CurrentTime.Add(changeTimespan) : CurrentTime.Subtract(changeTimespan > CurrentTime ? CurrentTime : changeTimespan); var returnValue = true; if (!addTime && ExportedTime > calculatedNewTime) { returnValue = false; calculatedNewTime = ExportedTime; } CurrentTime = calculatedNewTime; if (shouldRestart) { StartTimer(); } PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("ExactCurrentTime")); return(returnValue); }
private void Rewind(MediaElement Player) { if (PlayerIsOpen(Player)) { CurrentTime = CurrentTime.Add(new TimeSpan(0, 0, 0, 0, -FastForwardOrRewindStepMilliseconds)); } }
public void StopTimer() { currentRunningTime.Stop(); IsRunning = false; CurrentTime = CurrentTime.Add(currentRunningTime.Elapsed); currentRunningTime.Reset(); }
public override void Process() { if (IsPlaying) { CurrentTime = CurrentTime.Add(TimeSpan.FromSeconds(Game.LastFrameTime)); TimedEventManager.RunEvents(CurrentTime); if (TimedEventManager.AllExecuted(CurrentTime)) { StartExplodingScene(); } if (_justAttached) { DeloreanTimedEventManager.RunEvents(CurrentTime); if (_wheelPtfxes != null) { foreach (var wheelPTFX in _wheelPtfxes) { wheelPTFX.Process(); } } } } }
public void MakeStep() { if (Ended) { return; } foreach (int i in System.Linq.Enumerable.Range(0, Settings.Instance.StepMinutes)) { NextClientSpawn -= 1; if (NextClientSpawn <= 0) { Client NewClient = new Client( ClientNum, Rnd.Next(0, Settings.Instance.TimeToProcessEnd - Settings.Instance.TimeToProcessBegin) + Settings.Instance.TimeToProcessBegin, Rnd.Next(Settings.Instance.ProfitStart, Settings.Instance.ProfitEnd) ); ClientNum += 1; Trace.WriteLine("Spawned Client with " + NewClient.TimeToSolve.ToString()); Department.NewClient(NewClient); NextClientSpawn = Rnd.Next(0, 15 - ((Settings.Instance.CustomerFlow - 50) / 10)); } Department.Tick(1); CurrentTime = CurrentTime.Add(new TimeSpan(0, 1, 0)); Trace.WriteLine("Minute passed, CurrentTime = " + CurrentTime.ToString()); if (CurrentTime.CompareTo(Settings.GetDayEndTime(Day)) >= 0) { NextDay(); break; } } }
public void Start() { State = TeamState.Started; CurrentTime = DateTime.UtcNow; EndTime = CurrentTime.Add(new TimeSpan(0, 0, Duration)); _sendTo.Group(Name).Started(EndTime); }
public void StopTimer() { DateFinished = DateTime.Now; currentRunningTime.Stop(); CurrentTime = CurrentTime.Add(currentRunningTime.Elapsed); currentRunningTime.Reset(); IsRunning = false; }
private void StartTimer() { Device.StartTimer(TimeSpan.FromSeconds(1), () => { CurrentTime = CurrentTime.Add(TimeSpan.FromSeconds(1)); RaisePropertyChanged(nameof(CurrentTime)); return(isTimerRunning); }); }
public void AddIdleTimer(IdleTimer idleTimer) { if (idleTimer.IsRunning) { throw new IdleTimerRunningException("Cannot add time from a running idle timer!"); } CurrentTime = CurrentTime.Add(idleTimer.CurrentTime); }
public void StartExplodingScene() { //if (tRogersSierra.isDeLoreanAttached) // RogersSierraManager.DetachDeLorean(); TimedEventManager.ClearEvents(); TimedEventManager.Add(CurrentTime.Add(TimeSpan.FromSeconds(2)), CurrentTime.Add(TimeSpan.FromSeconds(3))); TimedEventManager.Last.OnExecute += TrainExplosion_OnExecute; }
public void AddIdleTimer(IdleTimer idleTimer) { if (idleTimer.IsRunning) { throw new IdleTimerRunningException("Cannot add time from a running idle timer!"); } CurrentTime = CurrentTime.Add(idleTimer.IdleTimeValue); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("ExactCurrentTime")); }
public override void Update(GameTime gameTime) { if (!isStarted) { return; } // UtilityHelper.ApplyVelocity(ref currentDegree, UtilityHelper.MultiplyVector(velocity, Sign), gameTime); float deltaDistance = graphFunction.ApplyVelocity(CurrentTime, CurrentTime.Add(gameTime.ElapsedGameTime), Duration, totalDistance); CurrentTime = CurrentTime.Add(gameTime.ElapsedGameTime); // if (CurrentTime > Duration) CurrentTime = TimeSpan.Zero; deltaDistance = deltaDistance * Sign; currentDegree += deltaDistance; if (!isInfinite) { currentDegree = MathHelper.Clamp(currentDegree, Math.Min(fromDegree, toDegree), Math.Max(fromDegree, toDegree)); } else { while (currentDegree > MathHelper.Pi * 2) { currentDegree -= MathHelper.Pi * 2; } while (currentDegree < -MathHelper.Pi * 2) { currentDegree += MathHelper.Pi * 2; } } sprite.SetRotation(currentDegree); if (isLoop) { if (currentDegree == fromDegree || currentDegree == toDegree) { Sign *= -1; CurrentTime = TimeSpan.Zero; } } else { if (currentDegree == toDegree) { if (!isInfinite) { this.Stop(); } return; } } }
/// <summary> /// Moves the entire network in time from CurrentTime to End using the provided timestep. /// When using this method the entire network will be filled with water at the beginning /// </summary> /// <param name="Start"></param> /// <param name="End"></param> /// <param name="TimeStep"></param> public void MoveInTime(DateTime End, TimeSpan TimeStep) { while (CurrentTime.Add(TimeStep) <= End) { Update(CurrentTime.Add(TimeStep)); } if (CurrentTime > End) { Update(End); CurrentTime = End; } }
private IEnumerator TimeProgression() { WaitForSeconds waitForSeconds = new WaitForSeconds(1f); while (true) { if (PhotonNetwork.isMasterClient) { CurrentTime = CurrentTime.Add(TimeSpan.FromMinutes(tickRate)); PhotonNetwork.room.CustomProperties["gameTime"] = CurrentTime.Ticks; } yield return(waitForSeconds); } }
public TimeSpan StopTimer() { currentRunningTime.Stop(); runningWatcher.Stop(); IsRunning = false; var elapsed = currentRunningTime.Elapsed; CurrentTime = CurrentTime.Add(elapsed); currentRunningTime.Reset(); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("IsRunning")); return(elapsed); }
public override void Update(GameTime gameTime) { if (!isStarted) { return; } // UtilityHelper.ApplyVelocity(ref currentSize, UtilityHelper.MultiplyVector(velocity, Sign), gameTime); Vector2 deltaDistance = graphFunction.ApplyVelocity(CurrentTime, CurrentTime.Add(gameTime.ElapsedGameTime), Duration, totalDistance); CurrentTime = CurrentTime.Add(gameTime.ElapsedGameTime); deltaDistance = Vector2.Multiply(deltaDistance, Sign); currentSize = Vector2.Add(currentSize, deltaDistance); currentSize.X = MathHelper.Clamp(currentSize.X, Math.Min(fromSize.X, toSize.X), Math.Max(fromSize.X, toSize.X)); currentSize.Y = MathHelper.Clamp(currentSize.Y, Math.Min(fromSize.Y, toSize.Y), Math.Max(fromSize.Y, toSize.Y)); sprite.SetSize(currentSize); if (isLoop) { int completed = 0; if (currentSize.X == fromSize.X || currentSize.X == toSize.X) { Sign.X *= -1; completed++; } if (currentSize.Y == fromSize.Y || currentSize.Y == toSize.Y) { Sign.Y *= -1; completed++; } if (completed == 2) { // CurrentTime = TimeSpan.Zero; } } else { if (currentSize.X == toSize.X && currentSize.Y == toSize.Y) { if (!isInfinite) { this.Stop(); } return; } } }
//Метод логики работы таймера. private void Dispatcher_Timer() { AllTime = CurrentTime = GetRequiredTime(); Timer = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate { TimeLabel.Content = CurrentTime.ToString("mm\\:ss"); if (CurrentTime == TimeSpan.Zero) { Timer.Stop(); } CurrentTime = CurrentTime.Add(TimeSpan.FromSeconds(-1)); }, Application.Current.Dispatcher); Timer.Start(); }
public void Pause() { // Toggle Pause if (State == TeamState.Paused) { CurrentTime = DateTime.UtcNow; EndTime = CurrentTime.Add(new TimeSpan(0, 0, _timeRemaining)); State = TeamState.Started; } else { _timeRemaining = (int)EndTime.Subtract(DateTime.UtcNow).TotalSeconds; State = TeamState.Paused; } _sendTo.Group(Name).Paused(EndTime, _timeRemaining); }
/// <summary> /// Handles the Elapsed event of the InternalTimer control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ElapsedEventArgs"/> instance containing the event data.</param> private void InternalTimer_Elapsed(object sender, ElapsedEventArgs e) { if (this.direction == TimerDirection.CountUp) { this.currentTime = CurrentTime.Add(new TimeSpan(0, 0, 0, 0, this.timerIntervalInMilliseconds)); } else { this.currentTime = CurrentTime.Subtract(new TimeSpan(0, 0, 0, 0, this.timerIntervalInMilliseconds)); } if (currentTime.TotalMilliseconds < 1) { OnClockEnd(this, null); } Tick?.Invoke(this, new TickEventArgs(this.currentTime)); }
public void SetFramesWritten(int count) { _writtenSamples = count * FrameSize; CurrentTime = CurrentTime.Add(count * FFTSize, Samplerate); }
public void ManualAdjustment(int hours, int minutes, bool addTime) { var changeTimespan = new TimeSpan(hours, minutes, 0); CurrentTime = addTime ? CurrentTime.Add(changeTimespan) : CurrentTime.Subtract(changeTimespan); }
public override void Update(GameTime gameTime) { if (!isStarted) { return; } // UtilityHelper.ApplyVelocity(ref currentColor, Vector4.Multiply(velocity, Sign), gameTime); Vector4 deltaDistance = graphFunction.ApplyVelocity(CurrentTime, CurrentTime.Add(gameTime.ElapsedGameTime), Duration, totalDistance); CurrentTime = CurrentTime.Add(gameTime.ElapsedGameTime); // if (CurrentTime > Duration) CurrentTime = TimeSpan.Zero; deltaDistance = Vector4.Multiply(deltaDistance, Sign); currentColor = Vector4.Add(currentColor, deltaDistance); currentColor.X = MathHelper.Clamp(currentColor.X, Math.Min(fromColor.X, toColor.X), Math.Max(fromColor.X, toColor.X)); currentColor.Y = MathHelper.Clamp(currentColor.Y, Math.Min(fromColor.Y, toColor.Y), Math.Max(fromColor.Y, toColor.Y)); currentColor.Z = MathHelper.Clamp(currentColor.Z, Math.Min(fromColor.Z, toColor.Z), Math.Max(fromColor.Z, toColor.Z)); currentColor.W = MathHelper.Clamp(currentColor.W, Math.Min(fromColor.W, toColor.W), Math.Max(fromColor.W, toColor.W)); sprite.SetOverlay(currentColor); if (isLoop) { int completed = 0; if (currentColor.X == fromColor.X || currentColor.X == toColor.X) { Sign.X *= -1; completed++; } if (currentColor.Y == fromColor.Y || currentColor.Y == toColor.Y) { Sign.Y *= -1; completed++; } if (currentColor.Z == fromColor.Z || currentColor.Z == toColor.Z) { Sign.Z *= -1; completed++; } if (currentColor.W == fromColor.W || currentColor.W == toColor.W) { Sign.W *= -1; completed++; } if (completed == 4) { CurrentTime = TimeSpan.Zero; } } else { if (currentColor.X == toColor.X && currentColor.Y == toColor.Y && currentColor.Z == toColor.Z && currentColor.W == toColor.W) { if (!isInfinite) { this.Stop(); } return; } } }
/// <summary> /// Counts up the time and raises the IntervalPassed event. /// </summary> protected override void CountCurrent() { CurrentTime = CurrentTime.Add(Interval); RaiseIntervalPassedEvent(); }
private void Count() { CurrentTime = CurrentTime.Add(_timeStep); }