/// <summary> /// This is called after our control has been created and sited. /// This is a good place to initialize the control with data gathered /// from Visual Studio services. /// </summary> public override void OnToolWindowCreated() { base.OnToolWindowCreated(); PackageToolWindow package = (PackageToolWindow)this.Package; // Set the text that will appear in the title bar of the tool window. // Note that because we need access to the package for localization, // we have to wait to do this here. If we used a constant string, // we could do this in the constructor. this.Caption = package.GetResourceString("@110"); // Register to the window events WindowStatus windowFrameEventsHandler = new WindowStatus(this.OutputWindowPane, this.Frame as IVsWindowFrame); ErrorHandler.ThrowOnFailure(((IVsWindowFrame)this.Frame).SetProperty((int)__VSFPROPID.VSFPROPID_ViewHelper, (IVsWindowFrameNotify3)windowFrameEventsHandler)); // Let our control have access to the window state control.CurrentState = windowFrameEventsHandler; }
/// <summary> /// This is called after our control has been created and sited. /// This is a good place to initialize the control with data gathered /// from Visual Studio services. /// </summary> public override void OnToolWindowCreated() { base.OnToolWindowCreated(); PackageToolWindow package = (PackageToolWindow)this.Package; // Set the text that will appear in the title bar of the tool window. // Note that because we need access to the package for localization, // we have to wait to do this here. If we used a constant string, // we could do this in the consturctor. this.Caption = package.GetResourceString("@100"); // Add the handler for our toolbar button CommandID id = new CommandID(GuidsList.guidClientCmdSet, PkgCmdId.cmdidRefreshWindowsList); MsVsShell.OleMenuCommand command = DefineCommandHandler(new EventHandler(this.RefreshList), id); // Get the selection tracking service and pass it to the control so that it can push the // active selection. Only needed if you want to display something in the Properties window. // Note that this service is only available for windows (not in the global service provider) // Additionally, each window has its own (so you should not be sharing one between multiple windows) control.TrackSelection = (ITrackSelection)this.GetService(typeof(STrackSelection)); // Ensure the control's handle has been created; otherwise, BeginInvoke cannot be called. // Note that during runtime this should have no effect when running inside Visual Studio, // as the control's handle should already be created, but unit tests can end up calling // this method without the control being created. control.InitializeComponent(); // Delay initialization of the list until other tool windows have also had a chance to be // initialized control.Dispatcher.BeginInvoke((Action) delegate { // Populate the list view this.RefreshList(this, null); }); }