private bool UsedInMenuOrSameScreen(AccelKey newKey) { TreeIter selectedRow = GetSelectedRow(); string selectedName = (string)treeViewMenu.Model.GetValue(selectedRow, 2); string selectedType = (string)treeViewMenu.Model.GetValue(selectedRow, 3); TreeIter ownerRow = TreeIter.Zero; treeViewMenu.Model.Foreach((model, path, row) => { string name = (string)model.GetValue(row, 2); if (selectedName == name) { return(false); } string type = (string)model.GetValue(row, 3); AccelKey key = KeyShortcuts.LookupEntry(name); // when comparing with menus, ignore paths containing a '/' because menus do not have such (in incomplete paths) if (selectedType == type && (selectedType != KeyShortcuts.MENU_NEIGHBOURING_SHORTCUT || !name.Contains("/")) && KeyShortcuts.KeyEqual((uint)newKey.Key, (uint)key.Key) && newKey.AccelMods == key.AccelMods) { ownerRow = row; return(true); } return(false); }); if (!ownerRow.Equals(TreeIter.Zero)) { string translation = Translator.GetString("The selected shortcut is already used for the \"{0}\" menu item. " + "Do you want to remove the shortcut for \"{0}\" to reassign it?"); string message = string.Format(translation, treeViewMenu.Model.GetValue(ownerRow, 0)); if (Message.ShowDialog(Translator.GetString("Warning!"), string.Empty, message, "Icons.Question32.png", MessageButtons.YesNo) == ResponseType.Yes) { string ownerItem = (string)treeViewMenu.Model.GetValue(ownerRow, 2); ApplyShortcut(ownerItem, new AccelKey(Key.VoidSymbol, ModifierType.None, AccelFlags.Visible)); treeViewMenu.Model.SetValue(ownerRow, 1, KeyShortcuts.KeyToString(AccelKey.Zero)); return(false); } return(true); } return(false); }