| | |
| | | **
|
| | | ****************************************************************************/
|
| | |
|
| | | using EnvDTE;
|
| | | using Microsoft.VisualStudio.Shell;
|
| | | using QtVsTools.Core;
|
| | | using QtVsTools.VisualStudio;
|
| | | using System;
|
| | | using System.ComponentModel.Design;
|
| | | using Microsoft.VisualStudio.Shell;
|
| | | using EnvDTE;
|
| | |
|
| | | namespace QtVsTools
|
| | | {
|
| | | using Core;
|
| | | using VisualStudio;
|
| | |
|
| | | /// <summary>
|
| | | /// Command handler
|
| | | /// </summary>
|
| | |
| | | /// <summary>
|
| | | /// Command menu group (command set GUID).
|
| | | /// </summary>
|
| | | public static readonly Guid ItemContextMenuGuid = new Guid("9f67a0bd-ee0a-47e3-b656-5efb12e3c770");
|
| | | private static readonly Guid ItemContextMenuGuid = new Guid("9f67a0bd-ee0a-47e3-b656-5efb12e3c770");
|
| | |
|
| | | /// <summary>
|
| | | /// Gets the instance of the command.
|
| | | /// </summary>
|
| | | public static QtItemContextMenu Instance
|
| | | private static QtItemContextMenu Instance
|
| | | {
|
| | | get;
|
| | | private set;
|
| | | set;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// Initializes the singleton instance of the command.
|
| | | /// </summary>
|
| | | /// <param name="package">Owner package, not null.</param>
|
| | | public static void Initialize(Package package)
|
| | | public static void Initialize()
|
| | | {
|
| | | Instance = new QtItemContextMenu(package);
|
| | | Instance = new QtItemContextMenu();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// VS Package that provides this command, not null.
|
| | | /// </summary>
|
| | | private readonly Package m_package;
|
| | |
|
| | | /// <summary>
|
| | | /// Command ID.
|
| | |
| | | /// Initializes a new instance of the <see cref="QtMainMenu"/> class.
|
| | | /// Adds our command handlers for menu (commands must exist in the command table file)
|
| | | /// </summary>
|
| | | /// <param name="package">Owner package, not null.</param>
|
| | | private QtItemContextMenu(Package package)
|
| | | private QtItemContextMenu()
|
| | | {
|
| | | if (package == null)
|
| | | throw new ArgumentNullException("package");
|
| | |
|
| | | m_package = package;
|
| | |
|
| | | var commandService = VsServiceProvider
|
| | | .GetService<IMenuCommandService, OleMenuCommandService>();
|
| | | if (commandService == null)
|
| | |
| | |
|
| | | private void execHandler(object sender, EventArgs e)
|
| | | {
|
| | | ThreadHelper.ThrowIfNotOnUIThread();
|
| | |
|
| | | var command = sender as OleMenuCommand;
|
| | | if (command == null)
|
| | | return;
|
| | |
| | |
|
| | | private void beforeQueryStatus(object sender, EventArgs e)
|
| | | {
|
| | | ThreadHelper.ThrowIfNotOnUIThread();
|
| | |
|
| | | var command = sender as OleMenuCommand;
|
| | | if (command == null)
|
| | | return;
|
| | |
| | | command.Visible = false;
|
| | |
|
| | | var prj = HelperFunctions.GetSelectedProject(QtVsToolsPackage.Instance.Dte);
|
| | | if (!HelperFunctions.IsQtProject(prj) || QtVsToolsPackage.Instance.Dte.SelectedItems.Count <= 0)
|
| | | if (!HelperFunctions.IsVsToolsProject(prj) || QtVsToolsPackage.Instance.Dte.SelectedItems.Count <= 0)
|
| | | return;
|
| | |
|
| | | foreach (SelectedItem si in QtVsToolsPackage.Instance.Dte.SelectedItems) {
|
| | |
| | | return; // Don't display commands if one of the selected files is not a .ts file.
|
| | | }
|
| | |
|
| | | command.Enabled = true;
|
| | | command.Enabled = Translation.ToolsAvailable(prj);
|
| | | command.Visible = true;
|
| | | }
|
| | | }
|