예제 #1
0
 public DesktopTaskViewModel(TimeEntryTimerService timeEntryTimerService)
 {
     _timeEntryTimerService = timeEntryTimerService;
     _timeEntryTimerService.TimeEntryUpdated += new EventHandler(_timeEntryTimerService_TimeEntryUpdated);
     _timeEntry       = _timeEntryTimerService.TimeEntry;
     ToolTipViewModel = new TaskToolTipViewModel(_timeEntry);
 }
예제 #2
0
        private void InitializeTimer(TimeEntry timeEntry)
        {
            //if the given is null, create a new timer based on the existing timeentry (with same task and project)
            if (timeEntry == null)
            {
                TimeEntry = TimeEntry.Create(TimeEntry);
            }
            //If time is zero, start a new timer based on the given timeentry (with same task and project)
            else if (timeEntry.TimeSpent == TimeSpan.Zero)
            {
                TimeEntry = TimeEntry.Create(timeEntry);
            }
            //Else just continue the timer on the current timeentry
            else
            {
                TimeEntry = timeEntry;
            }
            if (TimerService != null)
            {
                TimerService.Dispose();
                TimerService = null;
            }
            if (ToolTipViewModel == null)
            {
                ToolTipViewModel = new TaskToolTipViewModel(TimeEntry);
            }
            else
            {
                ToolTipViewModel.Update(TimeEntry);
            }
            _applicationStateService.CurrentState.ActiveTimeEntry = TimeEntry;
            _applicationStateService.Save();

            TimerService = new TimeEntryTimerService(TimeEntry);
            TimerService.TimeEntryUpdated  += _timeEntryTimerService_TimeEntryUpdated;
            TimerService.TimerStateChanged += _timeEntryTimerService_TimerStateChanged;
        }