当前位置: 首页>>代码示例>>C#>>正文


C# Plugin.AddToolbarCommand方法代码示例

本文整理汇总了C#中Plugin.AddToolbarCommand方法的典型用法代码示例。如果您正苦于以下问题:C# Plugin.AddToolbarCommand方法的具体用法?C# Plugin.AddToolbarCommand怎么用?C# Plugin.AddToolbarCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Plugin的用法示例。


在下文中一共展示了Plugin.AddToolbarCommand方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnConnection


//.........这里部分代码省略.........
                }
                catch
                {
                    toolsControl = null;
                }

                try
                {
                    if (toolsControl == null)
                    {
                        toolsControl = menuBarCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing,
                                                                      Type.Missing, 4, false);
                        toolsControl.Caption = "Git";
                    }

                    toolsPopup = (CommandBarPopup) toolsControl;
                    toolsPopup.Caption = "Git";
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    if (toolsControl == null)
                    {
                        toolsControl = menuBarCommandBar.Controls[GetToolsMenuName()];
                        toolsPopup = (CommandBarPopup) toolsControl;
                    }
                }

                try
                {
                    // add the toolbar and menu commands
                    var commandBar = _gitPlugin.AddCommandBar("GitExtensions", MsoBarPosition.msoBarTop);

                    _gitPlugin.AddToolbarCommandWithText(
                        commandBar, "GitExtensionsCommit", "Commit", "Commit changes", 7,1);

                    _gitPlugin.AddToolbarCommand(commandBar,
                        "GitExtensionsBrowse", "Browse", "Browse repository", 12, 2);
                    _gitPlugin.AddToolbarCommand(commandBar, "GitExtensionsPull", "Pull",
                                                "Pull changes from remote repository", 9, 3);
                    _gitPlugin.AddToolbarCommand(commandBar, "GitExtensionsPush", "Push",
                                                "Push changes to remote repository", 8, 4);
                    _gitPlugin.AddToolbarCommand(commandBar,
                        "GitExtensionsStash", "Stash", "Stash changes", 3, 5);
                    _gitPlugin.AddToolbarCommand(commandBar,
                        "GitExtensionsSettings", "Settings", "Settings", 2, 6);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

                try
                {
                    var n = 1;
                    _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsApplyPatch", "Apply patch", "Apply patch", 0,
                                              n++);
                    _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsBrowse", "Browse", "Browse repository", 12, n++);
                    _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsSwitchBranch", "Checkout branch",
                                              "Switch to branch", 10, n++);
                    _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsCherryPick", "Cherry pick", "Cherry pick commit",
                                              11, n++);
                    _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsCommit", "Commit", "Commit changes", 7, n++);
                    _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsCreateBranch", "Create branch",
                                              "Create new branch", 10, n++);
                    _gitPlugin.AddPopupCommand(toolsPopup, "GitExtensionsClone", "Clone repository", "Clone existing Git",
开发者ID:DavidBasarab,项目名称:gitextensions,代码行数:67,代码来源:Connect.cs

示例2: OnConnection

        /// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
        /// <param term='application'>Root object of the host application.</param>
        /// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
        /// <param term='addInInst'>Object representing this Add-in.</param>
        /// <seealso class='IDTExtensibility2' />
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            if (GitPlugin != null)
                return;

            try
            {
                CultureInfo cultureInfo = new CultureInfo("en-US");
                System.Threading.Thread.CurrentThread.CurrentCulture = cultureInfo;

                _applicationObject = (DTE2)application;

                //Place the command on the tools menu.
                //Find the MenuBar command bar, which is the top-level command bar holding all the main menu items:
                Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["MenuBar"];

                CommandBarControl toolsControl = null;
                CommandBarPopup toolsPopup = null;
                try
                {
                    toolsControl = menuBarCommandBar.Controls["Git"];
                }
                catch
                {
                    toolsControl = null;
                }

                try
                {
                    if (toolsControl == null)
                    {
                        toolsControl = menuBarCommandBar.Controls.Add(MsoControlType.msoControlPopup, System.Type.Missing, System.Type.Missing, 4, true);
                        toolsControl.Caption = "Git";
                    }

                    toolsPopup = (CommandBarPopup)toolsControl;
                    toolsPopup.Caption = "Git";
                }
                catch
                {
                    if (toolsControl == null)
                    {
                        toolsControl = menuBarCommandBar.Controls[GetToolsMenuName()];
                        toolsPopup = (CommandBarPopup)toolsControl;
                    }
                }

                GitPlugin = new Plugin((DTE2)application, (AddIn)addInInst, "GitExtensions", "GitPlugin.Connect");
                try
                {
                    GitPlugin.RegisterCommand("GitExtensionsFileHistory", new ToolbarCommand<FileHistory>());
                    GitPlugin.RegisterCommand("GitExtensionsCommit", new ToolbarCommand<Commit>());
                    GitPlugin.RegisterCommand("GitExtensionsBrowse", new ToolbarCommand<Browse>());
                    GitPlugin.RegisterCommand("GitExtensionsClone", new ToolbarCommand<Clone>());
                    GitPlugin.RegisterCommand("GitExtensionsCreateBranch", new ToolbarCommand<CreateBranch>());
                    GitPlugin.RegisterCommand("GitExtensionsSwitchBranch", new ToolbarCommand<SwitchBranch>());
                    GitPlugin.RegisterCommand("GitExtensionsDiff", new ToolbarCommand<ViewDiff>());
                    GitPlugin.RegisterCommand("GitExtensionsInitRepository", new ToolbarCommand<Init>());
                    GitPlugin.RegisterCommand("GitExtensionsFormatPatch", new ToolbarCommand<FormatPatch>());
                    GitPlugin.RegisterCommand("GitExtensionsPull", new ToolbarCommand<Pull>());
                    GitPlugin.RegisterCommand("GitExtensionsPush", new ToolbarCommand<Push>());
                    GitPlugin.RegisterCommand("GitExtensionsRebase", new ToolbarCommand<Rebase>());
                    GitPlugin.RegisterCommand("GitExtensionsRevert", new ToolbarCommand<Revert>());
                    GitPlugin.RegisterCommand("GitExtensionsMerge", new ToolbarCommand<Merge>());
                    GitPlugin.RegisterCommand("GitExtensionsCherryPick", new ToolbarCommand<Cherry>());
                    GitPlugin.RegisterCommand("GitExtensionsStash", new ToolbarCommand<Stash>());
                    GitPlugin.RegisterCommand("GitExtensionsSettings", new ToolbarCommand<Settings>());
                    GitPlugin.RegisterCommand("GitExtensionsSolveMergeConflicts", new ToolbarCommand<SolveMergeConflicts>());
                    GitPlugin.RegisterCommand("GitExtensionsApplyPatch", new ToolbarCommand<ApplyPatch>());
                    GitPlugin.RegisterCommand("GitExtensionsAbout", new ToolbarCommand<About>());
                    GitPlugin.RegisterCommand("GitExtensionsBash", new ToolbarCommand<Bash>());
                    GitPlugin.RegisterCommand("GitExtensionsGitIgnore", new ToolbarCommand<GitIgnore>());
                    GitPlugin.RegisterCommand("GitExtensionsRemotes", new ToolbarCommand<Remotes>());
                }
                catch (Exception ex)
                {
                    string s = ex.Message;
                }

                try
                {
                    // add the toolbar and menu commands
                    CommandBar commandBar = GitPlugin.AddCommandBar("GitExtensions", MsoBarPosition.msoBarTop);
                    GitPlugin.AddToolbarCommandWithText(commandBar, "GitExtensionsCommit", "Commit", "Commit changes", 7, 1);
                    GitPlugin.AddToolbarCommand(commandBar, "GitExtensionsBrowse", "Browse", "Browse repository", 12, 2);
                    GitPlugin.AddToolbarCommand(commandBar, "GitExtensionsPull", "Pull", "Pull changes from remote repository", 9, 3);
                    GitPlugin.AddToolbarCommand(commandBar, "GitExtensionsPush", "Push", "Push changes to remote repository", 8, 4);
                    GitPlugin.AddToolbarCommand(commandBar, "GitExtensionsStash", "Stash", "Stash changes", 3, 5);
                    GitPlugin.AddToolbarCommand(commandBar, "GitExtensionsSettings", "Settings", "Settings", 2, 6);
                }
                catch (Exception ex)
                {
                    string s = ex.Message;
                }

//.........这里部分代码省略.........
开发者ID:jorn,项目名称:gitextensions,代码行数:101,代码来源:Connect.cs


注:本文中的Plugin.AddToolbarCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。