private void timerPreview_SaveRequested(object sender, SettingIOEventArgs e) { TimerPreview preview = sender as TimerPreview; if (preview == null) { return; } var success = true; try { var id = e.Settings.Id; // Fetch the current name for the timer to be saved var currentName = e.Settings.Name; if (currentName != null && !TimerSettings.IsUntitled(currentName)) { var settingsManager = this.savedTimersToolStripItem.SettingsManager; // Fetch the old name for this timer in case it has been changed ////var oldName = settingsManager.Fetch(id).Name; // Update and save this timer settingsManager.AddOrUpdate(e.Settings); preview.Settings = settingsManager.Save(id); this.AddSavedTimersToPreviews(preview.Settings.Id, preview.Settings.Name); ////// Now, get the possible new Id ////var newId = preview.Settings.Id; ////// If the name has changed, remove it from the preview lists ////if (!oldName.Equals(currentName)) ////{ //// // Removed the old name from the dropdown and add the new name in //// this.ClearPresetFromPreviews(id, oldName); //// this.AddSavedTimersToPreviews(newId, currentName); ////} } } catch (Exception) { success = false; } if (!success) { MessageBox.Show("Could not save setting. Please try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void SaveSettings() { var name = this.Settings.Name; if (name != null && !TimerSettings.IsUntitled(name)) { this.OnSaveRequested(this.Settings); this.btnSave.BackgroundImage = ControlPanel.SaveImage; this.savePending = false; } else { MessageBox.Show("Please enter a name for this timer"); } }