コード例 #1
0
        /// <summary>
        /// Occurs whenever an add-in, which is set to load when Visual Studio starts, loads.
        /// </summary>
        /// <param name="custom">An empty array that you can use to pass host-specific data for use when the add-in loads.</param>
        void IDTExtensibility2.OnStartupComplete(ref Array custom)
        {
            this.solutionEvents = dte.Events.SolutionEvents;

            this.hOpened = new _dispSolutionEvents_OpenedEventHandler(SolutionEvents_Opened);// 为什么要这样?

            this.solutionEvents.Opened += this.hOpened;
        }
コード例 #2
0
 public void HookEvents() {
     if (!hooked) {
         hooked = true;
         afterClosingEventHandler = new _dispSolutionEvents_AfterClosingEventHandler(solutionEvents_AfterClosing);
         solutionEvents.AfterClosing += afterClosingEventHandler;
         openedEventHandler = new _dispSolutionEvents_OpenedEventHandler(solutionEvents_Opened);
         solutionEvents.Opened += openedEventHandler;
     }
 }
コード例 #3
0
ファイル: EventManager.cs プロジェクト: pjsatou/VSFileNav
        /// <summary>
        /// Called when the Solution is opened and fires an Event
        /// </summary>
        public virtual void OnSolutionOpened()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "OnSolutionOpened fired for: {0}", this.ToString()));
            _dispSolutionEvents_OpenedEventHandler solutionOpenedHandler = this.SolutionOpened;

            if (solutionOpenedHandler != null)
            {
                solutionOpenedHandler();
            }
        }
コード例 #4
0
 public void HookEvents()
 {
     if (!hooked)
     {
         hooked = true;
         afterClosingEventHandler     = new _dispSolutionEvents_AfterClosingEventHandler(solutionEvents_AfterClosing);
         solutionEvents.AfterClosing += afterClosingEventHandler;
         openedEventHandler           = new _dispSolutionEvents_OpenedEventHandler(solutionEvents_Opened);
         solutionEvents.Opened       += openedEventHandler;
     }
 }
コード例 #5
0
        private void bindEventsOnSolution()
        {
            if (_openedEvent != null)
                return;
            
            _openedEvent = new _dispSolutionEvents_OpenedEventHandler(onSolutionOpened);
            _solutionEvents.Opened += _openedEvent;

            _afterClosingEvent = new _dispSolutionEvents_AfterClosingEventHandler(onSolutionClosingFinished);
            _solutionEvents.AfterClosing += _afterClosingEvent;
        }
コード例 #6
0
        private void bindEventsOnSolution()
        {
            if (_openedEvent != null)
                return;

            _openedEvent = new _dispSolutionEvents_OpenedEventHandler(onSolutionOpened);
            _solutionEvents.Opened += _openedEvent;

            _afterClosingEvent = new _dispSolutionEvents_AfterClosingEventHandler(onSolutionClosingFinished);
            _solutionEvents.AfterClosing += _afterClosingEvent;
        }
コード例 #7
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>
        /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param>
        /// <param name="progress">A provider for progress updates.</param>
        /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering InitializeAsync for: {0}", this.ToString()));

            // When initialized asynchronously, the current thread may be a background thread at this point.
            // Do any initialization that requires the UI thread after switching to the UI thread.
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            _dte = await GetServiceAsync(typeof(DTE)) as DTE2;

            _openedHandler = () => InvokeOnMainThread(() => OnOpened());

            _dte.Events.SolutionEvents.Opened += _openedHandler;

            SetupOutputWindow();

            if (_dte.Solution.IsOpen)
            {
                await OnOpened();
            }
        }
コード例 #8
0
ファイル: VisualStudioPackage.cs プロジェクト: akobr/texo.ui
        /// <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>
        /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param>
        /// <param name="progress">A provider for progress updates.</param>
        /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // Hack: force load of Markdig.Wpf assembly
            Type markdownType = typeof(Markdig.Wpf.Markdown);

            IsMarkdownAssemblyLoaded = markdownType != null;
            Type jsonType = typeof(Newtonsoft.Json.JsonSerializer);

            IsNewtonsoftJsonAssemblyLoaded = jsonType != null;

            DTE = (EnvDTE80.DTE2) await GetServiceAsync(typeof(DTE));

            ComponentModel = (IComponentModel) await GetServiceAsync(typeof(SComponentModel));

            // When initialized asynchronously, the current thread may be a background thread at this point.
            // Do any initialization that requires the UI thread after switching to the UI thread.
            await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            solutionEvents             = DTE.Events.SolutionEvents;
            solutionOpenedEventHandler = new _dispSolutionEvents_OpenedEventHandler(HandleSolutionOpened);
            solutionEvents.Opened     += solutionOpenedEventHandler;

            await TexoToolWindow.InitializeAsync(this);
        }