Exemplo n.º 1
0
 public ButtonTag(ICommandTarget target, IToolBarComponent owner, IPoderosaCommand command)
     : base(owner)
 {
     _target            = target;
     _associatedCommand = command;
     _generalCommand    = (IGeneralCommand)command.GetAdapter(typeof(IGeneralCommand)); //取得できなきゃnull
 }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        //同一キーに重複登録は許さない
        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;
        }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        private static IGeneralCommand BindCommand(string commandID)
        {
            IGeneralCommand cmd = CommandManagerPlugin.Instance.Find(commandID);

            Debug.Assert(cmd != null, commandID + " not found");
            return(cmd);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 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;
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
 public ButtonTag(ICommandTarget target, IToolBarComponent owner, IPoderosaCommand command)
     : base(owner)
 {
     _target = target;
     _associatedCommand = command;
     _generalCommand = (IGeneralCommand)command.GetAdapter(typeof(IGeneralCommand)); //取得できなきゃnull
 }
Exemplo n.º 12
0
 private void Init(string textID, string commandID)
 {
     _textID = textID;
     _command = SSHUtilPlugin.Instance.CommandManager.Find(commandID);
     Debug.Assert(_command != null);
 }
Exemplo n.º 13
0
 private void Init(string textID, string commandID)
 {
     _textID  = textID;
     _command = SSHUtilPlugin.Instance.CommandManager.Find(commandID);
     Debug.Assert(_command != null);
 }
Exemplo n.º 14
0
        //同一キーに重複登録は許さない
        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;

        }
Exemplo n.º 15
0
 public ShortcutFileToolBarComponent(IGeneralCommand open, IGeneralCommand save)
 {
     _openCommand = open;
     _saveCommand = save;
 }
Exemplo n.º 16
0
 public IPoderosaCommand TranslateCommand(IGeneralCommand command)
 {
     return(null);
 }
Exemplo n.º 17
0
 public Keys GetKey(IGeneralCommand command) {
     Tag tag = _commandToTag[command];
     return tag == null ? Keys.None : tag.Key;
 }
Exemplo n.º 18
0
 public ShortcutFileToolBarComponent(IGeneralCommand open, IGeneralCommand save)
 {
     _openCommand = open;
     _saveCommand = save;
 }
Exemplo n.º 19
0
        public Keys GetKey(IGeneralCommand command)
        {
            Tag tag = _commandToTag[command];

            return(tag == null ? Keys.None : tag.Key);
        }
Exemplo n.º 20
0
 public Tag(int index, IGeneralCommand command, Keys key)
 {
     _index   = index;
     _command = command;
     _key     = key;
 }
Exemplo n.º 21
0
 public IPoderosaCommand TranslateCommand(IGeneralCommand command)
 {
     return null;
 }
Exemplo n.º 22
0
        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);
        }
Exemplo n.º 23
0
 public Tag(int index, IGeneralCommand command, Keys key) {
     _index = index;
     _command = command;
     _key = key;
 }