Esempio n. 1
0
 private void SignFulling()
 {
     _markTime += Time.deltaTime;
     if (_markTime > 0 && _markTime < 0.1)
     {
         timeImage.rectTransform.rotation = Quaternion.Euler(0, 0, -30);
     }
     if (_markTime > 0.1 && _markTime < 0.2)
     {
         timeImage.rectTransform.rotation = Quaternion.Euler(0, 0, 30);
     }
     if (_markTime > 0.2 && _markTime < 0.3)
     {
         timeImage.rectTransform.rotation = Quaternion.Euler(0, 0, 0);
     }
     if (_markTime > 0.3 && _markTime < 0.4)
     {
         timeImage.rectTransform.localScale = new Vector3(2, 2, 2);
     }
     if (_markTime > 0.5)
     {
         timeImage.rectTransform.localScale = new Vector3(1, 1, 1);
         clockState = ClockState.Full;
         SoundManager.PlaySound(readySound);
         _markTime = 0;
     }
 }
Esempio n. 2
0
 private void OnCurrentStateInvalidated(object?sender, EventArgs e)
 {
     if (sender is Clock clock)
     {
         _currentState = clock.CurrentState;
     }
 }
Esempio n. 3
0
        public void SequentialClockTicksTest()
        {
            IClock clock = new SequentialClock(new [] {
                new TestClock(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(6)),
                new TestClock(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(7)),
                new TestClock(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(4), TimeSpan.FromSeconds(8)),
            });

            Assert.AreEqual(TimeSpan.FromSeconds(2), clock.FirstTick);
            Assert.AreEqual(TimeSpan.FromSeconds(28), clock.LastTick);
            Assert.AreEqual(TimeSpan.FromSeconds(30), clock.Duration);

            ClockState state = clock.Tick(TimeSpan.Zero);

            Assert.AreEqual(Granular.Compatibility.TimeSpan.MinValue, state.PreviousTick);
            Assert.AreEqual(TimeSpan.FromSeconds(2), state.NextTick);

            state = clock.Tick(TimeSpan.FromSeconds(6));
            Assert.AreEqual(TimeSpan.FromSeconds(6), state.PreviousTick);
            Assert.AreEqual(TimeSpan.FromSeconds(13), state.NextTick);

            state = clock.Tick(TimeSpan.FromSeconds(17));
            Assert.AreEqual(TimeSpan.FromSeconds(17), state.PreviousTick);
            Assert.AreEqual(TimeSpan.FromSeconds(24), state.NextTick);

            state = clock.Tick(TimeSpan.FromSeconds(28));
            Assert.AreEqual(TimeSpan.FromSeconds(28), state.PreviousTick);
            Assert.AreEqual(Granular.Compatibility.TimeSpan.MaxValue, state.NextTick);
        }
Esempio n. 4
0
    private void Start()
    {
        currentClockState = ClockState.Church;
        GameObject audio = GameObject.Find("GameManager");

        Bell = audio.GetComponent <AudioManager>();
    }
Esempio n. 5
0
    public void ChangeState(ClockState newState)
    {
        CurrentState.Exit();

        CurrentState = newState;
        newState.Enter();
    }
Esempio n. 6
0
        void Update(object sender, ElapsedEventArgs e)
        {
            switch (State)
            {
                case ClockState.Game:
                    if (DateTime.UtcNow >= NextStateTime)
                    {
                        State = ClockState.Results;
                        NextStateTime = DateTime.UtcNow + resultsDuration;
                        Debug.WriteLine("Changing state to Results.");
                    }
                    break;

                case ClockState.Results:
                    if(DateTime.UtcNow >= NextStateTime)
                    {
                        State = ClockState.Lobby;
                        NextStateTime = DateTime.UtcNow + lobbyDuration;
                        Debug.WriteLine("Changing state to Lobby.");
                    }
                    break;

                case ClockState.Lobby:
                    if (DateTime.UtcNow >= NextStateTime)
                    {
                        State = ClockState.Game;
                        NextStateTime = DateTime.UtcNow + gameDuration;
                        CurrentGameId = NextGameId;
                        NextGameId = Guid.NewGuid();
                        Debug.WriteLine("Changing state to Game. CurrentGameId=" + CurrentGameId);
                    }
                    break;
            }

        }
Esempio n. 7
0
        public Clock(TimeSpan topTime, TimeSpan botTime)
        {
            this.TopTime = topTime;
            this.BotTime = botTime;

            State = ClockState.NotStarted;
            StartTimer();
        }
Esempio n. 8
0
 private void ClockReset()
 {
     simulationTime = 0;
     FormUpdate();
     clockState             = ClockState.RUNNING;
     manualCheckBox.Enabled = true;
     ClockStart();
 }
        /// <summary>
        /// Executes the action.
        /// </summary>
        /// <param name="sender">The <see cref="System.Object"/> that is passed to the action by the behavior. Generally this is <seealso cref="Microsoft.Xaml.Interactivity.IBehavior.AssociatedObject"/> or a target object.</param>
        /// <param name="parameter">The value of this parameter is determined by the caller.</param>
        /// <returns>True if the specified operation is invoked successfully; else false.</returns>
        public object Execute(object sender, object parameter)
        {
            if (this.Storyboard == null)
            {
                return(false);
            }

            switch (this.ControlStoryboardOption)
            {
            case ControlStoryboardOption.Play:
                this.Storyboard.Begin();
                break;

            case ControlStoryboardOption.Stop:
                this.Storyboard.Stop();
                break;

            case ControlStoryboardOption.TogglePlayPause:
            {
                ClockState currentState = this.Storyboard.GetCurrentState();

                if (currentState == ClockState.Stopped)
                {
                    this._isPaused = false;
                    this.Storyboard.Begin();
                }
                else if (this._isPaused)
                {
                    this._isPaused = false;
                    this.Storyboard.Resume();
                }
                else
                {
                    this._isPaused = true;
                    this.Storyboard.Pause();
                }
            }

            break;

            case ControlStoryboardOption.Pause:
                this.Storyboard.Pause();
                break;

            case ControlStoryboardOption.Resume:
                this.Storyboard.Resume();
                break;

            case ControlStoryboardOption.SkipToFill:
                this.Storyboard.SkipToFill();
                break;

            default:
                return(false);
            }

            return(true);
        }
Esempio n. 10
0
        /// <summary>
        /// Called when redoing a move. The clock must be responsible for keeping track
        /// of its undo and redo history.
        /// </summary>
        public void Redo()
        {
            StopClock();

            m_undoHistory.Push(m_currentState);
            m_currentState    = m_redoHistory.Pop();
            m_whiteTimer.Time = m_currentState.WhiteTime;
            m_blackTimer.Time = m_currentState.BlackTime;
        }
Esempio n. 11
0
 public void stop()
 {
     if (!isRunning())
     {
         return;
     }
     state         = ClockState.Stopped;
     timeRemaining = timeRemaining - (DateTime.Now - runStart);
 }
Esempio n. 12
0
 public void start()
 {
     if (isRunning() || !isSet())
     {
         return;
     }
     state    = ClockState.Running;
     runStart = DateTime.Now;
 }
Esempio n. 13
0
        public bool Tick(double time, ClockState parentState)
        {
            bool ret = NoesisGUI_PINVOKE.ClockGroup_Tick(swigCPtr, time, (int)parentState);

            if (NoesisGUI_PINVOKE.SWIGPendingException.Pending)
            {
                throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Esempio n. 14
0
 public ClockState GetClockState()
 {
     lock (this) {
         BasicTypeSerializer.Put(SendContext, (byte)Command.GetClockState);
         Execute();
         Receive();
         ClockState state = (ClockState)BasicTypeDeSerializer.Get(ReceiveContext);
         return(state);
     }
 }
Esempio n. 15
0
        public GameClock()
        {
            State = ClockState.Game;
            NextStateTime = DateTime.UtcNow + gameDuration;
            CurrentGameId = Guid.NewGuid();
            NextGameId = Guid.NewGuid();

            timer = new Timer(1000.0f / timerUpdatesPerSecond);
            timer.Elapsed += Update;
            timer.Start();
        }
Esempio n. 16
0
        public TomatoClockManager(TimeSpan workTimeSpan, TimeSpan relaxTimeSpan)
        {
            clockTimer          = new Timer();
            clockTimer.Interval = 1;        // TODO:测试完毕后改回秒
            clockTimer.Elapsed += OnTimedEvent;
            clockTimeSpan       = TimeSpan.FromSeconds(0);
            clockState          = ClockState.Stop;

            this.workTimeSpan  = workTimeSpan;
            this.relaxTimeSpan = relaxTimeSpan;
        }
Esempio n. 17
0
        /// <summary>
        /// Initializes a new none clock.
        /// </summary>
        public NoneClock()
        {
            m_whiteTimer              = new StopwatchTimer();
            m_blackTimer              = new StopwatchTimer();
            m_whiteTimer.TimerNotify += WhiteClockEventHandler;
            m_blackTimer.TimerNotify += BlackClockEventHandler;

            m_currentState = new ClockState(new TimeSpan(), new TimeSpan());

            m_undoHistory = new Stack <ClockState>();
            m_redoHistory = new Stack <ClockState>();
        }
Esempio n. 18
0
        /// <summary>
        /// Initializes a new none clock.
        /// </summary>
        public NoneClock()
        {
            m_whiteTimer = new StopwatchTimer();
              m_blackTimer = new StopwatchTimer();
              m_whiteTimer.TimerNotify += WhiteClockEventHandler;
              m_blackTimer.TimerNotify += BlackClockEventHandler;

              m_currentState = new ClockState(new TimeSpan(), new TimeSpan());

              m_undoHistory = new Stack<ClockState>();
              m_redoHistory = new Stack<ClockState>();
        }
        public bool Tick(double time, ClockState parentState)
        {
            bool ret = NoesisGUI_PINVOKE.ClockGroup_Tick(swigCPtr, time, (int)parentState);

    #if UNITY_EDITOR || NOESIS_API
            if (NoesisGUI_PINVOKE.SWIGPendingException.Pending)
            {
                throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve();
            }
    #endif
            return(ret);
        }
Esempio n. 20
0
        /// <summary>
        /// This method is called when some criteria is met and the action should be invoked. This method will attempt to
        /// change the targeted storyboard in a way defined by the ControlStoryboardOption.
        /// </summary>
        /// <param name="parameter"></param>
        protected override void Invoke(object parameter)
        {
            if (this.AssociatedObject != null && this.Storyboard != null)
            {
                switch (this.ControlStoryboardOption)
                {
                case ControlStoryboardOption.Play:
                    this.Storyboard.Begin();
                    break;

                case ControlStoryboardOption.Stop:
                    this.Storyboard.Stop();
                    break;

                case ControlStoryboardOption.TogglePlayPause:
                    ClockState clockState = ClockState.Stopped;
                    bool       isPaused   = false;
                    try
                    {
                        clockState = this.Storyboard.GetCurrentState();
                        isPaused   = this.Storyboard.GetIsPaused();
                    }
                    catch (InvalidOperationException)
                    {
                    }
                    if (clockState == ClockState.Stopped)
                    {
                        this.Storyboard.Begin();
                    }
                    else if (isPaused)
                    {
                        this.Storyboard.Resume();
                    }
                    else
                    {
                        this.Storyboard.Pause();
                    }
                    break;

                case ControlStoryboardOption.Pause:
                    this.Storyboard.Pause();
                    break;

                case ControlStoryboardOption.Resume:
                    this.Storyboard.Resume();
                    break;

                case ControlStoryboardOption.SkipToFill:
                    this.Storyboard.SkipToFill();
                    break;
                }
            }
        }
Esempio n. 21
0
        /// <summary>
        /// 在构造函数中被调用,把番茄钟部分的构造代码放入此函数
        /// </summary>
        private void InitTaskClockModule()
        {
            clockManager = new TomatoClockManager(configService.TTConfig.WorkTimeSpan, configService.TTConfig.RelaxTimeSpan);
            clockManager.WorkClockFinishedEvent  += WorkClockFinishedHandler;
            clockManager.RelaxClockFinishedEvent += RelaxClockFinishedHandler;
            clockManager.ClockTickEvent          += ClockTickEventHandler;
            nextState = ClockState.Working;
            tts       = TaskTomatoService.GetTaskTomatoService();

            UpdateCurrentTaskInfo();
            viewModel.UpdateRelativeFiles();
            RelativeFilesListView.Items.Refresh();
        }
Esempio n. 22
0
    private void Update()
    {
        if (currentClockState == ClockState.Ticking)
        {
            currentTime -= 1 * Time.deltaTime;

            if (currentTime <= 0)
            {
                OnTimeTick.Invoke();
                currentClockState = ClockState.Stopped;
            }
        }
    }
Esempio n. 23
0
        /// <summary>
        /// Initializes a new incremental clock.
        /// </summary>
        /// <param name="startTime">Initial time for the clock.</param>
        /// <param name="addTime">time added for each move performed.</param>
        public IncrementalClock(TimeSpan startTime, TimeSpan addTime)
        {
            m_addTime = addTime;

            m_whiteTimer              = new CountdownTimer(startTime);
            m_blackTimer              = new CountdownTimer(startTime);
            m_whiteTimer.TimerNotify += WhiteClockEventHandler;
            m_blackTimer.TimerNotify += BlackClockEventHandler;

            m_currentState = new ClockState(startTime, startTime, true);

            m_undoHistory = new Stack <ClockState>();
            m_redoHistory = new Stack <ClockState>();
        }
Esempio n. 24
0
 private void AnimClock()
 {
     _speedChanges -= Time.unscaledDeltaTime * 4;
     if (_speedChanges < 0)
     {
         if (_indexAnim == 3)
         {
             clockState = ClockState.Rotation;
         }
         timeImage.sprite = _clockSetAnim[_indexAnim];
         _indexAnim++;
         _speedChanges = 1;
     }
 }
Esempio n. 25
0
 private void RotateClock()
 {
     _angle += Time.unscaledDeltaTime * 1000;
     if (_angle > 180)
     {
         clockState       = ClockState.InProgress;
         timeImage.sprite = _clockSet[0];
         timeImage.rectTransform.rotation = Quaternion.Euler(0, 0, 0);
         _indexAnim = 0;
         _angle     = 0;
         return;
     }
     timeImage.rectTransform.rotation = Quaternion.Euler(0, 0, _angle);
 }
Esempio n. 26
0
        /// <summary>
        /// Initializes a new incremental clock.
        /// </summary>
        /// <param name="startTime">Initial time for the clock.</param>
        /// <param name="addTime">time added for each move performed.</param>
        public IncrementalClock(TimeSpan startTime, TimeSpan addTime)
        {
            m_addTime = addTime;

              m_whiteTimer = new CountdownTimer(startTime);
              m_blackTimer = new CountdownTimer(startTime);
              m_whiteTimer.TimerNotify += WhiteClockEventHandler;
              m_blackTimer.TimerNotify += BlackClockEventHandler;

              m_currentState = new ClockState(startTime, startTime, true);

              m_undoHistory = new Stack<ClockState>();
              m_redoHistory = new Stack<ClockState>();
        }
Esempio n. 27
0
        protected override void Invoke(object type)
        {
            if (this.AssociatedObject == null || this.Storyboard == null)
            {
                return;
            }

            switch (this.ControlStoryboardOption)
            {
            case ControlStoryboardOption.Play:
                this.Storyboard.Begin();
                break;

            case ControlStoryboardOption.Stop:
                this.Storyboard.Stop();
                break;

            case ControlStoryboardOption.TogglePlayPause:
                ClockState _currentState = ClockState.Stopped;
                try
                {
                    _currentState = this.Storyboard.GetCurrentState();
                }
                catch (InvalidOperationException) { }

                if (_currentState == ClockState.Stopped)
                {
                    this.Storyboard.Resume();                               // or Begin()
                    break;
                }
                else
                {
                    this.Storyboard.Pause();
                    break;
                }

            case ControlStoryboardOption.Pause:
                this.Storyboard.Pause();
                break;

            case ControlStoryboardOption.Resume:
                this.Storyboard.Resume();
                break;

            case ControlStoryboardOption.SkipToFill:
                this.Storyboard.SkipToFill();
                break;
            }
        }
Esempio n. 28
0
            public override LinkedHashMap <string, PuzzleState> GetSuccessorsByName()
            {
                var successors = new LinkedHashMap <string, PuzzleState>();

                for (var turn = 0; turn < Turns.Length; turn++)
                {
                    for (var rot = 0; rot < 12; rot++)
                    {
                        // Apply the move
                        var positCopy1 = new int[18];
                        var pinsCopy1  = new bool[4];
                        for (var p = 0; p < 18; p++)
                        {
                            positCopy1[p] = (_posit[p] + rot * Moves[turn][p] + 12) % 12;
                        }
                        Array.Copy(_pins, 0, pinsCopy1, 0, 4);

                        // Build the move string
                        var clockwise = (rot < 7);
                        var move      = Turns[turn] + (clockwise ? (rot + "+") : ((12 - rot) + "-"));

                        successors[move] = new ClockState(pinsCopy1, positCopy1, _rightSideUp, _puzzle);
                    }
                }

                // Still y2 to implement
                var positCopy = new int[18];
                var pinsCopy  = new bool[4];

                Array.Copy(_posit, 0, positCopy, 9, 9);
                Array.Copy(_posit, 9, positCopy, 0, 9);
                Array.Copy(_pins, 0, pinsCopy, 0, 4);
                successors["y2"] = new ClockState(pinsCopy, positCopy, !_rightSideUp, _puzzle);

                // Pins position moves
                for (var pin = 0; pin < 4; pin++)
                {
                    var positC = new int[18];
                    var pinsC  = new bool[4];
                    Array.Copy(_posit, 0, positC, 0, 18);
                    Array.Copy(_pins, 0, pinsC, 0, 4);
                    var pinI = (pin == 0 ? 1 : (pin == 1 ? 3 : (pin == 2 ? 2 : 0)));
                    pinsC[pinI] = true;

                    successors[Turns[pin]] = new ClockState(pinsC, positC, _rightSideUp, _puzzle);
                }

                return(successors);
            }
Esempio n. 29
0
        /// <summary>
        /// clockTimer完成一个休息钟时回调
        /// </summary>
        private void RelaxClockFinishedHandler(object sender)
        {
            if (CurrentTaskInfo == null)
            {
                return;
            }
            nextState = ClockState.Working;
            // UI恢复

            this.Dispatcher.Invoke(new Action(() =>
            {
                ClockBtnImage.Source = new BitmapImage(
                    new Uri("pack://application:,,,/UI;component/Image/Start.png", UriKind.Absolute));
            }));
        }
Esempio n. 30
0
        public IntentExecutor(
            ILogger <IntentExecutor> logger,
            BringState bringState,
            RouteState routeState,
            SpotifyState spotifyState,
            HueState hueState,
            WeatherState weatherState,
            CalendarState calendarState,
            FuelState fuelState,
            ClockState clockState,
            VvsState vvsState,
            FitbitState fitbitState,
            GoogleFitState googleFitState,
            SoccerState bundesligaState,
            NewsState newsState)
        {
            _logger          = logger;
            _bringState      = bringState;
            _routeState      = routeState;
            _spotifyState    = spotifyState;
            _hueState        = hueState;
            _weatherState    = weatherState;
            _calendarState   = calendarState;
            _fuelState       = fuelState;
            _clockState      = clockState;
            _vvsState        = vvsState;
            _fitbitState     = fitbitState;
            _googleFitState  = googleFitState;
            _bundesligaState = bundesligaState;
            _newsState       = newsState;

            _displayableDictionary = new Dictionary <Type, Displayable>
            {
                { typeof(BringState), bringState },
                { typeof(RouteState), routeState },
                { typeof(SpotifyState), spotifyState },
                { typeof(HueState), hueState },
                { typeof(WeatherState), weatherState },
                { typeof(CalendarState), calendarState },
                { typeof(FuelState), fuelState },
                { typeof(ClockState), clockState },
                { typeof(VvsState), vvsState },
                { typeof(FitbitState), fitbitState },
                { typeof(GoogleFitState), googleFitState },
                { typeof(SoccerState), bundesligaState },
                { typeof(NewsState), newsState },
            };
        }
Esempio n. 31
0
        public Form1()
        {
            netState        = NetworkState.DISCONNECTED;
            clockState      = ClockState.STOPPED;
            simulationTime  = 0;
            updateFrequency = 1000;
            InitializeComponent();
            ofd         = new OpenFileDialog();
            ofd.Filter  = "XML File(*.xml)|*.xml";
            ofd2        = new OpenFileDialog();
            ofd2.Filter = "Text File(*.txt)|*.txt";
            sfd         = new SaveFileDialog();

            simModel  = null;
            netClient = null;
        }
Esempio n. 32
0
    void Start()
    {
        clockState = ClockState.Full;

        _clockSet = new Sprite[sandclockAtlas.spriteCount];
        sandclockAtlas.GetSprites(_clockSet);

        _clockSetAnim = new Dictionary <int, Sprite>();
        _clockSetAnim.Add(0, _clockSet[3]);
        _clockSetAnim.Add(1, _clockSet[2]);
        _clockSetAnim.Add(2, _clockSet[5]);
        _clockSetAnim.Add(3, _clockSet[4]);

        timeImage.sprite = _clockSet[0];
        timeImage.SetNativeSize();
    }
Esempio n. 33
0
        public Form1()
        {
            netState = NetworkState.DISCONNECTED;
            clockState = ClockState.STOPPED;
            simulationTime = 0;
            updateFrequency = 1000;
            InitializeComponent();
            ofd = new OpenFileDialog();
            ofd.Filter = "XML File(*.xml)|*.xml";
            ofd2 = new OpenFileDialog();
            ofd2.Filter = "Text File(*.txt)|*.txt";
            sfd = new SaveFileDialog();

            simModel = null;
            netClient = null;
        }
Esempio n. 34
0
        public void ReverseClockBasicTest()
        {
            IClock clock = new ReverseClock(new TestClock(TimeSpan.FromSeconds(2)));

            Assert.AreEqual(TimeSpan.Zero, clock.FirstTick);
            Assert.AreEqual(TimeSpan.FromSeconds(4), clock.LastTick);
            Assert.AreEqual(TimeSpan.FromSeconds(4), clock.Duration);

            ClockState state = clock.Tick(TimeSpan.FromSeconds(-1));

            Assert.AreEqual(Granular.Compatibility.TimeSpan.MinValue, state.PreviousTick);
            Assert.AreEqual(TimeSpan.Zero, state.NextTick);

            state = clock.Tick(TimeSpan.FromSeconds(5));
            Assert.AreEqual(TimeSpan.FromSeconds(4), state.PreviousTick);
            Assert.AreEqual(Granular.Compatibility.TimeSpan.MaxValue, state.NextTick);
        }
Esempio n. 35
0
        public void DurationOffsetClockTest()
        {
            IClock clock = new DurationClock(new TestClock(TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(2)), TimeSpan.FromSeconds(1));

            Assert.AreEqual(TimeSpan.Zero, clock.FirstTick);
            Assert.AreEqual(TimeSpan.FromSeconds(1), clock.LastTick);
            Assert.AreEqual(TimeSpan.FromSeconds(1), clock.Duration);

            ClockState state = clock.Tick(TimeSpan.Zero);

            Assert.AreEqual(Granular.Compatibility.TimeSpan.MinValue, state.PreviousTick);
            Assert.AreEqual(TimeSpan.FromSeconds(2), state.NextTick);

            state = clock.Tick(TimeSpan.FromSeconds(2));
            Assert.AreEqual(TimeSpan.FromSeconds(1), state.PreviousTick);
            Assert.AreEqual(Granular.Compatibility.TimeSpan.MaxValue, state.NextTick);
        }
Esempio n. 36
0
        /// <summary>
        /// Initializes a new conventional clock.
        /// </summary>
        /// <param name="moves">Moves that must be taken within the given time.</param>
        /// <param name="time">Time available to make the given amount of moves.</param>
        public ConventionalClock(int moves, TimeSpan time)
        {
            m_moves = moves;
              m_time = time;

              m_whiteMoves = moves;
              m_blackMoves = moves;

              m_whiteTimer = new CountdownTimer(time);
              m_blackTimer = new CountdownTimer(time);
              m_whiteTimer.TimerNotify += WhiteClockEventHandler;
              m_blackTimer.TimerNotify += BlackClockEventHandler;

              m_currentState = new ClockState(moves, moves, time, time, true);

              m_undoHistory = new Stack<ClockState>();
              m_redoHistory = new Stack<ClockState>();
        }
Esempio n. 37
0
        public virtual void Pause()
        {
            switch (_state)
            {
                case ClockState.Paused:
                    // success!
                    break;
                case ClockState.Playing:
                    ClockManager.Clocks.Remove(this);
                    break;
                case ClockState.Stopped:
                    // huh?  ignore it.
                    break;
            }

            _state = ClockState.Paused;
        }
Esempio n. 38
0
 private void ClockReset()
 {
     simulationTime = 0;
     FormUpdate();
     clockState = ClockState.RUNNING;
     manualCheckBox.Enabled = true;
     ClockStart();
 }
Esempio n. 39
0
        /// <summary>
        /// Called when white is to perform a move.
        /// </summary>
        public void BeginWhiteTurn()
        {
            m_currentState = new ClockState(m_whiteTimer.Time, m_blackTimer.Time);

              m_whiteTimer.Start();
        }
Esempio n. 40
0
        /// <summary>
        /// Stops the clock.
        /// </summary>
        public void Stop()
        {
            if (this.state != ClockState.Stopped)
            {
                this.state   = ClockState.Stopped;
                this.elapsed = 0;
                this.total   = 0;

                OnStopped();
            }
        }
Esempio n. 41
0
        private void ClockStart()
        {
            switch (clockState)
            {
                case ClockState.STOPPED:
                    clockState = ClockState.RUNNING;
                    startButton.Text = "Pause";
                    clockTimer.Interval = updateFrequency;
                    clockTimer.Start();
                    SimulationEvent tick = SimulationEventFactory.BuildEvent(ref simModel, "TimeTick");
                    ((IntegerValue)tick["Time"]).value = simulationTime;
                    netClient.PutEvent(tick);

                    manualCheckBox.Enabled = false;

                    break;
                case ClockState.RUNNING:
                    clockState = ClockState.STOPPED;
                    startButton.Text = "Start";
                    clockTimer.Stop();
                    break;

            }
        }
Esempio n. 42
0
        /// <summary>
        /// Resumes the clock after being paused.
        /// </summary>
        public void Resume()
        {
            if (this.state == ClockState.Paused)
            {
                this.state = ClockState.Playing;

                OnResumed();
            }
        }
Esempio n. 43
0
        /// <summary>
        /// Starts the clock.
        /// </summary>
        public void Start()
        {
            if (this.state != ClockState.Stopped)
                Stop();

            this.state   = ClockState.Playing;
            this.elapsed = 0;

            OnStarted();
        }
Esempio n. 44
0
        /// <summary>
        /// Called when undoing a move. The clock must be responsible for keeping track
        /// of its undo and redo history.
        /// </summary>
        public void Undo()
        {
            StopClock();

              m_redoHistory.Push(m_currentState);
              m_currentState = m_undoHistory.Pop();
              m_whiteTimer.Time = m_currentState.WhiteTime;
              m_blackTimer.Time = m_currentState.BlackTime;
        }
Esempio n. 45
0
        /// <summary>
        /// Pauses the clock.
        /// </summary>
        public void Pause()
        {
            if (this.state == ClockState.Playing)
            {
                this.state = ClockState.Paused;

                OnPaused();
            }
        }
Esempio n. 46
0
 public virtual void Stop()
 {
     switch (_state)
     {
         case ClockState.Paused:
         case ClockState.Playing:
             ClockManager.Clocks.Remove(this);
             break;
         case ClockState.Stopped:
             // nothing to do, we're already stopped
             break;
     }
     // was reset suposed to go here? Reset();
     _state = ClockState.Stopped;
 }
Esempio n. 47
0
        public virtual void Start()
        {
            switch (_state)
            {
                case ClockState.Paused:
                    Reset();
                    ClockManager.Clocks.Add(this);
                    break;
                case ClockState.Playing:
                    // we dont need to add because these states should already be added.
                    Reset();
                    break;
                case ClockState.Stopped:
                    // we don't need to reset, because stopped clocks already are // no they aren't!
                    Reset();
                    ClockManager.Clocks.Add(this);
                    break;
            }

            _state = ClockState.Playing;

            if (_beginOffset == 0.0)
            {
                // clocks without BeginOffset update syncronously
                Update(0.0f);
            }
        }
Esempio n. 48
0
        /// <summary>
        /// Called when black is to perform a move.
        /// </summary>
        public void BeginBlackTurn()
        {
            m_currentState = new ClockState(m_whiteTimer.Time, m_blackTimer.Time, m_currentState.SignalTimeout);

              m_blackTimer.Start();
        }
Esempio n. 49
0
        public void Stop()
        {
            switch (State)
            {
                case ClockState.Paused:
                case ClockState.Playing:
                    ClockManager.Clocks.Remove(this);
                    break;
                case ClockState.Stopped:
                    // nothing to do, we're already stopped
                    break;
            }

            State = ClockState.Stopped;
        }
Esempio n. 50
0
        public virtual void Resume()
        {
            switch (_state)
            {
                case ClockState.Paused:
                    ClockManager.Clocks.Add(this);
                    break;
                case ClockState.Playing:
                    // huh? ignore it.
                    break;
                case ClockState.Stopped:
                    ClockManager.Clocks.Add(this);
                    break;
            }

            _state = ClockState.Playing;
        }