コード例 #1
0
 public ButtonTag(ICommandTarget target, IToolBarComponent owner, IPoderosaCommand command)
     : base(owner)
 {
     _target            = target;
     _associatedCommand = command;
     _generalCommand    = (IGeneralCommand)command.GetAdapter(typeof(IGeneralCommand)); //取得できなきゃnull
 }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: CommandManager.cs プロジェクト: yueker/poderosa
        //同一キーに重複登録は許さない
        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;
        }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: MenuUtil.cs プロジェクト: yueker/poderosa
        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);
        }
コード例 #6
0
        private static IGeneralCommand BindCommand(string commandID)
        {
            IGeneralCommand cmd = CommandManagerPlugin.Instance.Find(commandID);

            Debug.Assert(cmd != null, commandID + " not found");
            return(cmd);
        }
コード例 #7
0
ファイル: CommandManager.cs プロジェクト: Ricordanza/poderosa
        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);
        }
コード例 #8
0
ファイル: CommandManager.cs プロジェクト: yueker/poderosa
        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);
        }
コード例 #9
0
        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;
        }
コード例 #10
0
ファイル: MainWindow.cs プロジェクト: yueker/poderosa
        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);
        }
コード例 #11
0
ファイル: ToolBar.cs プロジェクト: FNKGino/poderosa
 public ButtonTag(ICommandTarget target, IToolBarComponent owner, IPoderosaCommand command)
     : base(owner)
 {
     _target = target;
     _associatedCommand = command;
     _generalCommand = (IGeneralCommand)command.GetAdapter(typeof(IGeneralCommand)); //取得できなきゃnull
 }
コード例 #12
0
ファイル: SSHUtilPlugin.cs プロジェクト: FNKGino/poderosa
 private void Init(string textID, string commandID)
 {
     _textID = textID;
     _command = SSHUtilPlugin.Instance.CommandManager.Find(commandID);
     Debug.Assert(_command != null);
 }
コード例 #13
0
 private void Init(string textID, string commandID)
 {
     _textID  = textID;
     _command = SSHUtilPlugin.Instance.CommandManager.Find(commandID);
     Debug.Assert(_command != null);
 }
コード例 #14
0
ファイル: CommandManager.cs プロジェクト: Ricordanza/poderosa
        //同一キーに重複登録は許さない
        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;

        }
コード例 #15
0
 public ShortcutFileToolBarComponent(IGeneralCommand open, IGeneralCommand save)
 {
     _openCommand = open;
     _saveCommand = save;
 }
コード例 #16
0
ファイル: TextSelection.cs プロジェクト: takano32/poderosa
 public IPoderosaCommand TranslateCommand(IGeneralCommand command)
 {
     return(null);
 }
コード例 #17
0
ファイル: CommandManager.cs プロジェクト: Ricordanza/poderosa
 public Keys GetKey(IGeneralCommand command) {
     Tag tag = _commandToTag[command];
     return tag == null ? Keys.None : tag.Key;
 }
コード例 #18
0
 public ShortcutFileToolBarComponent(IGeneralCommand open, IGeneralCommand save)
 {
     _openCommand = open;
     _saveCommand = save;
 }
コード例 #19
0
ファイル: CommandManager.cs プロジェクト: yueker/poderosa
        public Keys GetKey(IGeneralCommand command)
        {
            Tag tag = _commandToTag[command];

            return(tag == null ? Keys.None : tag.Key);
        }
コード例 #20
0
ファイル: CommandManager.cs プロジェクト: yueker/poderosa
 public Tag(int index, IGeneralCommand command, Keys key)
 {
     _index   = index;
     _command = command;
     _key     = key;
 }
コード例 #21
0
ファイル: TextSelection.cs プロジェクト: VirusFree/Poderosa
 public IPoderosaCommand TranslateCommand(IGeneralCommand command)
 {
     return null;
 }
コード例 #22
0
ファイル: CommandManager.cs プロジェクト: VirusFree/Poderosa
        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);
        }
コード例 #23
0
ファイル: CommandManager.cs プロジェクト: Ricordanza/poderosa
 public Tag(int index, IGeneralCommand command, Keys key) {
     _index = index;
     _command = command;
     _key = key;
 }