Пример #1
0
        public DebugManager(ExcelDnaToolsPackage package, ExcelConnection connection)
        {
            _package    = package;
            _connection = connection;
            var packageServiceProvider = (IServiceProvider)package;

            _debugger = packageServiceProvider.GetService(typeof(SVsShellDebugger)) as IVsDebugger;
            // var dgr = Package.GetGlobalService(typeof(SVsShellDebugger)) ;
            // _debugger = dgr as IVsDebugger;
            _dte = packageServiceProvider.GetService(typeof(SDTE)) as DTE;
            if (_dte != null)
            {
                _dteDebugger = _dte.Debugger as Debugger2;
            }

            if (_package == null || _debugger == null || _dte == null || _dteDebugger == null)
            {
                Debug.Fail("DebugManager setup failed");
                return;
            }

            if (_debugger.AdviseDebuggerEvents(this, out _debuggerEventsCookie) != VSConstants.S_OK)
            {
                Debug.Fail("DebugManager setup failed");
            }

            if (_debugger.AdviseDebugEventCallback(this) != VSConstants.S_OK)
            {
                Debug.Fail("DebugManager setup failed");
            }
        }
Пример #2
0
        public DebugManager(ExcelDnaToolsPackage package, ExcelConnection connection)
        {
            _package = package;
            _connection = connection;
            var packageServiceProvider = (IServiceProvider)package;
             _debugger = packageServiceProvider.GetService(typeof(SVsShellDebugger)) as IVsDebugger;
            // var dgr = Package.GetGlobalService(typeof(SVsShellDebugger)) ;
            // _debugger = dgr as IVsDebugger;
            _dte = packageServiceProvider.GetService(typeof(SDTE)) as DTE;
            if (_dte != null)
            {
                _dteDebugger = _dte.Debugger as Debugger2;
            }

            if (_package == null || _debugger == null || _dte == null || _dteDebugger == null)
            {
                Debug.Fail("DebugManager setup failed");
                return;
            }

            if (_debugger.AdviseDebuggerEvents(this, out _debuggerEventsCookie) != VSConstants.S_OK)
            {
                Debug.Fail("DebugManager setup failed");
            }

            if (_debugger.AdviseDebugEventCallback(this) != VSConstants.S_OK)
            {
                Debug.Fail("DebugManager setup failed");
            }
        }
        /////////////////////////////////////////////////////////////////////////////
        // Overridden Package Implementation
        #region Package Members

        /// <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()
        {
            IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
            Guid       clsid   = Guid.Empty;
            int        result;

            uiShell.ShowMessageBox(0,
                                   ref clsid,
                                   "ExcelDnaTools",
                                   "Hello There!!!",
                                   string.Empty,
                                   0,
                                   OLEMSGBUTTON.OLEMSGBUTTON_OK,
                                   OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
                                   OLEMSGICON.OLEMSGICON_INFO,
                                   0, // false
                                   out result);
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            // Initialize our internal helpers
            _connection     = new ExcelConnection(); // Not connected at this point
            _debugManager   = new DebugManager(this, _connection);
            _solutionHelper = new SolutionHelper(this);

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

            if (mcs == null)
            {
                Debug.Fail("MenuCommandService not found!?");
                return;
            }

            // Create the command for the menu item.
            CommandID   menuCommandID = new CommandID(GuidList.guidExcelDnaToolsCmdSet, (int)PkgCmdIDList.cmdidExcelDna);
            MenuCommand menuItem      = new MenuCommand(MenuItemCallback, menuCommandID);

            mcs.AddCommand(menuItem);

            // Create the command for the tool window
            CommandID   toolwndCommandID = new CommandID(GuidList.guidExcelDnaToolsCmdSet, (int)PkgCmdIDList.cmdidExcelDnaExplorer);
            MenuCommand menuToolWin      = new MenuCommand(ShowToolWindow, toolwndCommandID);

            mcs.AddCommand(menuToolWin);

            CommandID      attachExcelCommandID = new CommandID(GuidList.guidExcelDnaToolsCmdSet, (int)PkgCmdIDList.cmdidExcelDnaAttachExcel);
            OleMenuCommand menuAttachExcel      = new OleMenuCommand(AttachExcelCallback, attachExcelCommandID);

            menuAttachExcel.ParametersDescription = "$"; // Documented http://www.getcodesamples.com/src/7D389846/8A0A4E48
            mcs.AddCommand(menuAttachExcel);

            CommandID      attachDebuggerCommandID = new CommandID(GuidList.guidExcelDnaToolsCmdSet, (int)PkgCmdIDList.cmdidExcelDnaAttachDebugger);
            OleMenuCommand menuAttachDebugger      = new OleMenuCommand(AttachDebuggerCallback, attachDebuggerCommandID);

            mcs.AddCommand(menuAttachDebugger);
        }
Пример #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()
        {
            IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
            Guid clsid = Guid.Empty;
            int result;
            uiShell.ShowMessageBox(0,
                       ref clsid,
                       "ExcelDnaTools",
                       "Hello There!!!",
                       string.Empty,
                       0,
                       OLEMSGBUTTON.OLEMSGBUTTON_OK,
                       OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
                       OLEMSGICON.OLEMSGICON_INFO,
                       0,        // false
                       out result);
            Debug.WriteLine (string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            // Initialize our internal helpers
            _connection = new ExcelConnection(); // Not connected at this point
            _debugManager = new DebugManager(this, _connection);
            _solutionHelper = new SolutionHelper(this);

            // Add our command handlers for menu (commands must exist in the .vsct file)
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (mcs == null)
            {
                Debug.Fail("MenuCommandService not found!?");
                return;
            }

            // Create the command for the menu item.
            CommandID menuCommandID = new CommandID(GuidList.guidExcelDnaToolsCmdSet, (int)PkgCmdIDList.cmdidExcelDna);
            MenuCommand menuItem = new MenuCommand(MenuItemCallback, menuCommandID );
            mcs.AddCommand( menuItem );

            // Create the command for the tool window
            CommandID toolwndCommandID = new CommandID(GuidList.guidExcelDnaToolsCmdSet, (int)PkgCmdIDList.cmdidExcelDnaExplorer);
            MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID);
            mcs.AddCommand( menuToolWin );

            CommandID attachExcelCommandID = new CommandID(GuidList.guidExcelDnaToolsCmdSet, (int)PkgCmdIDList.cmdidExcelDnaAttachExcel);
            OleMenuCommand menuAttachExcel = new OleMenuCommand(AttachExcelCallback, attachExcelCommandID);
            menuAttachExcel.ParametersDescription = "$"; // Documented http://www.getcodesamples.com/src/7D389846/8A0A4E48
            mcs.AddCommand(menuAttachExcel);

            CommandID attachDebuggerCommandID = new CommandID(GuidList.guidExcelDnaToolsCmdSet, (int)PkgCmdIDList.cmdidExcelDnaAttachDebugger);
            OleMenuCommand menuAttachDebugger = new OleMenuCommand(AttachDebuggerCallback, attachDebuggerCommandID);
            mcs.AddCommand(menuAttachDebugger);
        }