private void ResumeTimer()
        {
            _textToSpeach.SpeakNow("Resuming workout");
            isInTicked = false;
            _locationService.ResumeTraking();
            if (isEditCklicked)
            {
                isEditCklicked = false;
                if (Time != TimerPickersViewModel[(int)UserExercizeMode].Time)
                {
                    ProgressAnimationLength = 10;

                    ProgressPracentage = 1;

                    Time           = TimerPickersViewModel[(int)UserExercizeMode].Time;
                    CountdownTimer = Time;
                    _timer.InitWith(Time);
                    IsActivated = true;

                    _timer.Start();
                }
                else
                {
                    IsActivated = true;

                    _timer.Resume();
                }
            }
            else
            {
                IsActivated = true;

                _timer.Resume();
            }
        }
Esempio n. 2
0
        public void CountDownTimerCalculatesTimeLeft()
        {
            var startedTimer = _countDownTimer.Start();

            Now = Now.AddMinutes(5);
            Assert.Equal(TimeSpan.FromMinutes(10), startedTimer.TimeLeft);
            Assert.IsType <InProgressTimer>(startedTimer);
        }
Esempio n. 3
0
        public void Start_WaitLittleLessThanSetTime_ExpiredEventNotCalled(int secondsToWait, int msToWait)
        {
            bool isCalled = false;

            _uut.ExpiredEvent += (sender, args) => { isCalled = true; };

            _uut.Start(0, secondsToWait);

            Thread.Sleep(msToWait);

            Assert.That(isCalled, Is.EqualTo(false));
        }
Esempio n. 4
0
        private void button3_Click(object sender, EventArgs e)
        {
            Process.Start("Chrome.exe", @"C:\Users\mussa\source\repos\CryptoQuest\CryptoQuest\Resources\HTMLPage1.html");
            label3.Visible      = true;
            label2.Visible      = true;
            button1.Visible     = true;
            pictureBox1.Visible = true;
            button3.Visible     = false;
            label5.Visible      = true;
            textBox1.Enabled    = true;
            button2.Enabled     = true;


            CountDownTimer timer = new CountDownTimer();

            //set to 30 mins
            timer.SetTime(5, 0);

            timer.Start();

            //update label text
            timer.TimeChanged += () => label5.Text = timer.TimeLeftMsStr;

            // show messageBox on timer = 00:00.000
            timer.CountDownFinished += () => MessageBox.Show("Уақыт бітті кеңес алуыңызға болады!");

            //timer step. By default is 1 second
            timer.StepMs             = 33;
            timer.CountDownFinished += () => label4.Visible = true;
            timer.CountDownFinished += () => button4.Visible = true;
            timer.CountDownFinished += () => label5.Visible = false;
        }
Esempio n. 5
0
 /// <summary>
 /// 按下計時器按鈕
 /// input: 設定倒數幾分鐘
 /// </summary>
 /// <param name="set_time_min"></param>
 private void Click_on_Timer(int set_time_min, int set_time_sec = 0)
 {
     if (CDTimer.IsRunnign)
     {
         CDTimer.Pause();
     }
     else if (CDTimer.TimeLeft == new DateTime(1, 1, 1, 0, 59, 59))
     {
         CDTimer.SetTime(set_time_min, set_time_sec);
         CDTimer.Start();
     }
     else
     {
         CDTimer.Start();
     }
 }
Esempio n. 6
0
        public void StartRandomTimer()
        {
            if (IsRunning)
            {
                Log.Debug($"Timer already running");
                return;
            }
            Log.Debug($"Random start triggered at {DateTime.Now}");
            IsRunning = true;

            var minimum = _propertyService.MinimumDelay;
            var window  = minimum + _propertyService.StartWindow;

            Starting?.Invoke(this, EventArgs.Empty);

            var sleep = _random.Next(minimum, window);

            Log.Information($"Sleeping for {sleep}ms");

            var timer = new CountDownTimer(TimeSpan.FromMilliseconds(sleep));

            timer.ReachedZero += (_, __) =>
            {
                Log.Information($"Start!");
                Started?.Invoke(this, EventArgs.Empty);
                IsRunning = false;
            };
            timer.Start();
        }
 /// <summary>
 /// 如果勾选消融,那就先开始计时延时计时器
 /// </summary>
 private void OnEnable()
 {
     if (isDisslove)
     {
         delayTimer.Start();
     }
 }
Esempio n. 8
0
        private void OnPlayerStateUpdate(object sender, PlayerStateChangedEventArgs eventArgs)
        {
            NotifyPropertyChanged("MultimediaName");
            NotifyPropertyChanged("MultimediaLength");
            NotifyPropertyChanged("Playing");
            NotifyPropertyChanged("PlaybackPosition");
            NotifyPropertyChanged("PlaybackTime");

            MultimediaItem multimedia = eventArgs.Multimedia;

            if (eventArgs.Multimedia != null)
            {
                this.millisLength = (long)multimedia.Length * 1000;
                long millisEstimatedLength = millisLength - (eventArgs.PlaybackPosition * 1000);

                int millisStep = 1000 / 60;

                if (playbackUpdater != null)
                {
                    playbackUpdater.Cancel();
                }

                playbackUpdater         = new CountDownTimer(new DispatcherMessageQueue(), millisEstimatedLength, millisStep);
                playbackUpdater.Tick   += OnUpdaterTick;
                playbackUpdater.Finish += OnUpdaterFinish;
                playbackUpdater.Start();
            }
        }
Esempio n. 9
0
        public void PlayTimer()
        {
            _timer.Start();
            IsPlaying = true;

            btnPlayPause.ImageMargin = new Padding(0, 0, 0, 0);
            btnPlayPause.Image       = Properties.Resources.Pause_104px;
            lblCountdown.Left        = (Width - lblCountdown.Width) / 2;
        }
Esempio n. 10
0
            public IEnumerator WHEN_StartFunctionCalled_THEN_CurrentTimeReset()
            {
                timerObject.Start();
                float expectedCurrentTime = 40;

                yield return(null);

                Assert.IsTrue(Math.Abs(expectedCurrentTime - timerObject.currentTime) <= tolerance);
            }
Esempio n. 11
0
 /// <summary>
 /// 显示提示
 /// </summary>
 /// <param name="duration">持续时间</param>
 /// <param name="content">显示内容</param>
 public void ShowToast(string content, float duration = 3f)
 {
     this.duration  = duration;
     toastText.text = content;
     Timer.Start();
     moveTimer.Start();
     gameObject.SetActive(true);
     Debug.Log(content);
 }
Esempio n. 12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Make this page show evenw hen the phone is locked
            Window.AddFlags(WindowManagerFlags.ShowWhenLocked);
            //Window.AddFlags(WindowManagerFlags.KeepScreenOn);
            Window.AddFlags(WindowManagerFlags.TurnScreenOn);

            Settings.AddLogMessage(this, "Stop screen started: {0}", DateTime.Now.ToString(ApplicationState.DATE_TIME_TIME_OF_DAY_FORMAT_STRING));

            // If we have location constraints, make sure we're near them
            if (Settings.GetConstrainByCellTower(this))
            {
                HashSet <int> validIDs           = Settings.GetValidCellTowerIDs(this);
                HashSet <int> cellTowerIDsNearby = ApplicationState.GetInstance(this).GetNearbyCellTowerIDs();

                if (!validIDs.Overlaps(cellTowerIDsNearby))
                {
                    // Cancel this activity
                    stopAlarm();
                    Finish();
                    Settings.AddLogMessage(this, "Not near any valid cell towers. {0}", string.Join(", ", cellTowerIDsNearby));
                    return;
                }
            }

            Vibrator vb = this.GetSystemService(Java.Lang.Class.FromType(typeof(Vibrator))) as Vibrator;

#pragma warning disable 618
            if (vb != null && vb.HasVibrator)
            {
                vb.Vibrate(VIBRATION_PATTERN, -1);
            }
#pragma warning restore 618

            SetContentView(Resource.Layout.StopAlarmView);

            ButtonStopAlarm.Click += ButtonStopAlarm_Click;

            // Set the alarm volume to a constant loud volume
            VolumeControlStream = Stream.Alarm;
            audioManager        = (AudioManager)GetSystemService(Context.AudioService);
            originalMediaVolume = audioManager.GetStreamVolume(VolumeControlStream);
            audioManager.SetStreamVolume(VolumeControlStream, audioManager.GetStreamMaxVolume(VolumeControlStream), VolumeNotificationFlags.AllowRingerModes);

            this.speechEngine = new TextToSpeech(this, this);

            TextStartTimeDisplay.Text = ApplicationState.SHUT_OFF_WARNING_TIME.TotalSeconds.ToString(TIME_FORMAT_STRING);

            timer = new StartAlarmTimer((long)ApplicationState.SHUT_OFF_WARNING_TIME.TotalMilliseconds, (long)TimeSpan.FromMilliseconds(7).TotalMilliseconds, this);
            timer.Start();
        }
Esempio n. 13
0
        private void TimerForm_Load(object sender, EventArgs e)
        {
            CountDownTimer.Start();

            aTimer = new System.Timers.Timer();

            // Hook up the Elapsed event for the timer.
            aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);

            aTimer.Interval = 1000;

            aTimer.Enabled = true;
        }
Esempio n. 14
0
 void judgeAndRun(int forward)
 {
     if (cdTimer.IsTimeUp)
     {
         if (isClient && !isServer)
         {
             CmdSyncMove(forward);
         }
         else if (isServer && isLocalPlayer)
         {
             RpcSyncMove(forward);
         }
         cdTimer.Start();
     }
 }
Esempio n. 15
0
    void Start()
    {
        GlobalManager.MemoryGameLoad(); //Ladataan aiempi aika
        Layers();                       //käynnistää sovelluksen välittömästi ilman buttonin painamista
        CountUpTimer.StartGame();       //Määritellään aloittamaan laskuri alusta.
        CountDownTimer.Start();
        Rotator.Start();
//        GlobalManager.Start();
        sr = GetComponent <SpriteRenderer>();

        Life1 = GameObject.Find("Life1"); //Viitataan sulkeissa määriteltyyn pelinäkymän objektiin
        Life2 = GameObject.Find("Life2");
        Life3 = GameObject.Find("Life3");
        Yeti  = GameObject.Find("yeti");

        if (level == 1)
        {
            triesLeft = 2;
            Tries     = 2;
            Life3.SetActive(false);
        }
        else if (level == 2)
        {
            triesLeft = 2;
            Tries     = 2;
            Life3.SetActive(false);
        }
        else if (level == 3)
        {
            triesLeft = 2;
            Tries     = 2;
            Life3.SetActive(false);
        }
        else if (level == 4)
        {
            triesLeft = 2;
            Tries     = 2;
            Life3.SetActive(false);
        }
        else
        {
            triesLeft = 3;                                                //Määritellään pelaajalle näkymättömien yritysten määrä aloitettaessa
            Tries     = 3;                                                //Määritellään pelaajalle näkyvien yritysten määrä aloitettaessa
        }
        countTries      = GameObject.Find("Tries").GetComponent <Text>(); //Linkitetään yrityslaskuri lainausmerkeissä määriteltyyn objektiin
        countTries.text = Tries.ToString();                               //Tulostetaan näkyvien yritysten määrä aloitettaessa linkitettyyn textiin
    }
Esempio n. 16
0
        private void onOffButton_Click(object sender, EventArgs e)
        {
            if (!start)
            {
                // Check
                if (timeTextBox.Text == "")
                {
                    MessageBox.Show("時間を入力して下さい"); return;
                }
                try
                {
                    interval = int.Parse(timeTextBox.Text);
                    if (!debug && interval < 5)
                    {
                        MessageBox.Show("5分以上にしてください");
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("入力内容が正しくありません。\n" + ex.Message);
                    return;
                }
                // Enable
                onOffButton.Text        = "停止";
                processComboBox.Enabled = false;
                timeTextBox.Enabled     = false;
                // Timer Start
                timer1.Interval = interval * 60 * 1000;
                timer1.Start();
                // CountDown
                minLabel.Text = interval.ToString().PadLeft(2, '0'); secLabel.Text = "00";
                CountDownTimer.Start();

                start = true;
            }
            else
            {
                onOffButton.Text = "開始";
                timer1.Stop();
                CountDownTimer.Stop();
                start = false;
                timeTextBox.Enabled     = true;
                processComboBox.Enabled = true;
            }
        }
Esempio n. 17
0
        void Update()
        {
            if (!BattlefieldUI.startFlag)
            {
                return;
            }
            if (BattlefieldUI.gameType == 1)
            {
                Destroy(gameObject);
            }

            if (!hasCreated)
            {
                cover_Left_Rect  = cover_Left.GetComponent <RectTransform>();
                cover_Right_Rect = cover_Right.GetComponent <RectTransform>();
                cover_Up_Rect    = cover_Up.GetComponent <RectTransform>();
                cover_Down_Rect  = cover_Down.GetComponent <RectTransform>();

                m_Vec_LR = new Vector2(0, 800);
                m_Vec_UD = new Vector2(800, 0);

                hasCreated = true;
                cdTimer    = new CountDownTimer(0.5f);
            }

            if (cdTimer.IsTimeUp)
            {
                cdTimer.Start();
                transform.SetSiblingIndex(transform.parent.childCount - 1);
            }

            me_Transform = GameObject.Find("Me").transform.Find("Head").transform;


            m_Vec_LR.x = me_Transform.localPosition.x - viewRadius;
            cover_Left_Rect.sizeDelta = m_Vec_LR;

            m_Vec_LR.x = 800 - me_Transform.localPosition.x - viewRadius;
            cover_Right_Rect.sizeDelta = m_Vec_LR;

            m_Vec_UD.y = -me_Transform.localPosition.y - viewRadius;
            cover_Up_Rect.sizeDelta = m_Vec_UD;

            m_Vec_UD.y = 800 + me_Transform.localPosition.y - viewRadius;
            cover_Down_Rect.sizeDelta = m_Vec_UD;
        }
        public PCLTimer(Action action, int period)
        {
            _action       = action;
            this.Interval = period;

            if (TheTimer != null)
            {
                TheTimer.IntervalPassed -= _timer2_IntervalPassed;
            }

            TheTimer          = new CountDownTimer(TimeSpan.FromSeconds(1));
            TheTimer.Interval = TimeSpan.FromSeconds(Interval);

            TheTimer.IntervalPassed += _timer2_IntervalPassed;

            TheTimer.Start();
        }
        private void StartTimer()
        {
            _locationService.startGPSTraking();
            IsActivated             = true;
            isInTicked              = false;
            ProgressAnimationLength = 10;
            ProgressPracentage      = 1;


            CountdownTimer    = TimerPickersViewModel[(int)UserExercizeMode].Time;
            Time              = CountdownTimer;
            _timer            = new CountDownTimer(Time);
            _timer.Completed += OnCountdownTimerCompleted;
            _timer.Ticked    += OnCountdownTimerTicked;
            _timer.Paused    += OnCountdownTimerPaused;
            _textToSpeach.SpeakNow("Lets go!");
            _timer.Start();
        }
Esempio n. 20
0
        public void CountDownTimer_WhenStarted_CountsDownAndFiresEvent()
        {
            // Arrange
            TimeSpan expectedSeconds = TimeSpan.FromSeconds(ExpectedTicks);
            int      actualTicks     = 0;

            IPclTimer classUnderTest = new CountDownTimer(expectedSeconds);

            classUnderTest.IntervalPassed += (o, e) => { actualTicks++; };

            // Act
            classUnderTest.Start();
            Thread.Sleep(TimeSpan.FromSeconds(ExpectedTicks * 2));

            // Assert
            classUnderTest.CurrentTime.ShouldBeLessThan(expectedSeconds);
            actualTicks.ShouldBeGreaterThan(ExpectedTicks);
        }
Esempio n. 21
0
        private void Started(object sender, EventArgs e)
        {
            _audioService.Play(_propertyService.StartedSound);
            Device.BeginInvokeOnMainThread(() =>
            {
                StartColour = Color.Green;
                StartText   = AppResources.StartedText;
            });
            var timer = new CountDownTimer(TimeSpan.FromMilliseconds(250));

            timer.ReachedZero += (_, __) =>
            {
                StartColour = Color.Red;
                StartText   = AppResources.StartText;
                // ReSharper disable once ExplicitCallerInfoArgument
                RaisePropertyChanged(nameof(CanStart));
            };
            timer.Start();
        }
Esempio n. 22
0
    /// <summary>
    /// 如果勾选消融,更新延时和消融
    /// </summary>
    private void Update()
    {
        if (!isDisslove || !delayTimer.IsTimeUp)
        {
            return;
        }

        if (dissloveTimer.IsStoped)
        {
            dissloveTimer.Start();
        }

        if (dissloveTimer.IsTimeUp)
        {
            gameObject.SetActive(false);
        }
        else
        {
            material.SetFloat("_BurnAmount", dissolveTime.Evaluate(dissloveTimer.GetPercent()));
        }
    }
Esempio n. 23
0
    // Update is called once per frame
    void Update()
    {
        if (cdTimer.IsTimeUp)
        {
            cdTimer.Start();
            if (flag)
            {
                tipText.CrossFadeAlpha(1, 1, true);
                flag = false;
            }
            else
            {
                tipText.CrossFadeAlpha(0, 1, true);
                //tipText.text = "[Press any key to START]\n[请按任意键开始]";
                flag = true;
            }
        }

        if (flag_font && text_Pretext.fontSize == 20)
        {
            flag_font = false;
        }
        else if (!flag_font && text_Pretext.fontSize == 100)
        {
            flag_font = true;
        }
        if (flag_font && text_Pretext)
        {
            text_Pretext.fontSize--;
        }
        else if (!flag_font && text_Pretext)
        {
            text_Pretext.fontSize++;
        }

        if (Input.anyKeyDown)
        {
            transform.GetComponent <SceneLoad>().StartSplash(1, 2);
        }
    }
Esempio n. 24
0
        }//end StatesForm()

        /// <summary>
        /// Handles the Click event of the NextQuestionButton control.
        /// Checks if the user got the name of the state's capital correct
        /// or if they got it wrong.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void NextQuestionButton_Click(object sender, EventArgs e)
        {
            TimeLeft = 15;
            CountDownTimer.Start();
            //Reset the timer back to 15 seconds
            //and start it again

            ClearSelectedBln = false;
            CapitalsListBox.ClearSelected();
            ClearSelectedBln = true;
            //ClearSelected in the CapitalsListBox, but does not go into the code of
            //the CapitalsListBox_SelectedIndexChanged method


            CapitalsListBox.Enabled = true;


            TimerTextBox.Text = TimeLeft.ToString();



            if (AttemptsCounter == 51)
            {
                AttemptsTextBox.Text = (AttemptsCounter).ToString();
                CorrectTextBox.Text  = CorrectCounter.ToString();
                System.Threading.Thread.Sleep(2000);
                this.Close();
            }
            else
            {
                //Remove the state from the list of states if the user gets it correct
                StatesIndex = R.Next(50 - AttemptsCounter);
                //Updates the new random int which will choose a new state
                StatesTextBox.Text   = States[StatesIndex];
                AttemptsTextBox.Text = (AttemptsCounter).ToString();
                CorrectTextBox.Text  = CorrectCounter.ToString();
            }
        }//end NextQuestionButton_Click(object sender, EventArgs e)
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            CountDownTimer timer = new CountDownTimer(new TimeSpan(0, 0, 4, 0));

            timer.Start();
            Thread.Sleep(2000);
            Console.WriteLine(timer.Remaining());
            Thread.Sleep(4000);
            Console.WriteLine(timer.Remaining());
            Console.WriteLine("Enter any key...");
            Console.ReadKey();

            CountDownTimer timer1 = new CountDownTimer(new TimeSpan(0, 0, 4, 0));

            timer1.Start();
            Thread.Sleep(2000);
            Console.WriteLine(timer1.Remaining());
            Thread.Sleep(4000);
            Console.WriteLine(timer1.Remaining());
            Console.WriteLine("Enter any key....");
            Console.ReadKey();
        }
 private void StartLaunchBallCounter()
 {
     countDownTimer.Start();
     GameState = GAME_STATE_BEGIN_COUNTDOWN;
 }
 protected override void OnViewModelSet()
 {
     this.SetContentView(Resource.Layout.Page_SplashScreen);
     _timer = new SplashCountDownTimer(SplashAnimationFinished);
     _timer.Start();
 }
Esempio n. 28
0
 private void OnEnable()
 {
     timer.Start();
 }
Esempio n. 29
0
 /// <summary>
 /// 失效按钮并且重启CD
 /// </summary>
 public void DisableButtonAndResetCDTimer()
 {
     button.interactable = false;
     coolDownTimer.Start();
 }
Esempio n. 30
0
        /// <summary>
        /// The Condition Requirement to execute this behavior
        /// </summary>
        /// <param name="model"> ActorMode object </param>
        /// <returns></returns>
        public bool MetRequirements(ActorModel model)
        {
            if (!isActivated)
            {
                return(false);
            }
            // if character has recovered from an attack?
            //if (model.HitRecoverFrames > 0)
            //{
            //    return false;
            //}

            // if this behavior require character to be grounded?
            if (requireGrounded)
            {
                if (!model.cc.isGrounded)
                {
                    CombatDebugger.Log("Grounded requirement failed", LogDomain.BehaviorRequirement);
                    return(false);
                }
            }

            if (requireRunning)
            {
                if (model.moveInputDir.magnitude <= 0.75f)
                {
                    CombatDebugger.Log("Running requirement failed", LogDomain.BehaviorRequirement);
                    return(false);
                }
            }

            // if this behavior require character to be in the air?
            if (requireAerial)
            {
                if (!model.isAerial)
                {
                    CombatDebugger.Log("In Air requirement failed", LogDomain.BehaviorRequirement);
                    return(false);
                }
            }

            // if this behavior require to have a target?
            if (requireTarget)
            {
                if (model.target == null)
                {
                    return(false);
                }
            }

            // if this behavior can force cancel other behaviors?
            if (canForceExecute && !model.currentBehavior.canForceExecute && !model.currentBehavior.isHurtBehavior)
            {
                // Disable Hitbox when force execute Behavior
                model.CanCancel = true;
                if (model.hitBox != null)
                {
                    model.hitBox.SetActive(false);
                    model.hitBox.SetLocalScale(Vector3.zero);
                }
            }
            if (requireUnderAttack)
            {
                if (model.currentBehavior.isHurtBehavior)
                {
                    model.CanCancel = true;
                }
                else
                {
                    return(false);
                }
            }


            // if this behavior can be canncel?
            if (model.CanCancel == false)
            {
                CombatDebugger.Log("CanCancel requirement failed", LogDomain.BehaviorRequirement);
                return(false);
            }
            else
            {
                model.CanCancel = false;
            }

            // if the behavior have CoolDown
            if (cooldown > 0)
            {
                if (!cdTimer.IsTimeUp)
                {
                    CombatDebugger.Log("Cooldown requirement failed", LogDomain.BehaviorRequirement);
                    return(false); // if count down haven't finish, return
                }
                ResetTimer(cooldown);
                cdTimer.Start(); // Start count down again
            }

            // if the character have enough energy to execute this behavior
            if (model.actorStats.currentEnergy < energyPointCost)
            {
                CombatDebugger.Log("PowerMeter requirement failed", LogDomain.BehaviorRequirement);
                return(false);
            }

            // if the character have enough air jump points to execute this behavior
            if (model.actorStats.currentAirJumpPoint < airJumpPointCost)
            {
                CombatDebugger.Log("AirJumpPoints requirement failed", LogDomain.BehaviorRequirement);
                return(false);
            }

            // if passing all the conditions, then return true
            return(true);
        }