private string apply_changes_to_button(CustomButton customButton) { List <IAction> actions_storage = customButton.actions.ToList(); customButton.actions.Clear(); string error_message = parse_button_command(customButton); if (error_message != "") { customButton.actions = actions_storage; return(error_message); } CustomButton target_button; var a = current_preset.buttons.Where(x => x.Id == customButton.Id).ToArray(); if (a.Length == 0) { target_button = new CustomButton(); current_preset.buttons.Add(target_button); if (current_preset == buttons_form.current_preset) { buttons_form.add_button_if_auto_switch_disabled(target_button); } Saver.save_button_settings(current_preset.name, customButton, true); } else if (a.Length == 1) { target_button = a[0]; Saver.save_button_settings(current_preset.name, customButton, false); } else { throw new Exception("Identity problem"); } CustomButton.OverWrite(target_button, customButton); customButton.property_watcher = false; return(""); }
private void OKButton_Click(object sender, EventArgs e) { Preset preset = settings.presets.Where(x => x.name == comboBox1.SelectedItem.ToString()).Single(); CustomButton button = settings.currentButton.Clone(); button.Location = new Point(0, 0); if (!PreservebackcolorcheckBox.Checked) { button.BackColor = preset.default_backcolor; } if (!PreservetextcolorcheckBox.Checked) { button.ForeColor = preset.default_textcolor; } if (!PreservefontcheckBox.Checked) { button.Font = preset.default_font; } if (preset == settings.current_preset) { button.Id = settings.get_new_id(); settings.add_button_to_panel(button.Clone()); } else { button.Id = settings.get_new_id(preset); } if (preset == buttons_form.current_preset) { buttons_form.add_button_if_auto_switch_disabled(button); } preset.buttons.Add(button); Saver.save_button_settings(preset.name, button, true); this.Close(); }