public void Add(Macro macro) { macros.Add(macro); keys.Add((Keys)macro.GetKey()); if (keys.Count == 1) hook(); }
public bool Remove(Macro macro) { keys.Remove((Keys)macro.GetKey()); if (keys.Count < 1) unhook(); return macros.Remove(macro); }
//Event - button controller private void GenericButton_Click(object sender, EventArgs e) { Button button = ((Button)sender); GroupBox groupbox = (GroupBox)button.Parent; Validator validator = new Validator(groupbox, this.BackColor, ACTIVE_COLOR); if (validator.Ready() && !ButtonList.Contains(button) && SelectedWindowID > 0) { Macro macro = new Macro(validator.GetProfile(), chk_mode.Checked); ButtonList.Add(button); MacroList.Add(macro); button.Text = "Deactivate"; Lock(true, groupbox); } else if (ButtonList.Contains(button)) { int index = ButtonList.IndexOf(button); Macro macro = MacroList[index]; macro.Destroy(); MacroList.Remove(macro); ButtonList.Remove(button); SetButtonText(button); Lock(false, groupbox); } if (ButtonList.Count > 0) chk_mode.Enabled = false; else chk_mode.Enabled = true; }