コード例 #1
0
        private TimeWarpUserState SaveNewState(Account account, DateTime time, TimeWarpState timeWarpState, int agentType)
        {
            var updatedState = new TimeWarpUserState(account, timeWarpState, time, TimeSpan.Zero, 0.0, agentType);

            _userStateRepository.Add(updatedState);
            return(updatedState);
        }
コード例 #2
0
        private void OnTimerCallback(object state)
        {
            var info          = _userStateService.GetUserState();
            var previousState = CurrentTimeWarpState;

            CurrentTimeWarpState = info.State;
            MinutesRemaining     = info.TimeLeft.Minutes;

            if (info.State == TimeWarpState.Resting && previousState == TimeWarpState.Working)
            {
                OnUserStateChanged(UserMessage.TakeABreak);
            }

            if (info.State == TimeWarpState.None && previousState == TimeWarpState.Resting)
            {
                OnUserStateChanged(UserMessage.TimeToWork);
            }

            if (info.State == TimeWarpState.Working && previousState != TimeWarpState.Working)
            {
                OnUserStateChanged(UserMessage.Working);
            }

            OnTimeChanged(MinutesRemaining);
            _timer.Change(RefreshPeriod, TimeSpan.Zero);
        }
コード例 #3
0
 public UserStateInfo(long accountId, TimeWarpState state, DateTime periodStartTime,
                      TimeSpan timeLeft, double progress)
 {
     AccountId       = accountId;
     State           = state;
     PeriodStartTime = periodStartTime;
     TimeLeft        = timeLeft;
     Progress        = progress;
 }
コード例 #4
0
 public TimeWarpUserState(Account account, TimeWarpState state, DateTime periodStartTime, TimeSpan timeLeft, double progress, int agentType)
 {
     Account         = account;
     State           = state;
     PeriodStartTime = periodStartTime;
     TimeLeft        = timeLeft;
     Progress        = progress;
     AgentType       = agentType;
 }
コード例 #5
0
        public string Get(TimeWarpState timeWarpState, int minutesRemaining)
        {
            if (timeWarpState == TimeWarpState.None)
            {
                return("Team Time Warp");
            }

            return(string.Concat(timeWarpState.ToString(), ' ', minutesRemaining, " mins remaining"));
        }
コード例 #6
0
 public UserStateInfoResponse(long accountId, string username, DateTime queryTime, TimeWarpState state, DateTime periodStartTime,
                              TimeSpan timeLeft, double progress, bool isQuickLoginUser, TimeWarpAgent timeWarpAgent)
 {
     AccountId        = accountId;
     QueryTime        = queryTime;
     State            = state;
     PeriodStartTime  = periodStartTime;
     TimeLeft         = timeLeft;
     Progress         = progress;
     Username         = username;
     IsQuickLoginUser = isQuickLoginUser;
     TimeWarpAgent    = timeWarpAgent;
 }
コード例 #7
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            TimeWarpState pomodoroState = (TimeWarpState)value;

            switch (pomodoroState)
            {
            case TimeWarpState.Resting:
                return(Brushes.Green);

            case TimeWarpState.Working:
                return(Brushes.Red);

            case TimeWarpState.None:
                return(Brushes.Silver);
            }

            throw new ArgumentOutOfRangeException();
        }
コード例 #8
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            TimeWarpState pomodoroState = (TimeWarpState)value;

            switch (pomodoroState)
            {
            case TimeWarpState.Resting:
                return(new SolidColorBrush(Colors.Green));;

            case TimeWarpState.Working:
                return(new SolidColorBrush(Colors.Red));;

            case TimeWarpState.None:
                return(new SolidColorBrush(Colors.DarkGray));
            }

            throw new ArgumentOutOfRangeException();
        }
コード例 #9
0
        private void HandleQueryUserStatusCompleted(object sender, AsyncCompletedEventArgs <UserStateInfoResponse> e)
        {
            if (e.Error != null)
            {
                OnError(e.Error);
            }

            if (e.Result != null)
            {
                var info          = e.Result;
                var previousState = CurrentTimeWarpState;

                CurrentTimeWarpState = info.State;
                MinutesRemaining     = info.TimeLeft.Minutes;

                if (info.State == TimeWarpState.Resting && previousState == TimeWarpState.Working)
                {
                    OnUserStateChanged(TimeWarpStateUserMessage.TakeABreak, info.TimeWarpAgent);
                }

                if (info.State == TimeWarpState.None && previousState == TimeWarpState.Resting)
                {
                    OnUserStateChanged(TimeWarpStateUserMessage.TimeToWork, info.TimeWarpAgent);
                }

                if (info.State == TimeWarpState.Working && previousState != TimeWarpState.Working)
                {
                    OnUserStateChanged(TimeWarpStateUserMessage.Working, info.TimeWarpAgent);
                }

                OnTimeChanged(MinutesRemaining);
            }

            lock (_disposeTimer)
            {
                if (_timer != null)
                {
                    _timer.Change(RefreshPeriod, TimeSpan.Zero); //todo fix dispose
                }
            }
        }
コード例 #10
0
        private void OnTimerCallback(object state)
        {
            var info = _userStateService.GetUserState();//in try catch?

            if (info != null)
            {
                var previousState = CurrentTimeWarpState;

                CurrentTimeWarpState = info.State;
                MinutesRemaining     = info.TimeLeft.Minutes;

                if (info.State == TimeWarpState.Resting && previousState == TimeWarpState.Working)
                {
                    OnUserStateChanged(UserMessage.TakeABreak, info.TimeWarpAgent);
                }

                if (info.State == TimeWarpState.None && previousState == TimeWarpState.Resting)
                {
                    OnUserStateChanged(UserMessage.TimeToWork, info.TimeWarpAgent);
                }

                if (info.State == TimeWarpState.Working && previousState != TimeWarpState.Working)
                {
                    OnUserStateChanged(UserMessage.Working, info.TimeWarpAgent);
                }

                OnTimeChanged(MinutesRemaining);
            }

            lock (_disposeTimer)
            {
                if (_timer != null)
                {
                    _timer.Change(RefreshPeriod, TimeSpan.Zero); //todo fix dispose
                }
            }
        }
コード例 #11
0
 public TimeWarp(TimeWarpState state, float speed)
 {
     State = state;
     Speed = speed;
 }
コード例 #12
0
 public Icon Get(TimeWarpState timeWarpState)
 {
     return(timeWarpState == (TimeWarpState.Working)
                ? new Icon(Path.Combine(Environment.CurrentDirectory, "Working.ico"), 40, 40)
                : new Icon(Path.Combine(Environment.CurrentDirectory, "Transmission.ico"), 40, 40));
 }