示例#1
0
 /// <summary>
 /// Sets the instance of currently running Visual Studio IDE.
 /// </summary>
 /// <param name="dte">The DTE.</param>
 internal static void SetDTE(DTE dte)
 {
     DTE = dte;
     if (dte != null)
     {
         debuggerEvents = DTE.Events.DebuggerEvents;
         debuggerEvents.OnEnterBreakMode  += DebuggerEvents_OnEnterBreakMode;
         debuggerEvents.OnEnterDesignMode += DebuggerEvents_OnEnterDesignMode;
         debuggerEvents.OnEnterRunMode    += DebuggerEvents_OnEnterRunMode;
         debuggerProxy = (VSDebuggerProxy)AppDomain.CurrentDomain.GetData(VSDebuggerProxy.AppDomainDataName) ?? new VSDebuggerProxy();
         VSDebugger    = new VSDebugger(debuggerProxy);
         Engine.Context.InitializeDebugger(VSDebugger, new DiaSymbolProvider());
     }
     else
     {
         // 90s all over again :)
         var timer = new System.Windows.Threading.DispatcherTimer();
         timer.Tick += (a, b) =>
         {
             timer.Stop();
             if (DTE == null)
             {
                 InitializeDTE();
             }
         };
         timer.Interval = TimeSpan.FromSeconds(0.1);
         timer.Start();
     }
 }
示例#2
0
        /// <summary>
        /// Implements the OnConnection method of the IDTExtensibility2 interface.
        /// Receives notification that the Add-in is being loaded.
        /// </summary>
        /// <param name="application">Root object of the host application.</param>
        /// <param name="connectMode">
        /// Describes how the Add-in is being loaded (e.g. command line or UI). This is unused since
        /// the add-in functions the same regardless of how it was loaded.
        /// </param>
        /// <param name="addInInst">Object representing this Add-in.</param>
        /// <param name="custom">Unused, but could contain host specific data for the add-in.</param>
        /// <seealso class='IDTExtensibility2' />
        public void OnConnection(
            object application,
            ext_ConnectMode connectMode,
            object addInInst,
            ref Array custom)
        {
            dte_ = (DTE2)application;

            debuggerEvents_ = dte_.Events.DebuggerEvents;
            debuggerEvents_.OnEnterDesignMode += DebuggerOnEnterDesignMode;
            debuggerEvents_.OnEnterRunMode    += DebuggerOnEnterRunMode;

            commandEvents_ = dte_.Events.CommandEvents;
            commandEvents_.AfterExecute += CommandEventsAfterExecute;

            try
            {
                webServerOutputPane_ = dte_.ToolWindows.OutputWindow.OutputWindowPanes.Item(
                    Strings.WebServerOutputWindowTitle);
            }
            catch (ArgumentException)
            {
                // This exception is expected if the window pane hasn't been created yet.
                webServerOutputPane_ = dte_.ToolWindows.OutputWindow.OutputWindowPanes.Add(
                    Strings.WebServerOutputWindowTitle);
            }
        }
示例#3
0
 private void SetDebugEvents()
 {
     _debugerEvents = _dte.Events.DebuggerEvents;
     _debugerEvents.OnEnterBreakMode  += DebuggerEvents_OnEnterBreakMode;
     _debugerEvents.OnEnterDesignMode += debugerEvents_OnEnterDesignMode;
     _debugerEvents.OnEnterRunMode    += debugerEvents_OnEnterRunMode;
 }
        void VsShellPropertyEvents_AfterShellPropertyChanged(object sender, VsShellPropertyEventsHandler.ShellPropertyChangeEventArgs e)
        {
            SafeExecute(() =>
            {
                // when zombie state changes to false, finish package initialization
                //! DO NOT USE CODE WHICH MAY EXECUTE FOR LONG TIME HERE

                if ((int)__VSSPROPID.VSSPROPID_Zombie == e.PropId)
                {
                    if ((bool)e.Var == false)
                    {
                        var dte2 = ServiceProvider.GetDte2();

                        Events          = dte2.Events as Events2;
                        DTEEvents       = Events.DTEEvents;
                        SolutionEvents  = Events.SolutionEvents;
                        DocumentEvents  = Events.DocumentEvents;
                        WindowEvents    = Events.WindowEvents;
                        DebuggerEvents  = Events.DebuggerEvents;
                        CommandEvents   = Events.CommandEvents;
                        SelectionEvents = Events.SelectionEvents;

                        DelayedInitialise();
                    }
                }
            });
        }
示例#5
0
    /// <summary>
    /// Implements the OnConnection method of the IDTExtensibility2 interface.
    /// Receives notification that the Add-in is being loaded.
    /// </summary>
    /// <param name="application">Root object of the host application.</param>
    /// <param name="connectMode">
    /// Describes how the Add-in is being loaded (e.g. command line or UI). This is unused since
    /// the add-in functions the same regardless of how it was loaded.
    /// </param>
    /// <param name="addInInst">Object representing this Add-in.</param>
    /// <param name="custom">Unused, but could contain host specific data for the add-in.</param>
    /// <seealso class='IDTExtensibility2' />
    public void OnConnection(
        object application,
        ext_ConnectMode connectMode,
        object addInInst,
        ref Array custom)
    {
      dte_ = (DTE2)application;

      debuggerEvents_ = dte_.Events.DebuggerEvents;
      debuggerEvents_.OnEnterDesignMode += DebuggerOnEnterDesignMode;
      debuggerEvents_.OnEnterRunMode += DebuggerOnEnterRunMode;

      commandEvents_ = dte_.Events.CommandEvents;
      commandEvents_.AfterExecute += CommandEventsAfterExecute;

      try
      {
        webServerOutputPane_ = dte_.ToolWindows.OutputWindow.OutputWindowPanes.Item(
            Strings.WebServerOutputWindowTitle);
      }
      catch (ArgumentException)
      {
        // This exception is expected if the window pane hasn't been created yet.
        webServerOutputPane_ = dte_.ToolWindows.OutputWindow.OutputWindowPanes.Add(
            Strings.WebServerOutputWindowTitle);
      }
    }
示例#6
0
        /// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
        /// <param term='application'>Root object of the host application.</param>
        /// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
        /// <param term='addInInst'>Object representing this Add-in.</param>
        /// <seealso class='IDTExtensibility2' />
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            _applicationObject = (DTE2)application;
            _addInInstance = (AddIn)addInInst;

            _dbgWatchConfig = new QuickWatchConfig();

            try {
                CommandBar commandBar = ((CommandBars)_applicationObject.CommandBars)["Code Window"];

                // Create Quick watch menu
                _controlQuickWatch = commandBar.Controls.Add(MsoControlType.msoControlButton, System.Reflection.Missing.Value, System.Reflection.Missing.Value, 1, true);
                _controlQuickWatch.Caption = "QuickWatchEx...";
                _controlQuickWatch.Enabled = IsInDebugMode(_applicationObject);

                _menuItemHandlerQuickWatch = (CommandBarEvents)_applicationObject.Events.CommandBarEvents[_controlQuickWatch];
                _menuItemHandlerQuickWatch.Click += MenuItemHandlerQuickWatch_Click;

                _debuggerEvents = _applicationObject.Events.DebuggerEvents;
                _debuggerEvents.OnEnterDesignMode += DebuggerEvents_OnEnterDesignMode;
                _debuggerEvents.OnEnterBreakMode += DebuggerEvents_OnEnterBreakMode;
                _debuggerEvents.OnEnterRunMode += DebuggerEvents_OnEnterRunMode;
            } catch (Exception e) {
                MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#7
0
        public ExpertWatch() : base(null)
        {
            Caption = "Expert Watch";

            DTE DTE2 = ExpertWatchCommand.Instance.ServiceProvider.GetService(typeof(DTE)) as DTE;

            if (DTE2 != null)
            {
                ViewModel viewModel = new ViewModel(DTE2.Debugger);

                BlueprintsOptionPage page = (BlueprintsOptionPage)ExpertWatchCommand.Instance.package.GetDialogPage(typeof(BlueprintsOptionPage));
                page.OptionChangedEvent += viewModel.OnToolsOptionsBlueprintsChanged;

                //viewModel.OnToolsOptionsBlueprintsChanged(page.Blueprints);

                ExpertWatchWindow window = new ExpertWatchWindow();
                window.DataContext = viewModel;

                Content        = window;
                DebuggerEvents = DTE2.Events.DebuggerEvents;
                DebuggerEvents.OnEnterBreakMode  += viewModel.OnEnterBreakMode;
                DebuggerEvents.OnEnterRunMode    += ExpertWatchCommand.Instance.RunHandler;
                DebuggerEvents.OnEnterDesignMode += ExpertWatchCommand.Instance.DesignHandler;
            }
        }
示例#8
0
        /// <summary>
        /// Enables the Trace manager to register for Debugger break events;
        /// </summary>
        /// <param name="unsubscribeOnDebugSessionEnd"></param>
        void SubscribeForDebuggerEvents()
        {
            if (subscribedForDebuggerBreak)
            {
                StatusReporter.Report(Resources.MsgAlreadySubscribedForDbgBreak, Status.INFO);
                return;
            }

            if (!dteInitialized)
            {
                InitializeDTE();
            }

            //Cache the debuggerEvents object so that it is not disposed by the shell.
            debuggerEvents = dte.Events.DebuggerEvents;
            if (debuggerEvents == null)
            {
                throw new NullReferenceException(Resources.MsgDebuggerEventsObjNull);
            }

            debuggerEvents.OnEnterBreakMode  += new EnvDTE._dispDebuggerEvents_OnEnterBreakModeEventHandler(DebuggerEvents_OnEnterBreakMode);
            debuggerEvents.OnEnterDesignMode += new _dispDebuggerEvents_OnEnterDesignModeEventHandler(debuggerEvents_OnEnterDesignMode);
            StatusReporter.Report(Resources.MsgDbgBreakEventSubscribeSuccess, Status.INFO);
            subscribedForDebuggerBreak = true;
        }
示例#9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CodeWithKemonoFriends"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private CodeWithKemonoFriends(Package package)
        {
            _package = package ?? throw new ArgumentNullException(nameof(package));

            OleMenuCommandService commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                var menuCommandId = new CommandID(CommandSet, CommandId);
                var menuItem      = new MenuCommand(MenuItemCallback, menuCommandId);
                commandService.AddCommand(menuItem);
            }

            // このプロジェクトのディレクトリを取得
            var codebase = typeof(CodeWithKemonoFriends).Assembly.CodeBase;
            var uri      = new Uri(codebase, UriKind.Absolute);

            _projectDirectory = Path.GetDirectoryName(uri.LocalPath);

            // イベントを初期化
            var dte = (DTE)ServiceProvider.GetService(typeof(DTE));

            _buildEvents    = dte.Events.BuildEvents;
            _debuggerEvents = dte.Events.DebuggerEvents;

            // Notifierを初期化
            var appId = "VisualStudio." + dte.RegistryRoot.Split('_').Last();

            _notifier = ToastNotificationManager.CreateToastNotifier(appId);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GeometryWatchControl"/> class.
        /// </summary>
        public GeometryWatchControl()
        {
            m_dte            = (DTE2)ServiceProvider.GlobalProvider.GetService(typeof(DTE));
            m_debugger       = m_dte.Debugger;
            m_debuggerEvents = m_dte.Events.DebuggerEvents;
            m_debuggerEvents.OnEnterBreakMode += DebuggerEvents_OnEnterBreakMode;

            VSColorTheme.ThemeChanged += VSColorTheme_ThemeChanged;

            m_colors   = new Colors(this);
            m_intsPool = new Util.IntsPool(m_colors.Count);

            this.InitializeComponent();

            m_emptyBitmap = new Bitmap(100, 100);
            Graphics graphics = Graphics.FromImage(m_emptyBitmap);

            graphics.Clear(m_colors.ClearColor);
            image.Source = Util.BitmapToBitmapImage(m_emptyBitmap);

            Geometries           = new ObservableCollection <GeometryItem>();
            dataGrid.ItemsSource = Geometries;

            ResetAt(new GeometryItem(-1, m_colors), Geometries.Count);
        }
示例#11
0
 public DebugController(IDialControllerHost host)
 {
     _dte    = host.DTE;
     _events = _dte.Events.DebuggerEvents;
     _events.OnEnterBreakMode  += delegate { host.RequestActivation(_dte.MainWindow, Moniker); };
     _events.OnEnterDesignMode += delegate { host.ReleaseActivation(_dte.MainWindow); };
 }
示例#12
0
        public async Task <MakeTheSoundEventCatcher> InitAsync(AsyncPackage package, OptionsPage optionsPage)
        {
            if (_package != null)
            {
                return(this);
            }

            OptionsPage = optionsPage;

            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            _package = package;

            _dte = (DTE2)await _package.GetServiceAsync(typeof(DTE));

            Assumes.Present(_dte);

            _events         = _dte.Events as Events2;
            _buildEvents    = _events.BuildEvents;
            _commands       = _dte.Commands;
            _debuggerEvents = _events.DebuggerEvents;

            await AddActionAsync(IDEEventType.FileSaveAll);
            await AddActionAsync(IDEEventType.FileSave);
            await AddActionAsync(IDEEventType.Building);
            await AddActionAsync(IDEEventType.Breakepoint);
            await AddActionAsync(IDEEventType.Exception);

            return(this);
        }
示例#13
0
        private DebugHandler(DTE2 dte)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            this.dte            = dte;
            this.debugger       = dte.Debugger;
            this.debuggerEvents = this.dte.Events.DebuggerEvents;
        }
        /// <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()
        {
            base.Initialize();

            // Load up the options from file.
            string  optionsFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "NiftySolution.xml");
            Options options         = Options.Load(optionsFileName);

            // Create our main plugin facade.
            DTE2 application = GetGlobalService(typeof(DTE)) as DTE2;
            IVsProfferCommands3   profferCommands3      = base.GetService(typeof(SVsProfferCommands)) as IVsProfferCommands3;
            OleMenuCommandService oleMenuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            ImageList icons = new ImageList();

            icons.Images.AddStrip(Properties.Resources.Icons);
            m_plugin = new Plugin(application, profferCommands3, icons, oleMenuCommandService, "NiftySolution", "Aurora.NiftySolution.Connect", options);

            // Every plugin needs a command bar.
            CommandBar commandBar = m_plugin.AddCommandBar("NiftySolution", MsoBarPosition.msoBarTop);

            m_commandRegistry = new CommandRegistry(m_plugin, commandBar, new Guid(PackageGuidString), new Guid(PackageGuidGroup));

            // Initialize the logging system.
            if (Log.HandlerCount == 0)
            {
                                #if DEBUG
                Log.AddHandler(new DebugLogHandler());
                                #endif

                Log.AddHandler(new VisualStudioLogHandler(m_plugin));
                Log.Prefix = "NiftySolution";
            }

            // Now we can take care of registering ourselves and all our commands and hooks.
            Log.Debug("Booting up...");
            Log.IncIndent();


            bool doBindings = options.EnableBindings;

            m_commandRegistry.RegisterCommand(doBindings, new QuickOpen(m_plugin, "NiftyOpen"));
            m_commandRegistry.RegisterCommand(doBindings, new ToggleFile(m_plugin, "NiftyToggle"));
            m_commandRegistry.RegisterCommand(doBindings, new CloseToolWindow(m_plugin, "NiftyClose"));
            m_commandRegistry.RegisterCommand(doBindings, new Configure(m_plugin, "NiftyConfigure"));

            if (options.SilentDebuggerExceptions || options.IgnoreDebuggerExceptions)
            {
                m_debuggerEvents = application.Events.DebuggerEvents;
                m_debuggerEvents.OnExceptionNotHandled += new _dispDebuggerEvents_OnExceptionNotHandledEventHandler(OnExceptionNotHandled);
            }

            m_timings = new SolutionBuildTimings(m_plugin);

            Log.DecIndent();
            Log.Debug("Initialized...");
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicalWatchControl"/> class.
        /// </summary>
        public GraphicalWatchControl()
        {
            this.InitializeComponent();

            m_dte = (DTE2)ServiceProvider.GlobalProvider.GetService(typeof(DTE));
            m_debugger = m_dte.Debugger;
            m_debuggerEvents = m_dte.Events.DebuggerEvents;
            m_debuggerEvents.OnEnterBreakMode += DebuggerEvents_OnEnterBreakMode;
        }
        public DebugController(RadialControllerMenuItem menuItem, DTE2 dte) : base(menuItem)
        {
            _dte = dte;
            // Switched in provider
#pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread
            _events = dte.Events.DebuggerEvents;
            _events.OnEnterBreakMode  += delegate { DialPackage.DialControllerHost.RequestActivation(this); };
            _events.OnEnterDesignMode += delegate { DialPackage.DialControllerHost.ReleaseActivation(); };
#pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread
        }
示例#17
0
 public DebuggerEventGenerator(IRSEnv env, IMessageBus messageBus, IDateUtils dateUtils, IThreading threading)
     : base(env, messageBus, dateUtils, threading)
 {
     _debuggerEvents = DTE.Events.DebuggerEvents;
     _debuggerEvents.OnEnterBreakMode      += _debuggerEvents_OnEnterBreakMode;
     _debuggerEvents.OnEnterDesignMode     += _debuggerEvents_OnEnterDesignMode;
     _debuggerEvents.OnEnterRunMode        += _debuggerEvents_OnEnterRunMode;
     _debuggerEvents.OnExceptionNotHandled += _debuggerEvents_OnExceptionNotHandled;
     _debuggerEvents.OnExceptionThrown     += _debuggerEvents_OnExceptionThrown;
 }
示例#18
0
            public void OnConnection(object application_, ext_ConnectMode connectMode, object addInInst, ref Array custom)
            {
                if (null != m_plugin)
                {
                    return;
                }

                // Load up the options from file.
                string  optionsFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "NiftySolution.xml");
                Options options         = Options.Load(optionsFileName);

                // Create our main plugin facade.
                DTE2 application = (DTE2)application_;

                m_plugin = new Plugin(application, (AddIn)addInInst, "NiftySolution", "Aurora.NiftySolution.Connect", options);

                // Every plugin needs a command bar.
                CommandBar commandBar = m_plugin.AddCommandBar("NiftySolution", MsoBarPosition.msoBarTop);

                m_commandRegistry = new CommandRegistry(m_plugin, commandBar);

                // Initialize the logging system.
                if (Log.HandlerCount == 0)
                {
                                        #if DEBUG
                    Log.AddHandler(new DebugLogHandler());
                                        #endif

                    Log.AddHandler(new VisualStudioLogHandler(m_plugin.OutputPane));
                    Log.Prefix = "NiftySolution";
                }

                // Now we can take care of registering ourselves and all our commands and hooks.
                Log.Debug("Booting up...");
                Log.IncIndent();


                bool doBindings = options.EnableBindings;

                m_commandRegistry.RegisterCommand("NiftyOpen", doBindings, new QuickOpen(m_plugin));
                m_commandRegistry.RegisterCommand("NiftyToggle", doBindings, new ToggleFile(m_plugin));
                m_commandRegistry.RegisterCommand("NiftyClose", doBindings, new CloseToolWindow(m_plugin));
                m_commandRegistry.RegisterCommand("NiftyConfigure", doBindings, new Configure(m_plugin));

                if (options.SilentDebuggerExceptions || options.IgnoreDebuggerExceptions)
                {
                    m_debuggerEvents = application.Events.DebuggerEvents;
                    m_debuggerEvents.OnExceptionNotHandled += new _dispDebuggerEvents_OnExceptionNotHandledEventHandler(OnExceptionNotHandled);
                }

                m_timings = new SolutionBuildTimings(m_plugin);

                Log.DecIndent();
                Log.Debug("Initialized...");
            }
示例#19
0
 public NoSourceWindowHider(JoinableTaskContext taskContext,
                            IServiceProvider serviceProvider,
                            IExceptionRecorder exceptionRecorder, YetiVSIService vsiService)
 {
     taskContext.ThrowIfNotOnMainThread();
     _taskContext       = taskContext;
     _serviceProvider   = serviceProvider;
     _exceptionRecorder = exceptionRecorder;
     _vsiService        = vsiService;
     _debuggerEvents    = GetDte().Events.DebuggerEvents;
 }
示例#20
0
 /// <summary>
 /// Sets the instance of currently running Visual Studio IDE.
 /// </summary>
 /// <param name="dte">The DTE.</param>
 internal static void SetDTE(DTE dte)
 {
     DTE            = dte;
     debuggerEvents = DTE.Events.DebuggerEvents;
     debuggerEvents.OnEnterBreakMode  += DebuggerEvents_OnEnterBreakMode;
     debuggerEvents.OnEnterDesignMode += DebuggerEvents_OnEnterDesignMode;
     debuggerEvents.OnEnterRunMode    += DebuggerEvents_OnEnterRunMode;
     debuggerProxy = (VSDebuggerProxy)AppDomain.CurrentDomain.GetData(VSDebuggerProxy.AppDomainDataName) ?? new VSDebuggerProxy();
     VSDebugger    = new VSDebugger(debuggerProxy);
     Engine.Context.InitializeDebugger(VSDebugger);
 }
示例#21
0
        private async Task InitializeAsync(CancellationToken cancellationToken)
        {
            if (_dte is null)
            {
                _logger.Error("DTE is null");
                return;
            }

            try
            {
                await _wakatime.InitializeAsync();

                // 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);

                // Visual Studio Events
                _docEvents        = _dte.Events.DocumentEvents;
                _windowEvents     = _dte.Events.WindowEvents;
                _solutionEvents   = _dte.Events.SolutionEvents;
                _debuggerEvents   = _dte.Events.DebuggerEvents;
                _buildEvents      = _dte.Events.BuildEvents;
                _textEditorEvents = _dte.Events.TextEditorEvents;

                // Settings Form
                _settingsForm = new SettingsForm(_wakatime.Config, _logger);

                // Add our command handlers for menu (commands must exist in the .vsct file)
                if (await GetServiceAsync(typeof(IMenuCommandService)) is OleMenuCommandService mcs)
                {
                    // Create the command for the menu item.
                    var menuCommandId = new CommandID(new Guid(GuidList.GuidWakaTimeCmdSetString), 0x100);
                    var menuItem      = new MenuCommand(MenuItemCallback, menuCommandId);
                    mcs.AddCommand(menuItem);
                }

                // setup event handlers
                _docEvents.DocumentOpened           += DocEventsOnDocumentOpened;
                _docEvents.DocumentSaved            += DocEventsOnDocumentSaved;
                _windowEvents.WindowActivated       += WindowEventsOnWindowActivated;
                _solutionEvents.Opened              += SolutionEventsOnOpened;
                _debuggerEvents.OnEnterRunMode      += DebuggerEventsOnEnterRunMode;
                _debuggerEvents.OnEnterDesignMode   += DebuggerEventsOnEnterDesignMode;
                _debuggerEvents.OnEnterBreakMode    += DebuggerEventsOnEnterBreakMode;
                _buildEvents.OnBuildProjConfigBegin += BuildEventsOnBuildProjConfigBegin;
                _buildEvents.OnBuildProjConfigDone  += BuildEventsOnBuildProjConfigDone;
                _textEditorEvents.LineChanged       += TextEditorEventsLineChanged;
            }
            catch (Exception ex)
            {
                _logger.Error("Error Initializing WakaTime", ex);
            }
        }
示例#22
0
        public ShellEventsListener(DTE2 dte)
        {
            appObject   = dte;
            dteEvents   = dte.Events.DTEEvents;
            debugEvents = dte.Events.DebuggerEvents;
            currentMode = ShellHelper.GetMode(appObject);

            dteEvents.ModeChanged         += InternalModeChanged;
            debugEvents.OnEnterBreakMode  += OnEnterBreakMode;
            debugEvents.OnEnterDesignMode += OnEnterDesignMode;
            debugEvents.OnEnterRunMode    += OnEnterRunMode;
        }
        protected override void Initialize()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", ToString()));
            base.Initialize();

            applicationObject = (DTE2)GetService(typeof(DTE));
            buildEvents       = applicationObject.Events.BuildEvents;
            debugEvents       = applicationObject.Events.DebuggerEvents;

            players = new Players(this.SoundSettingsOverrides);
            this.soundOverridesSettings.OnApplyHandler += () => this.players.SoundSettingsChanged();
            SetupEventHandlers();
        }
示例#24
0
        private void AttachToEvents()
        {
            _solutionEvents               = DTE.Events.SolutionEvents;
            _solutionEvents.Opened       += OnSolutionOpened;
            _solutionEvents.AfterClosing += OnSolutionAfterClosing;

            _buildEvents               = DTE.Events.BuildEvents;
            _buildEvents.OnBuildDone  += OnBuildDone;
            _buildEvents.OnBuildBegin += OnBuildBegin;

            _debuggerEvents = DTE.Events.DebuggerEvents;
            _debuggerEvents.OnEnterRunMode += _debuggerEvents_OnEnterRunMode;
        }
			public void OnConnection(object application_, ext_ConnectMode connectMode, object addInInst, ref Array custom)
			{
				if(null != m_plugin)
					return;

				// Load up the options from file.
				string optionsFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "NiftySolution.xml");
				Options options = Options.Load(optionsFileName);

				// Create our main plugin facade.
				DTE2 application = (DTE2)application_;
				m_plugin = new Plugin(application, (AddIn)addInInst, "NiftySolution", "Aurora.NiftySolution.Connect", options);
				
				// Every plugin needs a command bar.
				CommandBar commandBar = m_plugin.AddCommandBar("NiftySolution", MsoBarPosition.msoBarTop);
				m_commandRegistry = new CommandRegistry(m_plugin, commandBar);

				// Initialize the logging system.
				if(Log.HandlerCount == 0)
				{
					#if DEBUG
					Log.AddHandler(new DebugLogHandler());
					#endif

					Log.AddHandler(new VisualStudioLogHandler(m_plugin.OutputPane));
					Log.Prefix = "NiftySolution";
				}

				// Now we can take care of registering ourselves and all our commands and hooks.
				Log.Debug("Booting up...");
				Log.IncIndent();


				bool doBindings = options.EnableBindings;

				m_commandRegistry.RegisterCommand("NiftyOpen", doBindings, new QuickOpen(m_plugin));
				m_commandRegistry.RegisterCommand("NiftyToggle", doBindings, new ToggleFile(m_plugin));
				m_commandRegistry.RegisterCommand("NiftyClose", doBindings, new CloseToolWindow(m_plugin));
				m_commandRegistry.RegisterCommand("NiftyConfigure", doBindings, new Configure(m_plugin));

                if (options.SilentDebuggerExceptions || options.IgnoreDebuggerExceptions)
                {
                    m_debuggerEvents = application.Events.DebuggerEvents;
                    m_debuggerEvents.OnExceptionNotHandled += new _dispDebuggerEvents_OnExceptionNotHandledEventHandler(OnExceptionNotHandled);
                }

				m_timings = new SolutionBuildTimings(m_plugin);

				Log.DecIndent();
				Log.Debug("Initialized...");
			}
示例#26
0
        public void UnregisterEvents()
        {
            //logger.LogMessage("UnRegistering events");
            Microsoft.VisualStudio.Shell.Events.SolutionEvents.OnAfterBackgroundSolutionLoadComplete -= SolutionEvents_OnAfterBackgroundSolutionLoadComplete;
            Microsoft.VisualStudio.Shell.Events.SolutionEvents.OnAfterCloseSolution -= SolutionEvents_OnAfterCloseSolution;
            BuildEvents.OnBuildBegin -= BuildEvents_OnBuildBegin;
            BuildEvents.OnBuildDone  -= BuildEvents_OnBuildDone;

            DebuggerEvents.OnEnterRunMode    -= DebuggerEvents_OnEnterRunMode;
            DebuggerEvents.OnEnterDesignMode -= DebuggerEvents_OnEnterDesignMode;

            BuildEvents    = null;
            DebuggerEvents = null;
        }
示例#27
0
        public LeakBaseClass(object[] args) : base(args)
        {
            _perfGraphToolWindowControl.TabControl.SelectedIndex = 1; // select graph tab

            BuildEvents    = _dte.Events.BuildEvents;
            DebuggerEvents = _dte.Events.DebuggerEvents;

            Microsoft.VisualStudio.Shell.Events.SolutionEvents.OnAfterBackgroundSolutionLoadComplete += SolutionEvents_OnAfterBackgroundSolutionLoadComplete;
            Microsoft.VisualStudio.Shell.Events.SolutionEvents.OnAfterCloseSolution += SolutionEvents_OnAfterCloseSolution;
            BuildEvents.OnBuildBegin += BuildEvents_OnBuildBegin;
            BuildEvents.OnBuildDone  += BuildEvents_OnBuildDone;

            DebuggerEvents.OnEnterRunMode    += DebuggerEvents_OnEnterRunMode;
            DebuggerEvents.OnEnterDesignMode += DebuggerEvents_OnEnterDesignMode;
        }
示例#28
0
        /// <summary>
        /// Initializes the singleton instance of the command.
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        public static async Task InitializeAsync(AsyncPackage package)
        {
            // Switch to the main thread - the call to AddCommand in DumpStackToCSharpCodeCommand's constructor requires
            // the UI thread.
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken);

            var dte = await package.GetServiceAsync(typeof(DTE)) ?? throw new Exception("GetServiceAsync returned DTE null");

            _dte            = dte as DTE2;
            _debuggerEvents = _dte.Events.DebuggerEvents;

            var commandService = await package.GetServiceAsync((typeof(IMenuCommandService))) as OleMenuCommandService;

            Instance = new DumpStackToCSharpCodeCommand(package, commandService);
        }
示例#29
0
 public DTEEventSource( Events2 events)
 {
     _buildEvents = events.BuildEvents;
     _dteEvents = events.DTEEvents;
     _debuggerEvents = events.DebuggerEvents;
     _debuggerProcessEvents = events.DebuggerProcessEvents;
     _debuggerExpressionEvaluationEvents = events.DebuggerExpressionEvaluationEvents;
     _findEvents = events.FindEvents;
     _miscFileEvents = events.MiscFilesEvents;
     _projectItemsEvents = events.ProjectItemsEvents;
     _projectEvents = events.ProjectsEvents;
     _publishEvents = events.PublishEvents;
     _selectionEvents = events.SelectionEvents;
     _solutionEvents = events.SolutionEvents;
     _solutionItemEvents = events.SolutionItemsEvents;            
 }
示例#30
0
 public DTEEventSource(Events2 events)
 {
     _buildEvents           = events.BuildEvents;
     _dteEvents             = events.DTEEvents;
     _debuggerEvents        = events.DebuggerEvents;
     _debuggerProcessEvents = events.DebuggerProcessEvents;
     _debuggerExpressionEvaluationEvents = events.DebuggerExpressionEvaluationEvents;
     _findEvents         = events.FindEvents;
     _miscFileEvents     = events.MiscFilesEvents;
     _projectItemsEvents = events.ProjectItemsEvents;
     _projectEvents      = events.ProjectsEvents;
     _publishEvents      = events.PublishEvents;
     _selectionEvents    = events.SelectionEvents;
     _solutionEvents     = events.SolutionEvents;
     _solutionItemEvents = events.SolutionItemsEvents;
 }
示例#31
0
        public VSOperations()
        {
            //Initializing Variables

            dte = Package.GetGlobalService(typeof(DTE)) as DTE;
            //dte.Events.WindowEvents.WindowClosing += OnClose;
            textManager = (IVsTextManager)Package.GetGlobalService(typeof(SVsTextManager));
            debugEvents = dte.Events.DebuggerEvents;
            mTalkPoints = new List <Talkpoint>();

            //Setting Handlers
            SetBreakModeHandler();
            SetExceptionHandler();
            //VS Document focussed changed event
            OnDocumentFocusChanged();
        }
示例#32
0
 public void EndWork()
 {
     this.buttonBuildSolution.Click -= new EventHandler <ThumbnailButtonClickedEventArgs>(this.buttonBuildSolution_Click);
     this.buttonDebug.Click         -= new EventHandler <ThumbnailButtonClickedEventArgs>(this.buttonDebug_Click);
     this.buttonRun.Click           -= new EventHandler <ThumbnailButtonClickedEventArgs>(this.buttonRun_Click);
     this.DisableToolbar();
     this._buildEvents = this._applicationObject.Events.BuildEvents;
     this._buildEvents.OnBuildBegin         += new _dispBuildEvents_OnBuildBeginEventHandler(OnBuildBegin);
     this._buildEvents.OnBuildDone          -= new _dispBuildEvents_OnBuildDoneEventHandler(OnBuildDone);
     this._debuggerEvents                    = this._applicationObject.Events.DebuggerEvents;
     this._debuggerEvents.OnEnterRunMode    += (new _dispDebuggerEvents_OnEnterRunModeEventHandler(this.OnEnterRunMode));
     this._debuggerEvents.OnEnterDesignMode -= (new _dispDebuggerEvents_OnEnterDesignModeEventHandler(this.OnEnterDesignMode));
     this._solutionEvents                    = this._applicationObject.Events.SolutionEvents;
     this._solutionEvents.Opened            -= (new _dispSolutionEvents_OpenedEventHandler(this.EnableToolbar));
     this._solutionEvents.AfterClosing      -= (new _dispSolutionEvents_AfterClosingEventHandler(this.DisableToolbar));
 }
示例#33
0
 public void Startup()
 {
     this.buttonBuildSolution.Click += new EventHandler <ThumbnailButtonClickedEventArgs>(this.buttonBuildSolution_Click);
     this.buttonDebug.Click         += new EventHandler <ThumbnailButtonClickedEventArgs>(this.buttonDebug_Click);
     this.buttonRun.Click           += new EventHandler <ThumbnailButtonClickedEventArgs>(this.buttonRun_Click);
     _taskbarManager.ThumbnailToolBars.AddButtons((IntPtr)this._applicationObject.MainWindow.HWnd, new ThumbnailToolBarButton[] { this.buttonBuildSolution, this.buttonDebug, this.buttonRun });
     this.DisableToolbar();
     this._buildEvents = this._applicationObject.Events.BuildEvents;
     this._buildEvents.OnBuildBegin         += new _dispBuildEvents_OnBuildBeginEventHandler(OnBuildBegin);
     this._buildEvents.OnBuildDone          += new _dispBuildEvents_OnBuildDoneEventHandler(OnBuildDone);
     this._debuggerEvents                    = this._applicationObject.Events.DebuggerEvents;
     this._debuggerEvents.OnEnterRunMode    += (new _dispDebuggerEvents_OnEnterRunModeEventHandler(this.OnEnterRunMode));
     this._debuggerEvents.OnEnterDesignMode += (new _dispDebuggerEvents_OnEnterDesignModeEventHandler(this.OnEnterDesignMode));
     this._solutionEvents                    = this._applicationObject.Events.SolutionEvents;
     this._solutionEvents.Opened            += (new _dispSolutionEvents_OpenedEventHandler(this.EnableToolbar));
     this._solutionEvents.AfterClosing      += (new _dispSolutionEvents_AfterClosingEventHandler(this.DisableToolbar));
 }
示例#34
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()
        {
            Command.Initialize(this);
            base.Initialize();

            applicationObject  = (DTE2)GetService(typeof(DTE));
            debugEvents        = applicationObject.Events.DebuggerEvents;
            commandEvents      = applicationObject.Events.CommandEvents;
            solutionEvents     = applicationObject.Events.SolutionEvents;
            currentCommandStep = CurrentCommandStep.StepInto;

            solutionEvents.Opened         += SolutionEvents_Opened;
            debugEvents.OnEnterBreakMode  += DebugEvents_OnEnterBreakMode;
            debugEvents.OnEnterDesignMode += DebugEvents_OnEnterDesignMode;
            debugEvents.OnEnterRunMode    += DebugEvents_OnEnterRunMode;
            commandEvents.AfterExecute    += CommandEvents_AfterExecute;
        }
示例#35
0
        BreakpointEvents(EnvDTE.DTE dte)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            m_Dte = dte;

            // seems like this reallocates it. if we modify just the DTE, event listeners
            // won't persist once this is out of scope.
            m_debuggerEvents = dte.Events.DebuggerEvents;
            m_debuggerEvents.OnEnterBreakMode  += this.OnEnterBreakMode;
            m_debuggerEvents.OnEnterDesignMode += this.OnEnterDesignMode;

            m_solutionEvents = dte.Events.SolutionEvents;
            m_solutionEvents.BeforeClosing += OnBeforeClosing;


            SolutionOpenedImpl();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicalWatchControl"/> class.
        /// </summary>
        public GraphicalWatchControl()
        {
            m_dte = (DTE2)ServiceProvider.GlobalProvider.GetService(typeof(DTE));
            m_debugger = m_dte.Debugger;
            m_debuggerEvents = m_dte.Events.DebuggerEvents;
            m_debuggerEvents.OnEnterBreakMode += DebuggerEvents_OnEnterBreakMode;

            VSColorTheme.ThemeChanged += VSColorTheme_ThemeChanged;

            m_colors = new Colors(this);

            Variables = new ObservableCollection<VariableItem>();

            this.InitializeComponent();

            dataGrid.ItemsSource = Variables;

            ResetAt(new VariableItem(), Variables.Count);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GeometryWatchControl"/> class.
        /// </summary>
        public GeometryWatchControl()
        {
            m_dte = (DTE2)ServiceProvider.GlobalProvider.GetService(typeof(DTE));
            m_debugger = m_dte.Debugger;
            m_debuggerEvents = m_dte.Events.DebuggerEvents;
            m_debuggerEvents.OnEnterBreakMode += DebuggerEvents_OnEnterBreakMode;

            m_colorsPool = new Util.ColorsPool();

            m_emptyBitmap = new Bitmap(100, 100);
            Graphics graphics = Graphics.FromImage(m_emptyBitmap);
            graphics.Clear(Color.White);

            this.InitializeComponent();

            image.Source = Util.BitmapToBitmapImage(m_emptyBitmap);

            GeometryItem var = new GeometryItem(m_colorsPool.Transparent);
            ((System.ComponentModel.INotifyPropertyChanged)var).PropertyChanged += GeometryItem_NameChanged;
            listView.Items.Add(var);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GeometryWatchControl"/> class.
        /// </summary>
        public GeometryWatchControl()
        {
            m_dte = (DTE2)ServiceProvider.GlobalProvider.GetService(typeof(DTE));
            m_debugger = m_dte.Debugger;
            m_debuggerEvents = m_dte.Events.DebuggerEvents;
            m_debuggerEvents.OnEnterBreakMode += DebuggerEvents_OnEnterBreakMode;

            VSColorTheme.ThemeChanged += VSColorTheme_ThemeChanged;

            m_colors = new Colors(this);
            m_intsPool = new Util.IntsPool(m_colors.Count);

            this.InitializeComponent();

            m_emptyBitmap = new Bitmap(100, 100);
            Graphics graphics = Graphics.FromImage(m_emptyBitmap);
            graphics.Clear(m_colors.ClearColor);
            image.Source = Util.BitmapToBitmapImage(m_emptyBitmap);

            Geometries = new ObservableCollection<GeometryItem>();
            dataGrid.ItemsSource = Geometries;

            ResetAt(new GeometryItem(-1, m_colors), Geometries.Count);
        }
示例#39
0
        protected override void Initialize()
        {
            base.Initialize();

            expressionGraph = new ExpressionGraph();

            applicationObject = (DTE2)GetService(typeof(DTE));

            debuggerEvents = applicationObject.Events.DebuggerEvents;
            debuggerEvents.OnEnterBreakMode += DebuggerEvents_OnEnterBreakMode;
            debuggerEvents.OnEnterDesignMode += DebuggerEvents_OnEnterDesignMode;

            // Add our command handlers for menu (commands must exist in the .vsct file)
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if ( null != mcs )
            {
                // Create the command for the tool window
                CommandID toolwndCommandID = new CommandID(GuidList.guidCommandTargetRGBCmdSet, (int)PkgCmdIDList.cmdidShowToolWindow);
                MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID);
                mcs.AddCommand(menuToolWin);
            }
        }
示例#40
0
        /// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
        /// <param term='application'>Root object of the host application.</param>
        /// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
        /// <param term='addInInst'>Object representing this Add-in.</param>
        /// <seealso class='IDTExtensibility2' />
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            _applicationObject = (DTE2)application;
            _addInInstance = (AddIn)addInInst;

            if (connectMode == ext_ConnectMode.ext_cm_AfterStartup ||
                connectMode == ext_ConnectMode.ext_cm_Startup ||
                connectMode == ext_ConnectMode.ext_cm_UISetup)
            {
                Events events = _applicationObject.Events;
                _solutionEvents = events.SolutionEvents;
                _solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(OnSolutionOpened);
                _solutionEvents.BeforeClosing += new _dispSolutionEvents_BeforeClosingEventHandler(OnSolutionClosing);
                _debuggerEvents = events.DebuggerEvents;

                SetupUI();
            }

            if (_applicationObject.Solution.IsOpen)
            {
                OnSolutionOpened();
            }
        }
示例#41
0
        public void AddSubscription()
        {
            // "{1496A755-94DE-11D0-8C3F-00C04FC2AAE2}, 1113" Guid-ID pair refer to
            // Project.AddReference command.
            // About how to get the Guid and ID of the specific command, please take a
            // look at this link on Dr.eX's blog:
            // http://blogs.msdn.com/dr._ex/archive/2007/04/17/using-enablevsiplogging-
            // to-identify-menus-and-commands-with-vs-2005-sp1.aspx
            try
            {

               _breakpointsEvents
                    = _applicationObject.Events.get_CommandEvents(
                        "{5EFC7975-14BC-11CF-9B2B-00AA00573819}",
                        769);
                _breakpointsEvents.BeforeExecute
                    += new _dispCommandEvents_BeforeExecuteEventHandler(breakpointsEvents_BeforeExecute);

                __findAllReferencesEvents
                    = _applicationObject.Events.get_CommandEvents(
                        "{5EFC7975-14BC-11CF-9B2B-00AA00573819}",
                        1915);
                __findAllReferencesEvents.BeforeExecute
                    += new _dispCommandEvents_BeforeExecuteEventHandler(findAllReferencesEvents_BeforeExecute);

                _gotoDefinitionEvents
                    = _applicationObject.Events.get_CommandEvents(
                        "{5EFC7975-14BC-11CF-9B2B-00AA00573819}",
                        935);
                _gotoDefinitionEvents.BeforeExecute
                    += new _dispCommandEvents_BeforeExecuteEventHandler(gotoDefinitionEvents_BeforeExecute);

                _stopEvents
                    = _applicationObject.Events.get_CommandEvents(
                        "{5EFC7975-14BC-11CF-9B2B-00AA00573819}",
                        179);
                _stopEvents.BeforeExecute
                    += new _dispCommandEvents_BeforeExecuteEventHandler(stopEvents_BeforeExecute);

                _startEvents
                    = _applicationObject.Events.get_CommandEvents(
                        "{5EFC7975-14BC-11CF-9B2B-00AA00573819}",
                        295);
                _startEvents.BeforeExecute
                    += new _dispCommandEvents_BeforeExecuteEventHandler(startEvents_BeforeExecute);

                _debuggerEvents = _applicationObject.Events.DebuggerEvents;
                _debuggerEvents.OnEnterBreakMode += new _dispDebuggerEvents_OnEnterBreakModeEventHandler(debuggerEvents_OnEnterBreakMode);
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
            }
        }
        /// <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()
        {
            base.Initialize();

            // Load up the options from file.
            string optionsFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "NiftySolution.xml");
            Options options = Options.Load(optionsFileName);

            // Create our main plugin facade.
            DTE2 application = GetGlobalService(typeof(DTE)) as DTE2;
            IVsProfferCommands3 profferCommands3 = base.GetService(typeof(SVsProfferCommands)) as IVsProfferCommands3;
            OleMenuCommandService oleMenuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            ImageList icons = new ImageList();
            icons.Images.AddStrip(Properties.Resources.Icons);
            m_plugin = new Plugin(application, profferCommands3, icons, oleMenuCommandService, "NiftySolution", "Aurora.NiftySolution.Connect", options);

            // Every plugin needs a command bar.
            CommandBar commandBar = m_plugin.AddCommandBar("NiftySolution", MsoBarPosition.msoBarTop);
            m_commandRegistry = new CommandRegistry(m_plugin, commandBar, new Guid(PackageGuidString), new Guid(PackageGuidGroup));

            // Initialize the logging system.
            if(Log.HandlerCount == 0)
            {
                #if DEBUG
                Log.AddHandler(new DebugLogHandler());
                #endif

                Log.AddHandler(new VisualStudioLogHandler(m_plugin));
                Log.Prefix = "NiftySolution";
            }

            // Now we can take care of registering ourselves and all our commands and hooks.
            Log.Debug("Booting up...");
            Log.IncIndent();

            bool doBindings = options.EnableBindings;

            m_commandRegistry.RegisterCommand(doBindings, new QuickOpen(m_plugin, "NiftyOpen"));
            m_commandRegistry.RegisterCommand(doBindings, new ToggleFile(m_plugin, "NiftyToggle"));
            m_commandRegistry.RegisterCommand(doBindings, new CloseToolWindow(m_plugin, "NiftyClose"));
            m_commandRegistry.RegisterCommand(doBindings, new Configure(m_plugin, "NiftyConfigure"));

            if (options.SilentDebuggerExceptions || options.IgnoreDebuggerExceptions)
            {
                m_debuggerEvents = application.Events.DebuggerEvents;
                m_debuggerEvents.OnExceptionNotHandled += new _dispDebuggerEvents_OnExceptionNotHandledEventHandler(OnExceptionNotHandled);
            }

            m_timings = new SolutionBuildTimings(m_plugin);

            Log.DecIndent();
            Log.Debug("Initialized...");
        }
        void VsShellPropertyEvents_AfterShellPropertyChanged(object sender, VsShellPropertyEventsHandler.ShellPropertyChangeEventArgs e)
        {
            SafeExecute(() =>
            {
                // when zombie state changes to false, finish package initialization
                //! DO NOT USE CODE WHICH MAY EXECUTE FOR LONG TIME HERE

                if ((int)__VSSPROPID.VSSPROPID_Zombie == e.PropId)
                {
                    if ((bool)e.Var == false)
                    {

                        var dte2 = ServiceProvider.GetDte2();

                        Events = dte2.Events as Events2;
                        DTEEvents = Events.DTEEvents;
                        SolutionEvents = Events.SolutionEvents;
                        DocumentEvents = Events.DocumentEvents;
                        WindowEvents = Events.WindowEvents;
                        DebuggerEvents = Events.DebuggerEvents;
                        CommandEvents = Events.CommandEvents;
                        SelectionEvents = Events.SelectionEvents;

                        DelayedInitialise();
                    }
                }
            });
        }
示例#44
0
        ///<summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
        ///<param name='application'>Root object of the host application.</param>
        ///<param name='connectMode'>Describes how the Add-in is being loaded.</param>
        ///<param name='addInInst'>Object representing this Add-in.</param>
        ///<param name='custom'>Array containing custom parameters</param>
        ///<remarks></remarks>
        void IDTExtensibility2.OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            string sAddInTypeName = string.Empty;
            try
            {
                _applicationObject = (DTE2)application;
                _addInInstance = (AddIn)addInInst;

                _applicationObject.StatusBar.Text = "Loading BIDSHelper (" + this.GetType().Assembly.GetName().Version.ToString() + ")...";

                _debuggerEvents = _applicationObject.Events.DebuggerEvents;
                _debuggerEvents.OnEnterBreakMode += new _dispDebuggerEvents_OnEnterBreakModeEventHandler(_debuggerEvents_OnEnterBreakMode);
                _debuggerEvents.OnEnterDesignMode += new _dispDebuggerEvents_OnEnterDesignModeEventHandler(_debuggerEvents_OnEnterDesignMode);
                _debuggerEvents.OnEnterRunMode += new _dispDebuggerEvents_OnEnterRunModeEventHandler(_debuggerEvents_OnEnterRunMode);

                foreach (Type t in System.Reflection.Assembly.GetExecutingAssembly().GetTypes())
                {
                    if (typeof(BIDSHelperPluginBase).IsAssignableFrom(t)
                        && (!object.ReferenceEquals(t, typeof(BIDSHelperPluginBase)))
                        && (!t.IsAbstract))
                    {
                        sAddInTypeName = t.Name;

                        BIDSHelperPluginBase ext;
                        System.Type[] @params = { typeof(Connect), typeof(DTE2), typeof(AddIn) };
                        System.Reflection.ConstructorInfo con;

                        con = t.GetConstructor(@params);
                        if (con == null)
                        {
                            System.Windows.Forms.MessageBox.Show("Problem loading type " + t.Name + ". No constructor found.");
                            continue;
                        }
                        ext = (BIDSHelperPluginBase)con.Invoke(new object[] { this, _applicationObject, _addInInstance });
                        addins.Add(ext.CommandName, ext);

                    }
                }

            }
            catch (Exception ex)
            {
                if (string.IsNullOrEmpty(sAddInTypeName))
                {
                    System.Windows.Forms.MessageBox.Show("Problem loading BIDS Helper: " + ex.Message + "\r\n" + ex.StackTrace);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Problem loading BIDS Helper. Problem type was " + sAddInTypeName + ": " + ex.Message + "\r\n" + ex.StackTrace);
                }
            }
            finally
            {
                _applicationObject.StatusBar.Clear();
            }
        }
示例#45
0
 /// <summary>
 /// Sets the instance of currently running Visual Studio IDE.
 /// </summary>
 /// <param name="dte">The DTE.</param>
 internal static void SetDTE(DTE dte)
 {
     DTE = dte;
     debuggerEvents = DTE.Events.DebuggerEvents;
     debuggerEvents.OnEnterBreakMode += DebuggerEvents_OnEnterBreakMode;
     debuggerEvents.OnEnterDesignMode += DebuggerEvents_OnEnterDesignMode;
     debuggerEvents.OnEnterRunMode += DebuggerEvents_OnEnterRunMode;
     debuggerProxy = (VSDebuggerProxy)AppDomain.CurrentDomain.GetData(VSDebuggerProxy.AppDomainDataName) ?? new VSDebuggerProxy();
     VSDebugger = new VSDebugger(debuggerProxy);
     Engine.Context.InitializeDebugger(VSDebugger);
 }
示例#46
0
        ///<summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
        ///<param name='application'>Root object of the host application.</param>
        ///<param name='connectMode'>Describes how the Add-in is being loaded.</param>
        ///<param name='addInInst'>Object representing this Add-in.</param>
        ///<param name='custom'>Array containing custom parameters</param>
        ///<remarks></remarks>
        void IDTExtensibility2.OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            string sAddInTypeName = string.Empty;
            try
            {
                _applicationObject = (DTE2)application;
                _addInInstance = (AddIn)addInInst;

                _applicationObject.StatusBar.Text = "Loading BIDSHelper (" + this.GetType().Assembly.GetName().Version.ToString() + ")...";

                _debuggerEvents = _applicationObject.Events.DebuggerEvents;
                _debuggerEvents.OnEnterBreakMode += new _dispDebuggerEvents_OnEnterBreakModeEventHandler(_debuggerEvents_OnEnterBreakMode);
                _debuggerEvents.OnEnterDesignMode += new _dispDebuggerEvents_OnEnterDesignModeEventHandler(_debuggerEvents_OnEnterDesignMode);
                _debuggerEvents.OnEnterRunMode += new _dispDebuggerEvents_OnEnterRunModeEventHandler(_debuggerEvents_OnEnterRunMode);

                foreach (Type t in System.Reflection.Assembly.GetExecutingAssembly().GetTypes())
                {
                    if (typeof(BIDSHelperPluginBase).IsAssignableFrom(t)
                        && (!object.ReferenceEquals(t, typeof(BIDSHelperPluginBase)))
                        && (!t.IsAbstract))
                    {
                        sAddInTypeName = t.Name;

                        BIDSHelperPluginBase ext;
                        System.Type[] @params = { typeof(Connect), typeof(DTE2), typeof(AddIn) };
                        System.Reflection.ConstructorInfo con;

                        con = t.GetConstructor(@params);
                        if (con == null)
                        {
                            System.Windows.Forms.MessageBox.Show("Problem loading type " + t.Name + ". No constructor found.");
                            continue;
                        }
                        ext = (BIDSHelperPluginBase)con.Invoke(new object[] { this, _applicationObject, _addInInstance });
                        addins.Add(ext.CommandName, ext);

                    }
                }

#if DENALI
                //handle assembly reference problems when the compiled reference doesn't exist in that version of Visual Studio
                //doesn't appear to be needed for VS2013
                AppDomain currentDomain = AppDomain.CurrentDomain;
                currentDomain.AssemblyResolve += new ResolveEventHandler(currentDomain_AssemblyResolve);
#endif
            
            }
            catch (Exception ex)
            {
                //don't show a popup anymore since this exception is viewable in the Version dialog in the Tools menu
                if (string.IsNullOrEmpty(sAddInTypeName))
                {
                    AddInLoadException = ex;
                    //System.Windows.Forms.MessageBox.Show("Problem loading BIDS Helper: " + ex.Message + "\r\n" + ex.StackTrace);
                }
                else
                {
                    AddInLoadException = new Exception("Problem loading BIDS Helper. Problem type was " + sAddInTypeName + ": " + ex.Message + "\r\n" + ex.StackTrace, ex);
                    //System.Windows.Forms.MessageBox.Show("Problem loading BIDS Helper. Problem type was " + sAddInTypeName + ": " + ex.Message + "\r\n" + ex.StackTrace);
                }
            }
            finally
            {
                _applicationObject.StatusBar.Clear();
            }
        }
        /// <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
            {
                Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this));

                base.Initialize();

                // InitializePackageServices
                _dte = (DTE2)GetGlobalService(typeof(DTE));

                _log = GetService(typeof(SVsActivityLog)) as IVsActivityLog;

                // Initialize Tools->Options Page
                _options = (OptionsPageGeneral)GetDialogPage(typeof(OptionsPageGeneral));

                // Initialize Solution Service Events
                _solutionService = (IVsSolution2)GetGlobalService(typeof(SVsSolution));
                if (_solutionService != null)
                {
                    _solutionService.AdviseSolutionEvents(this, out _solutionEventsCookie);
                }
				
                _debuggerEvents = (EnvDTE.DebuggerEvents)_dte.Events.DebuggerEvents;
                _debuggerEvents.OnEnterRunMode += new _dispDebuggerEvents_OnEnterRunModeEventHandler(OnEnterRunMode); ;
                _debuggerEvents.OnEnterDesignMode += new _dispDebuggerEvents_OnEnterDesignModeEventHandler(OnEnterDesignMode); ;

                //InitializeOutputWindowPane
                if (_dte != null
                    && _dte.ToolWindows.OutputWindow.OutputWindowPanes.Cast<OutputWindowPane>().All(p => p.Name != _options.OutputPane))
                {
                    _dte.ToolWindows.OutputWindow.OutputWindowPanes.Add(_options.OutputPane);
                }

                InitializeMenus();
                InitializeAutoShelve();
            }
            catch (Exception ex)
            {
                WriteException(ex);
            }
        }
示例#48
0
        /// <summary>
        /// Enables the Trace manager to register for Debugger break events;
        /// </summary>
        /// <param name="unsubscribeOnDebugSessionEnd"></param>
        void SubscribeForDebuggerEvents()
        {
            if (subscribedForDebuggerBreak)
            {
                StatusReporter.Report(Resources.MsgAlreadySubscribedForDbgBreak, Status.INFO);
                return;
            }

            if (!dteInitialized)
                InitializeDTE();

            //Cache the debuggerEvents object so that it is not disposed by the shell.
            debuggerEvents = dte.Events.DebuggerEvents;
            if (debuggerEvents == null)
                throw new NullReferenceException(Resources.MsgDebuggerEventsObjNull);

            debuggerEvents.OnEnterBreakMode += new EnvDTE._dispDebuggerEvents_OnEnterBreakModeEventHandler(DebuggerEvents_OnEnterBreakMode);
            debuggerEvents.OnEnterDesignMode += new _dispDebuggerEvents_OnEnterDesignModeEventHandler(debuggerEvents_OnEnterDesignMode);
            StatusReporter.Report(Resources.MsgDbgBreakEventSubscribeSuccess, Status.INFO);
            subscribedForDebuggerBreak = true;
        }