Esempio n. 1
0
        protected override void Dispose(bool disposing)
        {
            TaskCommands.PauseActiveTask.UnregisterCommand(Pause);
            TaskCommands.ToggleActiveTask.UnregisterCommand(ToggleState);
            TaskCommands.StopActiveTask.UnregisterCommand(Stop);
            TaskCommands.TaskAssigned.UnregisterCommand(TaskAssigned);
            TaskCommands.SaveTaskCompleted.UnregisterCommand(TaskAssigned);
            TaskCommands.AssignTask.UnregisterCommand(ReAssign);

            TimerService.Dispose();
        }
Esempio n. 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;
        }