コード例 #1
0
ファイル: JiraTimer.cs プロジェクト: forki/Gallifrey
        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);
        }
コード例 #2
0
 private void Rewind(MediaElement Player)
 {
     if (PlayerIsOpen(Player))
     {
         CurrentTime = CurrentTime.Add(new TimeSpan(0, 0, 0, 0, -FastForwardOrRewindStepMilliseconds));
     }
 }
コード例 #3
0
 public void StopTimer()
 {
     currentRunningTime.Stop();
     IsRunning   = false;
     CurrentTime = CurrentTime.Add(currentRunningTime.Elapsed);
     currentRunningTime.Reset();
 }
コード例 #4
0
        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();
                        }
                    }
                }
            }
        }
コード例 #5
0
        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;
                }
            }
        }
コード例 #6
0
ファイル: Team.cs プロジェクト: benlaan/planningpoker
 public void Start()
 {
     State       = TeamState.Started;
     CurrentTime = DateTime.UtcNow;
     EndTime     = CurrentTime.Add(new TimeSpan(0, 0, Duration));
     _sendTo.Group(Name).Started(EndTime);
 }
コード例 #7
0
 public void StopTimer()
 {
     DateFinished = DateTime.Now;
     currentRunningTime.Stop();
     CurrentTime = CurrentTime.Add(currentRunningTime.Elapsed);
     currentRunningTime.Reset();
     IsRunning = false;
 }
コード例 #8
0
 private void StartTimer()
 {
     Device.StartTimer(TimeSpan.FromSeconds(1), () =>
     {
         CurrentTime = CurrentTime.Add(TimeSpan.FromSeconds(1));
         RaisePropertyChanged(nameof(CurrentTime));
         return(isTimerRunning);
     });
 }
コード例 #9
0
        public void AddIdleTimer(IdleTimer idleTimer)
        {
            if (idleTimer.IsRunning)
            {
                throw new IdleTimerRunningException("Cannot add time from a running idle timer!");
            }

            CurrentTime = CurrentTime.Add(idleTimer.CurrentTime);
        }
コード例 #10
0
        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;
        }
コード例 #11
0
ファイル: JiraTimer.cs プロジェクト: forki/Gallifrey
        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"));
        }
コード例 #12
0
ファイル: RotationAnimation.cs プロジェクト: bikrone/hexagon
        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;
                }
            }
        }
コード例 #13
0
ファイル: Model.cs プロジェクト: msruzy/hydronumerics
        /// <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;
            }
        }
コード例 #14
0
    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);
        }
    }
コード例 #15
0
ファイル: JiraTimer.cs プロジェクト: forki/Gallifrey
        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);
        }
コード例 #16
0
        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;
                }
            }
        }
コード例 #17
0
        //Метод логики работы таймера.
        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();
        }
コード例 #18
0
ファイル: Team.cs プロジェクト: benlaan/planningpoker
        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);
        }
コード例 #19
0
        /// <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));
        }
コード例 #20
0
 public void SetFramesWritten(int count)
 {
     _writtenSamples = count * FrameSize;
     CurrentTime     = CurrentTime.Add(count * FFTSize, Samplerate);
 }
コード例 #21
0
        public void ManualAdjustment(int hours, int minutes, bool addTime)
        {
            var changeTimespan = new TimeSpan(hours, minutes, 0);

            CurrentTime = addTime ? CurrentTime.Add(changeTimespan) : CurrentTime.Subtract(changeTimespan);
        }
コード例 #22
0
        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;
                }
            }
        }
コード例 #23
0
 /// <summary>
 ///     Counts up the time and raises the IntervalPassed event.
 /// </summary>
 protected override void CountCurrent()
 {
     CurrentTime = CurrentTime.Add(Interval);
     RaiseIntervalPassedEvent();
 }
コード例 #24
0
 private void Count()
 {
     CurrentTime = CurrentTime.Add(_timeStep);
 }