Ejemplo n.º 1
0
        public override void OnToolWindowCreated()
        {
            base.OnToolWindowCreated();
            ExplorerControl.OnVsToolWindowCreated(this);

            // Advise IVsWindowFrameNotify so we know when we get hidden, etc.
            var frame = this.Frame as IVsWindowFrame2;

            if (frame != null)
            {
                _frameNotify = new VsWindowFrameNotifyHandler(frame);
                _frameNotify.Advise();
            }

            // Hookup command handlers
            var commands = new List <IPackageCommandHandler> {
                new PreviousLocationCommandHandler(this),
                new NextLocationCommandHandler(this),
                new CancelSearchCommandHandler(this),
                //new CancelSearchToolWindowCommandHandler(this),
                // Add more here...
            };

            var commandService = (IMenuCommandService)this.GetService(typeof(IMenuCommandService));

            commands.ForEach(handler =>
                             commandService.AddCommand(handler.ToOleMenuCommand()));
        }
Ejemplo n.º 2
0
        public override void OnToolWindowCreated()
        {
            base.OnToolWindowCreated();
            ExplorerControl.OnVsToolWindowCreated(this);
            _txtMgr         = (IVsTextManager)GetService(typeof(SVsTextManager));
            _componentModel = (IComponentModel)GetService(typeof(SComponentModel));
            _editorAdaptersFactoryService = (IVsEditorAdaptersFactoryService)_componentModel.GetService <IVsEditorAdaptersFactoryService>();
            //_editorPrimitivesFactoryService = (IEditorPrimitivesFactoryService)_componentModel.GetService<IEditorPrimitivesFactoryService>();

            EnvDTE.DTE       dte    = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));
            EnvDTE80.Events2 events = (EnvDTE80.Events2)dte.Events;
            this.WindowEvents = (EnvDTE.WindowEvents)events.get_WindowEvents(null);
            this.WindowEvents.WindowActivated += (Window GotFocus, Window LostFocus) => {
                if (GotFocus.ObjectKind.ToString().ToLower().Equals("{" + GuidList.GuidCodeSearchToolWindowString + "}"))
                {
                    var word = GetSelectedOrWord();
                    if (word.Equals(""))
                    {
                        return;
                    }
                    ExplorerControl.SearchCodeCombo.Text = GetSelectedOrWord();
                    //ExplorerControl.SearchCodeCombo.Focus();
                }
            };
            // Advise IVsWindowFrameNotify so we know when we get hidden, etc.
            var frame = Frame as IVsWindowFrame2;

            if (frame != null)
            {
                _frameNotify = new VsWindowFrameNotifyHandler(frame);
                _frameNotify.Advise();
                //_frameNotify.OnShowCallBack = () => {
                //  ExplorerControl.SearchCodeCombo.Focus();
                //  var vsp = Package as VsPackage;
                //  var ts = vsp.DTE.ActiveDocument.Selection as TextSelection;
                //  //if (ts != null)
                //  //  ExplorerControl.SearchCodeCombo.Text = ts.Text;
                //};
            }

            // Hookup command handlers
            var commands = new List <IPackageCommandHandler> {
                new PreviousLocationCommandHandler(this),
                new NextLocationCommandHandler(this),
                new CancelSearchCommandHandler(this),
                //new CancelSearchToolWindowCommandHandler(this),
                // Add more here...
            };

            var commandService = (IMenuCommandService)GetService(typeof(IMenuCommandService));

            commands.ForEach(handler =>
                             commandService.AddCommand(handler.ToOleMenuCommand()));
        }
Ejemplo n.º 3
0
    public override void OnToolWindowCreated() {
      base.OnToolWindowCreated();
      ExplorerControl.OnVsToolWindowCreated(this);

      // Advise IVsWindowFrameNotify so we know when we get hidden, etc.
      var frame = this.Frame as IVsWindowFrame2;
      if (frame != null) {
        _frameNotify = new VsWindowFrameNotifyHandler(frame);
        _frameNotify.Advise();
      }

      // Hookup command handlers
      var commands = new List<IPackageCommandHandler> {
        new PreviousLocationCommandHandler(this),
        new NextLocationCommandHandler(this),
        new CancelSearchCommandHandler(this),
        //new CancelSearchToolWindowCommandHandler(this),
        // Add more here...
      };

      var commandService = (IMenuCommandService)this.GetService(typeof(IMenuCommandService));
      commands.ForEach(handler =>
          commandService.AddCommand(handler.ToOleMenuCommand()));
    }