private static TreeNode FindAction(Action action, TreeNodeCollection list) { foreach (TreeNode test in list) { if (test != null && action.Equals(test.Tag)) { return(test); } TreeNode found = FindAction(action, test.Nodes); if (found != null) { return(found); } } return(null); }
public void btnSetKey_Click(object sender, EventArgs e) { if (tvActions.SelectedAction.IsEmpty || m_DisplayedKey == Keys.None) { return; } Functions.Action action = tvActions.SelectedAction; Functions.Action existing = m_Applied.KeyAction(m_DisplayedKey); if (action.Equals(existing)) { return; } if (!existing.IsEmpty) { if (GUIUtilities.QuestionBox(Strings.Item("Config_KeyReplaceWarning").Replace("%0", lblKeyCurrent.Text), MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } } List <Keys> keys = m_Applied.GetKeysForAction(action); if (keys != null && keys.Count == 1 && keys[0] != m_DisplayedKey) { if (GUIUtilities.QuestionBox(Strings.Item("Config_KeyRemoveExisting").Replace("%0", GUIUtilities.KeyDescription(keys[0])), MessageBoxButtons.YesNo) == DialogResult.Yes) { m_Config.Write(Config.KeyKey(keys[0]), ""); } } m_Config.Write(Config.KeyKey(m_DisplayedKey), action.ToString()); WrittenToCurrent(); m_Applied.DiscardKeyLookup(); DisplayKey(m_DisplayedKey); tvActions_AfterSelect(this, null); m_KeyActionChanged = false; m_KeyIsChanged = false; }