private void ShowForm() { m_bIsReminderOpen = false; m_timeForm = new frmTimeEntry(); m_timeForm.FormClosed += new FormClosedEventHandler(m_timeForm_FormClosed); if (tmrCheck.Enabled == false) { //if the timer has been stopped (end of day) then reset the last end date m_dfLastStartDate = DateTime.Now; } //TODO: Check for standard start / stop times and clock state m_timeForm.PopulateScreen(m_currUser, m_lastEntry, tmrCheck.Enabled, m_reminderMilliseconds); //sest the location of the form to be the last location if (m_lastLocation != Point.Empty) { m_timeForm.Location = m_lastLocation; } //set the size of the form to be the last size if (m_lastSize != Size.Empty) { m_timeForm.Size = m_lastSize; } m_timeForm.ShowDialog(this); }
/// <summary> /// Finalisation of form closing procedure /// </summary> private void FinaliseFormClose() { if (m_timeForm != null) { //remember the last saved entry m_lastEntry = m_timeForm.LastSavedEntry; if (m_timeForm != null) { //if we get more properties, might have to retrieve, but for now just construct a new one each time for efficiency LocalSettings settings = new LocalSettings(); //if the save button was clicked, update the indicator values if (m_timeForm.LastSavedEntry != null) { m_currProject = m_timeForm.SelectedProject; m_currTask = m_timeForm.SelectedTask; m_dfLastStartDate = m_timeForm.StartTime; settings.LastTimeEntryId = m_timeForm.LastSavedEntry.TimeEntryId; } else { if (m_currProject != null) { //if we were previously working on something, set the last start date to now //so that while the clock is stopped it keeps this time m_dfLastStartDate = DateTime.Now; } m_currProject = null; m_currTask = null; settings.LastTimeEntryId = Guid.Empty; } //set the reminder interval settings.LastReminderPeriodInMilliseconds = m_timeForm.ReminderMilliseconds; OperationsReadWrite.SaveLocalSettings(settings); } //set the reminder milliseconds m_reminderMilliseconds = m_timeForm.ReminderMilliseconds; //set enabled status on timer tmrCheck.Enabled = m_timeForm.AreRemindersOn; //update the last reminder time m_dtLastReminder = DateTime.Now; m_bWasIgnored = false; m_dtLastShow = DateTime.Now; //remember the location and size if (m_timeForm != null) { m_lastLocation = m_timeForm.Location; m_lastSize = m_timeForm.Size; m_timeForm.Dispose(); m_timeForm = null; } } }