Exemple #1
0
        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("");
        }
Exemple #2
0
 private void Cancelbutton_Click(object sender, EventArgs e)
 {
     CustomButton[] a = current_preset.buttons.Where(x => x.Id == currentButton.Id).ToArray();
     if (a.Length == 0)
     {
         delete_button_from_panel(currentButton);
     }
     else if (a.Length == 1)
     {
         CustomButton target_button = a[0];
         CustomButton.OverWrite(currentButton, target_button);
         currentButton.property_watcher = false;
         disable_editpanel_events();
         ButtonTextBox.Text          = currentButton.Text;
         ButtonParametersBox.Text    = currentButton.Parameters;
         Action_typeBox.SelectedItem = currentButton.action_type.ToString();
         enable_editpanel_events();
     }
     else
     {
         throw new Exception("Identity problem");
     }
 }
Exemple #3
0
 private void CancelAll_Click(object sender, EventArgs e)
 {
     CustomButton[] panel_buttons = Panel.Controls.OfType <CustomButton>().ToArray();
     foreach (CustomButton button in panel_buttons)
     {
         if (button.property_watcher)
         {
             CustomButton[] a = current_preset.buttons.Where(x => x.Id == button.Id).ToArray();
             if (a.Length == 0)
             {
                 delete_button_from_panel(button);
             }
             else if (a.Length == 1)
             {
                 CustomButton.OverWrite(button, a[0]);
                 button.property_watcher = false;
             }
             else if (a.Length > 1)
             {
                 throw new Exception("Identity problem");
             }
         }
     }
 }