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; }
private async void SaveStateBtn_Click(object sender, RoutedEventArgs e) { try { var appState = new ApplicationState(Entries.Select(vm => vm.Model).ToList()); if (await _appStateService.Save(appState, this)) { MessageBox.Show("Stan zapisany"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void TaskAssigned(object obj) { _applicationStateService.Save(); }