private void AddTime_Click(object sender, RoutedEventArgs e)
        {
            // Ironically I don't have time to think of a proper solution for adjusting
            // the time of an entry.
            // Since the total duration is calculated each time, we can use a variable offset.

            if (this.popup != null)
            {
                this.popup.Close();
                this.popup = null;
            }
            this.popup              = new EditTime();
            popup.ParentWindow      = this;
            popup.SelectedTimeEntry = SelectedTimeEntry;

            // pending to be saved / tentative changes applied
            decimal pendingHours = decimal.Parse(SelectedTimeEntry.ToView(0).Hours) +
                                   PendingOffset;

            popup.NewHours.Text = pendingHours.ToString();
            popup.Show();
            popup.Focus();
            popup.NewHours.Focus();
            popup.NewHours.SelectAll();
        }
        public bool CloseWithoutSave()
        {
            if (SelectedTimeEntry == null)
            {
                return(true);
            }

            bool changeDetected = SelectedTimeEntry.Name != NameField.Text ||
                                  SelectedTimeEntry.Details != DetailsField.Text;

            if (changeDetected)
            {
                var confirmResult = MessageBox.Show("Close without saving?", "Close Confirmation",
                                                    MessageBoxButton.OKCancel);

                if (confirmResult == MessageBoxResult.Cancel)
                {
                    return(false);
                }
            }

            this.Hide();
            if (this.popup != null)
            {
                this.popup.Close();
                this.popup = null;
            }

            MainWindow.Show();
            MainWindow.Focus();
            return(true);
        }