private object OnButton(Button button) { var keys = ShortcutKeysUtil.Parse(button.Key); if (keys.Length > 0 && !ShortcutKeysUtil.IsValid(keys[0])) { throw new NetIdeException(String.Format(Labels.IllegalButtonShortcutKeys, button.Id, keys)); } INiCommandBarButton command; ErrorUtil.ThrowOnFailure(_commandManager.CreateCommandBarButton( button.Guid != Guid.Empty ? button.Guid : Guid.NewGuid(), button.Priority, button.Id, out command )); command.Text = _package.ResolveStringResource(button.Text); command.ToolTip = _package.ResolveStringResource(button.ToolTip); command.DisplayStyle = Enum <NiCommandDisplayStyle> .Parse(button.Style.ToString()); command.ShortcutKeys = keys.Length > 0 ? keys[0] : 0; ((NiCommandBarButton)command).Bitmap = ResolveBitmapResource(button.Image); return(command); }
private Dictionary <Guid, Keys[]> LoadFromRegistry() { var mappings = new Dictionary <Guid, Keys[]>(); var keys = new List <Keys>(); using (var key = OpenRegistryKey(false)) { if (key != null) { foreach (string name in key.GetValueNames()) { Guid guid; if (Guid.TryParse(name, out guid)) { keys.Clear(); string value = (string)key.GetValue(name); if (!String.IsNullOrEmpty(value)) { foreach (string item in value.Split('|')) { var itemKeys = ShortcutKeysUtil.Parse(item); foreach (var itemKey in itemKeys) { if (!ShortcutKeysUtil.IsValid(itemKey)) { Log.WarnFormat("Skipping illegal shortcut key '{0}' for button '{1}'", itemKey, guid); } else { keys.Add(itemKey); } } } } mappings.Add(guid, keys.ToArray()); } } } } return(mappings); }