This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using System.Globalization; | |
using System.Runtime.InteropServices; | |
using System.ComponentModel.Design; | |
using Microsoft.Win32; | |
using Microsoft.VisualStudio; | |
using Microsoft.VisualStudio.Shell.Interop; | |
using Microsoft.VisualStudio.OLE.Interop; | |
using Microsoft.VisualStudio.Shell; | |
namespace Company.ProjectionBufferTutorial | |
{ | |
[PackageRegistration(UseManagedResourcesOnly = true)] | |
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] | |
[ProvideMenuResource("Menus.ctmenu", 1)] | |
[ProvideToolWindow(typeof(MyToolWindow))] | |
[Guid(GuidList.guidProjectionBufferTutorialPkgString)] | |
public sealed class ProjectionBufferTutorialPackage : Package | |
{ | |
public ProjectionBufferTutorialPackage() | |
{ | |
} | |
private void ShowToolWindow(object sender, EventArgs e) | |
{ | |
ToolWindowPane window = this.FindToolWindow(typeof(MyToolWindow), 0, true); | |
if ((null == window) || (null == window.Frame)) | |
{ | |
throw new NotSupportedException(Resources.CanNotCreateWindow); | |
} | |
IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame; | |
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show()); | |
} | |
protected override void Initialize() | |
{ | |
Debug.WriteLine (string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString())); | |
base.Initialize(); | |
OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; | |
if ( null != mcs ) | |
{ | |
CommandID toolwndCommandID = new CommandID(GuidList.guidProjectionBufferTutorialCmdSet, (int)PkgCmdIDList.cmdidMyTool); | |
MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID); | |
mcs.AddCommand( menuToolWin ); | |
} | |
VisualStudioServices.ServiceProvider = this; | |
VisualStudioServices.OLEServiceProvider = (Microsoft.VisualStudio.OLE.Interop.IServiceProvider)VisualStudioServices.ServiceProvider.GetService(typeof(Microsoft.VisualStudio.OLE.Interop.IServiceProvider)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment