예제 #1
0
        private void RegisterToDTEEvents()
        {
            docEvents.DocumentOpening += DocumentEvents_DocumentOpening;
            docEvents.DocumentSaved   += DocumentEvents_DocumentSaved;
            docEvents.DocumentClosing += DocEvents_DocumentClosing;

            buildEvents.OnBuildBegin += BuildEvents_OnBuildBegin;
            buildEvents.OnBuildDone  += BuildEvents_OnBuildDone;

            EnvDTE80.Events2 events2 = dte.Events as EnvDTE80.Events2;
            if (events2 != null)
            {
                this.projectItemsEvents              = events2.ProjectItemsEvents;
                this.projectItemsEvents.ItemAdded   += ProjectItemsEvents_ItemAdded;
                this.projectItemsEvents.ItemRemoved += ProjectItemsEvents_ItemRemoved;
                this.projectItemsEvents.ItemRenamed += ProjectItemsEvents_ItemRenamed;
            }

            this.csharpProjectItemsEvents = dte.Events.GetObject("CSharpProjectItemsEvents") as EnvDTE.ProjectItemsEvents;
            if (this.csharpProjectItemsEvents != null)
            {
                this.csharpProjectItemsEvents.ItemAdded   += ProjectItemsEvents_ItemAdded;
                this.csharpProjectItemsEvents.ItemRemoved += ProjectItemsEvents_ItemRemoved;
                this.csharpProjectItemsEvents.ItemRenamed += ProjectItemsEvents_ItemRenamed;
            }
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ToolWindow1"/> class.
        /// </summary>
        public ToolWindow(ToolWindowState state)
            : base()
        {
            _state = state;

            Caption = "SolutionBook - Initializing";

            // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable,
            // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on
            // the object returned by the Content property.
            var content = new ToolWindowControl(state, this);

            Content = content;

            Task.Run(() => state.GetAll())
            .ContinueWith(x =>
            {
                content.Populate(x.Result);
                Caption = "SolutionBook";
            }, TaskScheduler.FromCurrentSynchronizationContext());

            // icon
            BitmapImageMoniker = KnownMonikers.Solution;

            //// focus
            EnvDTE80.Events2 events2 = (EnvDTE80.Events2)state.DTE.Events;
            var wve = events2.WindowVisibilityEvents;

            wve.WindowShowing += (window) => { if (window.ObjectKind.ToLowerInvariant() == WindowObjectKind)
                                               {
                                                   content.Show();
                                               }
            };
            //wve.WindowHiding += (window) => { };
        }
예제 #3
0
        private void InitialiseDTEDependantObjects()
        {
            if (hasInitialised)
            {
                return;
            }


            EnvDTE80.DTE2 dte2 = package.GetServiceInternal(typeof(SDTE)) as EnvDTE80.DTE2;
            if (dte2 == null)
            {
                return;
            }

            // Zombie state dependent code.
            dte2 = package.GetServiceInternal(typeof(SDTE)) as EnvDTE80.DTE2;
            EnvDTE80.Events2 events = (EnvDTE80.Events2)dte2.Events;
            _ = package.GetServiceInternal(typeof(EnvDTE.DTE)) as EnvDTE.DTE;

            // Register event handlers that need the DTE active to do work.
            eventManager.RegisterDteDependentHandlers(dte2, events);

            // Initialize the output logger.  This is a bit hacky but a quick fix for Alpha release.
            //StatusBarLogger.InitializeInstance(dte);
            hasInitialised = true;
        }
예제 #4
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            try
            {
                base.Initialize();
                SetTheme();

                IVsMonitorSelection monitorSelection = (IVsMonitorSelection)Package.GetGlobalService(typeof(SVsShellMonitorSelection));
                monitorSelection.AdviseSelectionEvents(this, out cookie);

                // Add our command handlers for menu (commands must exist in the .vsct file)
                OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

                if (null != mcs)
                {
                    _handlers = new PackageHandlers();
                    _handlers.Register(mcs);

                    _handlers.SwitchToSettings  = new RelayCommand((o) => SwitchToSettings((o as PackageHandlers.ChoiceCommandParameters).Selected as ProfileSelection), (o) => HasProjectAvailableProfiles());
                    _handlers.ShowWorkItemView  = new RelayCommand((o) => ShowWorkItemView());
                    _handlers.ShowChangesetView = new RelayCommand((o) => ShowChangesetView());
                    _handlers.RefreshBranches   = new RelayCommand((o) => RefreshBranches());
                    _handlers.ShowVMergeHelp    = new RelayCommand((o) => ShowVMergeHelp());

                    _handlers.SetTargetBranchChoiceHandler(
                        (args) => GetAvailableMergeTargetBranches());
                    _handlers.TargetBranch = new RelayCommand((o) => MergeToTarget((o as PackageHandlers.ChoiceCommandParameters).Selected as MergeSelection));

                    _handlers.SetTargetBranch2ChoiceHandler(
                        (args) => GetAvailableMergeTargetBranches());
                    _handlers.TargetBranch2 = new RelayCommand((o) => OpenChangesetView((o as PackageHandlers.ChoiceCommandParameters).Selected as MergeSelection));

                    _handlers.SetMatchingProfilesChoiceHandler(
                        (args) => GetMatchingProfilesForBranch());
                    _handlers.MatchingProfiles = new RelayCommand((o) => LoadProfileAndMerge((o as PackageHandlers.ChoiceCommandParameters).Selected as ProfileSelection));

                    _handlers.SetSwitchToSettingsChoiceHandler(
                        (args) => GetMatchingProfilesForProject());

                    _handlers.SetSwitchToSettingsGetSelectedChoiceHandler(
                        (args) => GetActiveProfile());
                }

                var dte = GetGlobalService(typeof(EnvDTE.DTE)) as EnvDTE.DTE;
                _events = dte.Events as EnvDTE80.Events2;
                _events.WindowVisibilityEvents.WindowHiding  += WindowVisibilityEvents_WindowHiding;
                _events.WindowVisibilityEvents.WindowShowing += WindowVisibilityEvents_WindowShowing;

                ((VsTfsUIInteractionProvider)Repository.Instance.TfsUIInteractionProvider).UIShell = GetService(typeof(SVsUIShell)) as IVsUIShell;
                Microsoft.VisualStudio.PlatformUI.VSColorTheme.ThemeChanged += (a) => SetTheme();
            }
            catch (Exception ex)
            {
                SimpleLogger.Log(ex);
                throw;
            }
        }
예제 #5
0
        public override void OnToolWindowCreated()
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var dte = DTE;

            EnvDTE80.Events2 events = (EnvDTE80.Events2)dte.Events;
            WindowEvents = events.get_WindowEvents(null);
            WindowEvents.WindowActivated += new EnvDTE._dispWindowEvents_WindowActivatedEventHandler(WindowEvents_WindowActivated);
        }
예제 #6
0
        protected override void OnToolWindowCreate()
        {
            base.OnToolWindowCreate();

            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 += new EnvDTE._dispWindowEvents_WindowActivatedEventHandler(WindowEvents_WindowActivated);
        }
        protected override void Initialize()
        {
            base.Initialize();

            this.dte    = (EnvDTE80.DTE2)GetService(typeof(EnvDTE.DTE));
            this.event2 = (EnvDTE80.Events2) this.dte.Events;

            this.keyPressEvents = this.event2.TextDocumentKeyPressEvents;
            this.keyPressEvents.AfterKeyPress += TextDocumentKeyPressEvents_AfterKeyPress;
        }
        public override void OnToolWindowCreated()
        {
            EnvDTE.DTE       dte    = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE));
            EnvDTE80.Events2 events = (EnvDTE80.Events2)dte.Events;

            var windowVisibility = events.get_WindowVisibilityEvents();

            windowVisibility.WindowShowing += WindowVisibility_WindowShowing;
            windowVisibility.WindowHiding  += WindowVisibility_WindowHiding;
        }
예제 #9
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()));
        }
예제 #10
0
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);

            m_settings.onOptionsChanged += new EventHandler(onConfigurationChanged);

            // Add our command handlers for menu (commands must exist in the .vsct file)
            OleMenuCommandService mcs = await  GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != mcs)
            {
                // Register new command
                CommandID cmdOptions          = new CommandID(GuidList.guidCodeBeautifierCmdSet, (int)PkgCmdIDList.cmdOptions);
                CommandID cmdAbout            = new CommandID(GuidList.guidCodeBeautifierCmdSet, (int)PkgCmdIDList.cmdAbout);
                CommandID cmdCurrentDocument  = new CommandID(GuidList.guidCodeBeautifierCmdSet, (int)PkgCmdIDList.cmdCurrentDocument);
                CommandID cmdAllOpenDocuments = new CommandID(GuidList.guidCodeBeautifierCmdSet, (int)PkgCmdIDList.cmdAllOpenDocuments);
                CommandID cmdSelectedProject  = new CommandID(GuidList.guidCodeBeautifierCmdSet, (int)PkgCmdIDList.cmdSelectedProject);
                CommandID cmdSelectedSolution = new CommandID(GuidList.guidCodeBeautifierCmdSet, (int)PkgCmdIDList.cmdSelectedSolution);

                MenuCommand    menuOptions          = new MenuCommand(menuOptionsCallback, cmdOptions);
                MenuCommand    menuAbout            = new MenuCommand(menuAboutCallback, cmdAbout);
                OleMenuCommand menuCurrentDocument  = new OleMenuCommand(callbackCurrentCallback, cmdCurrentDocument);
                OleMenuCommand menuAllOpenDocuments = new OleMenuCommand(callbackAllOpenDocuments, cmdAllOpenDocuments);
                OleMenuCommand menuSelectedProject  = new OleMenuCommand(callbackSelectedProject, cmdSelectedProject);
                OleMenuCommand menuSolution         = new OleMenuCommand(callbackSolution, cmdSelectedSolution);

                menuCurrentDocument.BeforeQueryStatus  += new EventHandler(onBeforeQueryStatusCurrentDocument);
                menuAllOpenDocuments.BeforeQueryStatus += new EventHandler(onBeforeQueryStatusAllOpenDocuments);
                menuSelectedProject.BeforeQueryStatus  += new EventHandler(onBeforeQueryStatusSelectedProject);
                menuSolution.BeforeQueryStatus         += new EventHandler(onBeforeQueryStatusSolution);

                mcs.AddCommand(menuOptions);
                mcs.AddCommand(menuAbout);
                mcs.AddCommand(menuCurrentDocument);
                mcs.AddCommand(menuAllOpenDocuments);
                mcs.AddCommand(menuSelectedProject);
                mcs.AddCommand(menuSolution);

                m_dte2 = await GetServiceAsync(typeof(EnvDTE.DTE)) as EnvDTE80.DTE2;

                beforeExecute("{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 882).BeforeExecute  += onBuildSolution;
                beforeExecute("{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 883).BeforeExecute  += onReBuildSolution;
                beforeExecute("{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 886).BeforeExecute  += onBuildSelected;
                beforeExecute("{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 887).BeforeExecute  += onReBuildSelected;
                beforeExecute("{1496A755-94DE-11D0-8C3F-00C04FC2AAE2}", 1603).BeforeExecute += onBuildSelected;
                beforeExecute("{1496A755-94DE-11D0-8C3F-00C04FC2AAE2}", 1604).BeforeExecute += onReBuildSelected;

                EnvDTE80.Events2 dteEvents2 = m_dte2.Events as EnvDTE80.Events2;
                m_documentEvents = dteEvents2.get_DocumentEvents();
                m_documentEvents.DocumentSaved += onDocumentSaved;

                m_textDocumentEvents = dteEvents2.get_TextDocumentKeyPressEvents();
                m_textDocumentEvents.AfterKeyPress += onTextDocumentKeyPressed;

                onConfigurationChanged(null, null);
            }
        }