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); }
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); }
public UserStateInfo(long accountId, TimeWarpState state, DateTime periodStartTime, TimeSpan timeLeft, double progress) { AccountId = accountId; State = state; PeriodStartTime = periodStartTime; TimeLeft = timeLeft; Progress = progress; }
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; }
public string Get(TimeWarpState timeWarpState, int minutesRemaining) { if (timeWarpState == TimeWarpState.None) { return("Team Time Warp"); } return(string.Concat(timeWarpState.ToString(), ' ', minutesRemaining, " mins remaining")); }
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; }
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(); }
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(); }
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 } } }
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 } } }
public TimeWarp(TimeWarpState state, float speed) { State = state; Speed = speed; }
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)); }