private void OpenForm(Key key, PoseCombination poseCombination) { if (poseCombination.IsKeyExist(key)) { poseCombination.ToggleKey(key); } else { KeyMode keyMode = new KeyMode(); DialogResult result = keyMode.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { key.SetKeyMode(keyMode.GetKeyMode()); poseCombination.ToggleKey(key); } } }
public void AddKey(Key key) { _keys.Add(key); }
//移除功能鍵 public void RemoveKey(Key key) { for (int i = 0; i < _keys.Count; i++) { if (_keys[i].GetKeyName() == key.GetKeyName()) _keys.RemoveAt(i); } }
//加入功能鍵,假如有同一種功能鍵重覆加入,則刪除(這邊寫超爛的~"~) public void ToggleKey(Key key) { if (IsKeyExist(key)) { RemoveKey(key); } else { AddKey(key); } }
public bool IsKeyExist(Key key) { return _keys.Exists(item => item.GetKeyName() == key.GetKeyName()); }