Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        private void timerPreview_LoadRequested(object sender, SettingIOEventArgs e)
        {
            var setting = this.savedTimersToolStripItem.SettingsManager.Fetch(e.SettingPair.Id);

            if (setting != null)
            {
                var timerPreview = sender as TimerPreview;
                if (timerPreview != null)
                {
                    timerPreview.Settings = setting;
                }
            }
        }