예제 #1
0
 private void timerPreview_LoadRequested(object sender, SettingIOEventArgs e)
 {
     string settingsCsv = this.ptsToolStrip.PresetManager.LoadSetting(e.SettingName);
     if (settingsCsv != string.Empty)
     {
         var timerPreview = sender as TimerPreview;
         if (timerPreview != null)
         {
             timerPreview.Settings = TimerViewSettings.ParseCsv(settingsCsv);
         }
     }
 }
예제 #2
0
        private void timerPreview_SaveRequested(object sender, SettingIOEventArgs e)
        {
            TimerPreview preview = sender as TimerPreview;
            if (preview == null)
            {
                return;
            }

            var success = true;
            try
            {
                var name = e.SettingName;
                if (this.ptsToolStrip.PresetManager.HasSetting(name))
                {
                    var result = MessageBox.Show(
                        "A setting with the name '" + name + "' already exists.\r\n" +
                        "Do you wish to update the existing timer settings?\r\n\r\n" +
                        "Select 'Cancel' to choose a new name",
                        "Setting Already Exists",
                        MessageBoxButtons.OKCancel,
                        MessageBoxIcon.Information,
                        MessageBoxDefaultButton.Button2);

                    if (result != System.Windows.Forms.DialogResult.OK)
                    {
                        return;
                    }
                }
                else
                {
                    this.AddPresetsToPreviews(name);
                }

                success = this.ptsToolStrip.PresetManager.AddOrUpdateSetting(new KeyValuePair<string, string>(name, e.Settings.SaveSettingsAsCsv()));
                preview.DisplayName = name;
            }
            catch
            {
                success = false;
            }

            if (!success)
            {
                MessageBox.Show("Could not save setting. Please try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }