Ejemplo n.º 1
0
        public static void Register(IPluginManager pm, ICommandManager cm)
        {
            StringResource     sr      = TEnv.Strings;
            ICommandCategory   filecat = cm.CommandCategories.File;
            GeneralCommandImpl open    = new GeneralCommandImpl("org.poderosa.sessions.openShortcutFile", sr, "Command.OpenShortcutFile", filecat, new ExecuteDelegate(OpenShortcutFile));
            GeneralCommandImpl save    = new GeneralCommandImpl("org.poderosa.sessions.saveShortcutFile", sr, "Command.SaveShortcutFile", filecat, new ExecuteDelegate(SaveShortcutFile),
                                                                delegate(ICommandTarget target) {
                return(TerminalCommandTarget.AsTerminal(target) != null);
            });

            cm.Register(open);
            cm.Register(save);

            IExtensionPoint filemenu = pm.FindExtensionPoint("org.poderosa.menu.file");

            filemenu.RegisterExtension(new PoderosaMenuGroupImpl(new IPoderosaMenu[] {
                new PoderosaMenuItemImpl(open, sr, "Menu.OpenShortcutFile"),
                new PoderosaMenuItemImpl(save, sr, "Menu.SaveShortcutFile")
            }).SetPosition(PositionType.NextTo, CygwinPlugin.Instance.CygwinMenuGroupTemp));

            ShortcutFileToolBarComponent tb = new ShortcutFileToolBarComponent(open, save);

            pm.FindExtensionPoint("org.poderosa.core.window.toolbar").RegisterExtension(tb);
            TerminalSessionsPlugin.Instance.SessionManager.AddActiveDocumentChangeListener(tb);
        }
Ejemplo n.º 2
0
        public CommandResult Invoke(ICommandCategory category, ICommandContext context, string[] parameters, uint depth)
        {
            var additionalParameterCount = parameters.Length - depth;

            if (additionalParameterCount < additionalParameterConverters.Count)
            {
                return(CommandResult.Parameter);
            }

            var parameterObjects = new List <object> {
                category, context
            };

            for (int i = 0; i < additionalParameterConverters.Count; i++)
            {
                if (!additionalParameterConverters[i].TryConvert(parameters[depth + i], out object result))
                {
                    return(CommandResult.Parameter);
                }

                parameterObjects.Add(result);
            }

            handlerDelegate.DynamicInvoke(parameterObjects.ToArray());
            return(CommandResult.Ok);
        }
Ejemplo n.º 3
0
        public override void InitializePlugin(IPoderosaWorld poderosa)
        {
            base.InitializePlugin(poderosa);

#if USING_GENERIC_COMMAND
            //"ダイアログ"コマンドカテゴリを取得
            ICoreServices    cs     = (ICoreServices)poderosa.GetAdapter(typeof(ICoreServices));
            ICommandCategory dialog = cs.CommandManager.CommandCategories.Dialogs;

            //コマンド作成
            GeneralCommandImpl cmd = new GeneralCommandImpl("org.poderosa.helloworld", "Hello World Command", dialog, delegate(ICommandTarget target) {
                //コマンドの実装
                //このコマンドはメインメニューから起動するので、CommandTargetからウィンドウが取得できるはず
                IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));
                Debug.Assert(window != null);
                MessageBox.Show(window.AsForm(), "Hello World", "HelloWorld Plugin");
                return(CommandResult.Succeeded);
            });
            //コマンドマネージャへの登録
            cs.CommandManager.Register(cmd);

            //ヘルプメニューに登録
            IExtensionPoint helpmenu = poderosa.PluginManager.FindExtensionPoint("org.poderosa.menu.help");
            helpmenu.RegisterExtension(new PoderosaMenuGroupImpl(new PoderosaMenuItemImpl("org.poderosa.helloworld", "Hello World")));
#else //単なるIPoderosaCommand版
            //コマンド作成
            PoderosaCommandImpl cmd = new PoderosaCommandImpl(delegate(ICommandTarget target) {
                //コマンドの実装
                //このコマンドはメインメニューから起動するので、CommandTargetからウィンドウが取得できるはず
                IPoderosaMainWindow window = (IPoderosaMainWindow)target.GetAdapter(typeof(IPoderosaMainWindow));
                Debug.Assert(window != null);
                MessageBox.Show(window.AsForm(), "Hello World", "HelloWorld Plugin");
                return(CommandResult.Succeeded);
            });

            //ヘルプメニューに登録
            IExtensionPoint helpmenu = poderosa.PluginManager.FindExtensionPoint("org.poderosa.menu.help");
            helpmenu.RegisterExtension(new PoderosaMenuGroupImpl(new PoderosaMenuItemImpl(cmd, "Hello World")));
#endif
        }
Ejemplo n.º 4
0
        private void InitKeyConfigUI()
        {
            _keyConfigList.Items.Clear();

            //列挙してソート
            TypedHashtable <ICommandCategory, List <IGeneralCommand> > category_list = new TypedHashtable <ICommandCategory, List <IGeneralCommand> >();

            foreach (IGeneralCommand cmd in _keybinds.Commands)
            {
                ICommandCategory cat = cmd.CommandCategory;
                if (cat != null && cat.IsKeybindCustomizable)
                {
                    if (category_list.Contains(cat))
                    {
                        category_list[cat].Add(cmd);
                    }
                    else
                    {
                        List <IGeneralCommand> l = new List <IGeneralCommand>();
                        l.Add(cmd);
                        category_list.Add(cat, l);
                    }
                }
            }

            ICollection result = PositionDesignationSorter.SortItems(category_list.Keys);

            foreach (ICommandCategory cat in result)
            {
                foreach (IGeneralCommand cmd in category_list[cat])
                {
                    ListViewItem li = new ListViewItem(cat.Name);
                    li = _keyConfigList.Items.Add(li);
                    li.SubItems.Add(cmd.Description);
                    li.SubItems.Add(FormatKey(_keybinds.GetKey(cmd)));
                    li.Tag = cmd;
                }
            }
        }
Ejemplo n.º 5
0
        public override void InitializePlugin(IPoderosaWorld poderosa)
        {
            base.InitializePlugin(poderosa);

            _instance       = this;
            _stringResource = new StringResource("Poderosa.Usability.strings", typeof(OptionDialogPlugin).Assembly);
            poderosa.Culture.AddChangeListener(this);
            IPluginManager pm = poderosa.PluginManager;

            _coreServices = (ICoreServices)poderosa.GetAdapter(typeof(ICoreServices));

            IExtensionPoint panel_ext = pm.CreateExtensionPoint(OPTION_PANEL_ID, typeof(IOptionPanelExtension), this);

            ICommandCategory dialogs = _coreServices.CommandManager.CommandCategories.Dialogs;

            _optionDialogCommand       = new GeneralCommandImpl("org.poderosa.optiondialog.open", _stringResource, "Command.OptionDialog", dialogs, new ExecuteDelegate(OptionDialogCommand.OpenOptionDialog)).SetDefaultShortcutKey(Keys.Alt | Keys.Control | Keys.T);
            _detailedPreferenceCommand = new GeneralCommandImpl("org.poderosa.preferenceeditor.open", _stringResource, "Command.PreferenceEditor", dialogs, new ExecuteDelegate(OptionDialogCommand.OpenPreferenceEditor));

            IExtensionPoint toolmenu = pm.FindExtensionPoint("org.poderosa.menu.tool");

            _optionDialogMenuGroup = new PoderosaMenuGroupImpl(new IPoderosaMenuItem[] {
                new PoderosaMenuItemImpl(_optionDialogCommand, _stringResource, "Menu.OptionDialog"),
                new PoderosaMenuItemImpl(_detailedPreferenceCommand, _stringResource, "Menu.PreferenceEditor")
            }).SetPosition(PositionType.Last, null);

            toolmenu.RegisterExtension(_optionDialogMenuGroup);

            //基本のオプションパネルを登録
            panel_ext.RegisterExtension(new DisplayOptionPanelExtension());
            panel_ext.RegisterExtension(new TerminalOptionPanelExtension());
            panel_ext.RegisterExtension(new PeripheralOptionPanelExtension());
            panel_ext.RegisterExtension(new CommandOptionPanelExtension());
            panel_ext.RegisterExtension(new SSHOptionPanelExtension());
            panel_ext.RegisterExtension(new ConnectionOptionPanelExtension());
            panel_ext.RegisterExtension(new GenericOptionPanelExtension());
        }
Ejemplo n.º 6
0
 /// <summary>
 /// <ja>
 /// コマンドID、説明テキスト文、コマンドカテゴリを指定してオブジェクトを作成します。
 /// </ja>
 /// <en>
 /// Create a object specifying command ID, the explanation text sentence, and the command category. 
 /// </en>
 /// </summary>
 /// <param name="commandID">
 /// <ja>
 /// 割り当てるコマンドIDです。ほかのコマンドとは重複しない唯一無二のものを指定しなければなりません。
 /// </ja>
 /// <en>
 /// It is allocated command ID. The unique one that doesn't overlap should be specified other commands. 
 /// </en>
 /// </param>
 /// <param name="description">
 /// <ja>
 /// コマンドの説明文を示すテキストです。
 /// </ja>
 /// <en>
 /// Text that shows explanation of command
 /// </en>
 /// </param>
 /// <param name="category">
 /// <ja>
 /// コマンドのカテゴリです。
 /// </ja>
 /// <en>
 /// Category of command.
 /// </en>
 /// </param>
 public GeneralCommandImpl(string commandID, string description, ICommandCategory category)
     : this(commandID, null, description, category, null, null) {
 }
Ejemplo n.º 7
0
 /// <summary>
 /// <ja>
 /// コマンドID、カルチャ、説明テキスト文、コマンドカテゴリを指定してオブジェクトを作成します。
 /// </ja>
 /// <en>
 /// The object is made specifying command ID, culture, the explanation text sentence, and the command category. 
 /// </en>
 /// </summary>
 /// <param name="commandID">
 /// <ja>
 /// 割り当てるコマンドIDです。ほかのコマンドとは重複しない唯一無二のものを指定しなければなりません。
 /// </ja>
 /// <en>
 /// It is allocated command ID. The unique one that doesn't overlap should be specified other commands. 
 /// </en>
 /// </param>
 /// <param name="sr">
 /// <ja>
 /// カルチャ情報です。
 /// </ja>
 /// <en>
 /// Information of the culture.
 /// </en>
 /// </param>
 /// <param name="descriptionTextID">
 /// <ja>
 /// コマンドの説明文を示すテキストIDです。
 /// </ja>
 /// <en>
 /// Text ID that shows explanation of command.
 /// </en>
 /// </param>
 /// <param name="category">
 /// <ja>
 /// コマンドのカテゴリです。
 /// </ja>
 /// <en>
 /// Category of command.
 /// </en>
 /// </param>
 public GeneralCommandImpl(string commandID, StringResource sr, string descriptionTextID, ICommandCategory category)
     : this(commandID, sr, descriptionTextID, category, null, null) {
 }
Ejemplo n.º 8
0
 /// <summary>
 /// <ja>
 /// コマンドID、カルチャ、説明テキスト文、コマンドカテゴリ、コマンドが実行される際に呼び出されるデリゲートを指定してオブジェクトを作成します。
 /// </ja>
 /// <en>
 /// The object is made specifying delegate called when command ID, culture, explanation text ID, the command category, and the command are executed. 
 /// </en>
 /// </summary>
 /// <param name="commandID">
 /// <ja>
 /// 割り当てるコマンドIDです。ほかのコマンドとは重複しない唯一無二のものを指定しなければなりません。
 /// </ja>
 /// <en>
 /// It is allocated command ID. The unique one that doesn't overlap should be specified other commands. 
 /// </en>
 /// </param>
 /// <param name="description">
 /// <ja>
 /// コマンドの説明文を示すテキストです。
 /// </ja>
 /// <en>
 /// Text that shows explanation of command.
 /// </en>
 /// </param>
 /// <param name="category">
 /// <ja>
 /// コマンドのカテゴリです。
 /// </ja>
 /// <en>
 /// Category of command.
 /// </en>
 /// </param>
 /// <param name="execute">
 /// <ja>
 /// コマンドが実行されるときに呼び出されるデリゲートです。
 /// </ja>
 /// <en>
 /// Delegate called when command is executed.
 /// </en>
 /// </param>
 public GeneralCommandImpl(string commandID, string description, ICommandCategory category, ExecuteDelegate execute)
     : this(commandID, null, description, category, execute, null) {
 }
Ejemplo n.º 9
0
 /// <summary>
 /// <ja>
 /// コマンドID、カルチャ、説明テキストID、コマンドカテゴリ、コマンドが実行される際に呼び出されるデリゲートを指定してオブジェクトを作成します。
 /// </ja>
 /// <en>
 /// The object is made specifying delegate called when command ID, culture, explanation text ID, the command category, and the command are executed. 
 /// </en>
 /// </summary>
 /// <param name="commandID">
 /// <ja>
 /// 割り当てるコマンドIDです。ほかのコマンドとは重複しない唯一無二のものを指定しなければなりません。
 /// </ja>
 /// <en>
 /// It is allocated command ID. The unique one that doesn't overlap should be specified other commands. 
 /// </en>
 /// </param>
 /// <param name="sr">
 /// <ja>
 /// カルチャ情報です。
 /// </ja>
 /// <en>
 /// Information of the culture.
 /// </en>
 /// </param>
 /// <param name="descriptionTextID">
 /// <ja>
 /// コマンドの説明文を示すテキストIDです。
 /// </ja>
 /// <en>
 /// Text ID that shows explanation of command.
 /// </en>
 /// </param>
 /// <param name="category">
 /// <ja>
 /// コマンドのカテゴリです。
 /// </ja>
 /// <en>
 /// Category of command.
 /// </en></param>
 /// <param name="execute">
 /// <ja>
 /// コマンドが実行されるときに呼び出されるデリゲートです。
 /// </ja>
 /// <en>
 /// Delegate called when command is executed
 /// </en>
 /// </param>
 public GeneralCommandImpl(string commandID, StringResource sr, string descriptionTextID, ICommandCategory category, ExecuteDelegate execute)
     : this(commandID, sr, descriptionTextID, category, execute, null) {
 }
Ejemplo n.º 10
0
 //必須要素を与えるコンストラクタ
 /// <summary>
 /// <ja>
 /// コマンドID、カルチャ、説明テキストID、コマンドカテゴリ、コマンドが実行される際に呼び出されるデリゲート、実行可能かどうかを調べる際に呼び出されるデリゲートを指定してオブジェクトを作成します。
 /// </ja>
 /// <en>
 /// The object is made specifying delegate called when delegate called when command ID, Culture, explanation text ID, the command category, and the command are executed and it is executable is examined. 
 /// </en>
 /// </summary>
 /// <param name="commandID">
 /// <ja>
 /// 割り当てるコマンドIDです。ほかのコマンドとは重複しない唯一無二のものを指定しなければなりません。
 /// </ja>
 /// <en>
 /// It is allocated command ID. The unique one that doesn't overlap should be specified other commands. 
 /// </en>
 /// </param>
 /// <param name="sr">
 /// <ja>
 /// カルチャ情報です。
 /// </ja>
 /// <en>
 /// Information of the culture.
 /// </en>
 /// </param>
 /// <param name="descriptionTextID">
 /// <ja>
 /// コマンドの説明文を示すテキストIDです。
 /// </ja>
 /// <en>
 /// Text ID that shows explanation of command
 /// </en>
 /// </param>
 /// <param name="commandCategory">
 /// <ja>
 /// コマンドのカテゴリです。
 /// </ja>
 /// <en>
 /// Category of command.
 /// </en>
 /// </param>
 /// <param name="exec">
 /// <ja>
 /// コマンドが実行されるときに呼び出されるデリゲートです。
 /// </ja>
 /// <en>
 /// Delegate called when command is executed.
 /// </en>
 /// </param>
 /// <param name="canExecute">
 /// <ja>
 /// コマンドが実行可能かどうかを調べる際に呼び出されるデリゲートです。
 /// </ja>
 /// <en>
 /// Delegate called when it is examined whether command is executable
 /// </en>
 /// </param>
 /// <overloads>
 /// <summary>
 /// <ja>
 /// コマンドオブジェクトを作成します。
 /// </ja>
 /// <en>
 /// Create the command object.
 /// </en>
 /// </summary>
 /// </overloads>
 public GeneralCommandImpl(string commandID, StringResource sr, string descriptionTextID, ICommandCategory commandCategory, ExecuteDelegate exec, CanExecuteDelegate canExecute) {
     _commandID = commandID;
     _usingStringResource = sr != null;
     _strResource = sr;
     _descriptionTextID = descriptionTextID;
     _commandCategory = commandCategory;
     _executeDelegate = exec;
     _canExecuteDelegate = canExecute;
 }