public ButtonTag(ICommandTarget target, IToolBarComponent owner, IPoderosaCommand command) : base(owner) { _target = target; _associatedCommand = command; _generalCommand = (IGeneralCommand)command.GetAdapter(typeof(IGeneralCommand)); //取得できなきゃnull }
private void DefineCommandButton(IToolBarComponent comp, IToolBarCommandButton element) { ToolStripButton button = new ToolStripButton(); button.Image = element.Icon; button.Tag = new ButtonTag(GetCommandTarget(), comp, element.Command); button.Size = new Size(24, 23); button.Click += delegate(object sender, EventArgs args) { DoCommand(element.Command); }; IGeneralCommand gc = (IGeneralCommand)element.Command.GetAdapter(typeof(IGeneralCommand)); if (gc != null) { if (!String.IsNullOrEmpty(gc.Description)) { button.ToolTipText = gc.Description; } } else if (!String.IsNullOrEmpty(element.ToolTipText)) { button.ToolTipText = element.ToolTipText; } _currentToolStrip.Items.Add(button); }
//同一キーに重複登録は許さない public void SetKey(IGeneralCommand command, Keys key) { Tag tag = _commandToTag[command]; if (key != Keys.None) { if (_keyToTag.Contains(key)) { throw new ArgumentException("Duplicated Key in KeyBindConfiguration"); } if (tag.Key != Keys.None) { _keyToTag.Remove(tag.Key); } _keyToTag.Add(key, tag); } else //Keys.Noneの設定 { if (tag.Key != Keys.None) { Debug.Assert(_keyToTag.Contains(tag.Key)); _keyToTag.Remove(tag.Key); } } tag.Key = key; }
private void OnAllocateKey(object sender, EventArgs args) { StringResource sr = OptionDialogPlugin.Instance.Strings; if (_keyConfigList.SelectedItems.Count == 0) { return; } IGeneralCommand cmd = _keyConfigList.SelectedItems[0].Tag as IGeneralCommand; Debug.Assert(cmd != null); Keys key = _hotKey.Key; IGeneralCommand existing = _keybinds.FindCommand(key); if (existing != null && existing != cmd) //別コマンドへの割当があったら { if (GUtil.AskUserYesNo(this, String.Format(sr.GetString("Message.OptionDialog.AskOverwriteCommand"), existing.Description)) == DialogResult.No) { return; } _keybinds.SetKey(existing, Keys.None); //既存のやつに割当をクリア FindItemFromTag(existing).SubItems[2].Text = ""; } //設定を書き換え _keybinds.SetKey(cmd, key); _keyConfigList.SelectedItems[0].SubItems[2].Text = FormatKey(key); }
private static int BuildMenuContentsForGroup(int index, ICommandTarget target, ToolStripItemCollection children, IPoderosaMenuGroup grp) { int count = 0; foreach (IPoderosaMenu m in grp.ChildMenus) { ToolStripMenuItem mi = new ToolStripMenuItem(); children.Insert(index++, mi); //途中挿入のことも mi.DropDownOpening += new EventHandler(OnPopupMenu); mi.Enabled = m.IsEnabled(target); mi.Checked = mi.Enabled ? m.IsChecked(target) : false; mi.Text = m.Text; //Enabledを先に mi.Tag = new MenuItemTag(grp, m, target); IPoderosaMenuFolder folder; IPoderosaMenuItem leaf; if ((folder = m as IPoderosaMenuFolder) != null) { BuildMenuContents(mi, folder); } else if ((leaf = m as IPoderosaMenuItem) != null) { mi.Click += new EventHandler(OnClickMenu); IGeneralCommand gc = leaf.AssociatedCommand as IGeneralCommand; if (gc != null) { mi.ShortcutKeyDisplayString = WinFormsUtil.FormatShortcut(CommandManagerPlugin.Instance.CurrentKeyBinds.GetKey(gc)); } } count++; } return(count); }
private static IGeneralCommand BindCommand(string commandID) { IGeneralCommand cmd = CommandManagerPlugin.Instance.Find(commandID); Debug.Assert(cmd != null, commandID + " not found"); return(cmd); }
public void Register(IGeneralCommand command) { string id = command.CommandID; if (id == null || id.Length == 0) throw new ArgumentException("command id must be defined"); if (Find(id) != null) throw new ArgumentException(String.Format("command id {0} is duplicated", id)); //登録数が多いとオーバヘッドになりかねない _commands.Add(command); _idToCommand.Add(id, command); }
public void Register(IGeneralCommand command) { string id = command.CommandID; if (id == null || id.Length == 0) { throw new ArgumentException("command id must be defined"); } if (Find(id) != null) { throw new ArgumentException(String.Format("command id {0} is duplicated", id)); //登録数が多いとオーバヘッドになりかねない } _commands.Add(command); _idToCommand.Add(id, command); }
private void OnKeyMapItemActivated(object sender, EventArgs args) { if (_keyConfigList.SelectedItems.Count == 0) { return; } ListViewItem li = _keyConfigList.SelectedItems[0]; IGeneralCommand cmd = li.Tag as IGeneralCommand; Debug.Assert(cmd != null); _hotKey.Key = _keybinds.GetKey(cmd); _commandName.Text = String.Format("{0} - {1}", cmd.CommandCategory.Name, cmd.Description); _currentCommand.Text = FormatKey(_keybinds.GetKey(cmd)); _allocateKeyButton.Enabled = true; }
public UIHandleResult OnKeyProcess(Keys key) { IGeneralCommand cmd = CommandManagerPlugin.Instance.Find(key); if (cmd != null) { try { if (cmd.CanExecute(_window)) { CommandManagerPlugin.Instance.Execute(cmd, _window); } return(UIHandleResult.Stop); //キーが割り当てられていれば実行ができるかどうかにかかわらずStop。でないとAltキーがらみのときメニューにフォーカスが奪われてしまう } catch (Exception ex) { RuntimeUtil.ReportException(ex); } } return(UIHandleResult.Pass); }
private void Init(string textID, string commandID) { _textID = textID; _command = SSHUtilPlugin.Instance.CommandManager.Find(commandID); Debug.Assert(_command != null); }
//同一キーに重複登録は許さない public void SetKey(IGeneralCommand command, Keys key) { Tag tag = _commandToTag[command]; if (key != Keys.None) { if (_keyToTag.Contains(key)) throw new ArgumentException("Duplicated Key in KeyBindConfiguration"); if (tag.Key != Keys.None) _keyToTag.Remove(tag.Key); _keyToTag.Add(key, tag); } else { //Keys.Noneの設定 if (tag.Key != Keys.None) { Debug.Assert(_keyToTag.Contains(tag.Key)); _keyToTag.Remove(tag.Key); } } tag.Key = key; }
public ShortcutFileToolBarComponent(IGeneralCommand open, IGeneralCommand save) { _openCommand = open; _saveCommand = save; }
public IPoderosaCommand TranslateCommand(IGeneralCommand command) { return(null); }
public Keys GetKey(IGeneralCommand command) { Tag tag = _commandToTag[command]; return tag == null ? Keys.None : tag.Key; }
public Keys GetKey(IGeneralCommand command) { Tag tag = _commandToTag[command]; return(tag == null ? Keys.None : tag.Key); }
public Tag(int index, IGeneralCommand command, Keys key) { _index = index; _command = command; _key = key; }
public IPoderosaCommand TranslateCommand(IGeneralCommand command) { return null; }
public void Register(IGeneralCommand command) { string id = command.CommandID; if (id == null || id.Length == 0) throw new ArgumentException("command id must be defined"); if (Find(id) != null) throw new ArgumentException(String.Format("command id {0} is duplicated", id)); //�o�^���������ƃI�[�o�w�b�h�ɂȂ肩�˂Ȃ� _commands.Add(command); _idToCommand.Add(id, command); }