コード例 #1
0
        public void Count()
        {
            if (isPaused)
            {
                return;
            }

            if (globalTimer.timerValueMs >= startTimeMs + timeoutMs)
            {
                isPaused = true;
                OnCountdownCompleted?.Invoke();
            }
        }
コード例 #2
0
        private void OnInterval(object obj, ElapsedEventArgs args)
        {
            counter++;

            StainLineAction = counter % 2 == 0 ? SetStainLines() : null;

            if (counter == intervalsPerSec)
            {
                counter = 0;
                countdownValue--;

                if (countdownValue == 0)
                {
                    timer.Stop();
                    timer.Dispose();
                    this.Dispatcher.Invoke(() => { MovingPath.Data = Geometry.Parse(PathMarkup + MidpointX + "," + (MidpointY - MovingRadius).ToString()); });
                    OnCountdownCompleted?.Invoke(this, new EventArgs());
                    return;
                }

                CounterUpdateAction = () => { tbCounter.Text = countdownValue.ToString(); };
            }
            else
            {
                CounterUpdateAction = null;
            }

            int posX = (int)(Math.Cos((counter * anglePerInterval) + angleOffset) * MovingRadius) + MidpointX;
            int posY = (int)(Math.Sin((counter * anglePerInterval) + angleOffset) * MovingRadius) + MidpointY;

            LineAction = () => { MovingPath.Data = Geometry.Parse(PathMarkup + posX.ToString() + "," + posY.ToString()); };

            this.Dispatcher.Invoke(() =>
            {
                StainLineAction?.Invoke();
                CounterUpdateAction?.Invoke();
                LineAction?.Invoke();
            });
        }