/// <summary> /// Event called when the application is about to exit. /// Saves the current window and activity. /// </summary> /// <param name="sender">The class that sent the event</param> /// <param name="e">The event</param> private void Application_Exit(object sender, ExitEventArgs e) { if (AppStateTracker != null) { AppStateTracker.SaveCurrentWindow(); AppStateTracker.SaveCurrentActivity(); } }
/// <summary> /// Changes the current activity and saves the old one. /// Closes the dialog afterwards. /// </summary> /// <param name="name">The name if the new activity. Leave it empty if the name of the last activity should be used.</param> /// <param name="confirmClicked">True, if the confirm button was clicked.</param> private void SetNewActivity(string name = null, bool confirmClicked = false) { if (AppStateTracker.CurrentActivity == null || !ComboBox.Text.Equals(AppStateTracker.CurrentActivity.Name)) { AppStateTracker.SaveCurrentActivity(); AppStateTracker.CreateCurrentActivity(name ?? DefaultName, ToDate); if (confirmClicked) { AppStateTracker.LastConfirmed = DateTime.Now; } } if (this.IsLoaded) // Can only close if the window still exists { this.Close(); } }
/// <summary> /// Sets the activity for the time while the users was away. /// Closes the dialog afterwards. /// </summary> /// <param name="name">The name of the activity</param> private void SetNewActivity(string name) { AppStateTracker.CreateCurrentActivity(name, FromDate); AppStateTracker.SaveCurrentActivity(ToDate); Close(); }