コード例 #1
0
ファイル: Container.cs プロジェクト: jrowies/dsmaddin
        public DebuggerHook GetDebugHook(DTE2 dteApplicationObject)
        {
            if (_debugHook == null)
            _debugHook = new DebuggerHook(dteApplicationObject, GetAddinController(dteApplicationObject), GetIViewAdapter(dteApplicationObject), GetIDsmSettingsManager());

              return _debugHook;
        }
コード例 #2
0
        public DebuggerHook GetDebugHook(DTE2 dteApplicationObject)
        {
            if (_debugHook == null)
            {
                _debugHook = new DebuggerHook(dteApplicationObject, GetAddinController(dteApplicationObject), GetIViewAdapter(dteApplicationObject), GetIDsmSettingsManager());
            }

            return(_debugHook);
        }
コード例 #3
0
ファイル: Connect.cs プロジェクト: jrowies/dsmaddin
        /// <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)
        {
            try
            {
                _applicationObject = (DTE2)application;

                _addInInstance = (AddIn)addInInst;

                var container = new Container();

                _exceptionManager = container.GetIExceptionManager();

                _controller = container.GetAddinController(_applicationObject);

                _debugHook = container.GetDebugHook(_applicationObject);
                _debugHook.Hook();

                _settingsManager = container.GetIDsmSettingsManager();

                if ((connectMode == ext_ConnectMode.ext_cm_Startup) || (connectMode == ext_ConnectMode.ext_cm_AfterStartup))
                {
                    //_settings = Settings.Default;
                    //_settings.Reload();

                    CommandBars commandBars = (CommandBars)_applicationObject.CommandBars;

                    // Create a toolbar for this app
                    string managerToolbarName = "Document Session Manager";
                    managerToolbar = null;
                    //try
                    //{
                    //  managerToolbar = ((Microsoft.VisualStudio.CommandBars.CommandBars)this._applicationObject.CommandBars)[managerToolbarName];
                    //}
                    //catch (ArgumentException)
                    //{
                    //}

                    if (managerToolbar == null)
                    {
                        managerToolbar = (CommandBar)commandBars.Add(managerToolbarName, MsoBarPosition.msoBarTop, System.Type.Missing, true);

                        _settingsManager.LoadSettings();
                        managerToolbar.Position = (MsoBarPosition)Enum.Parse(typeof(MsoBarPosition),
                                                                             _settingsManager.DsmSettings.ToolBarPosition ?? MsoBarPosition.msoBarTop.ToString());
                        managerToolbar.RowIndex = _settingsManager.DsmSettings.ToolBarRowIndex;
                        managerToolbar.Visible  = _settingsManager.DsmSettings.ToolBarVisible;

                        if (_settingsManager.DsmSettings.ToolBarTop != -1)
                        {
                            managerToolbar.Top = _settingsManager.DsmSettings.ToolBarTop;
                        }
                        if (_settingsManager.DsmSettings.ToolBarLeft != -1)
                        {
                            managerToolbar.Left = _settingsManager.DsmSettings.ToolBarLeft;
                        }
                        //if (_settingsManager.DsmSettings.ToolBarWidth != -1)
                        //  managerToolbar.Width = _settingsManager.DsmSettings.ToolBarWidth;
                        //if (_settingsManager.DsmSettings.ToolBarHeight != -1)
                        //  managerToolbar.Height = _settingsManager.DsmSettings.ToolBarHeight;
                    }

                    object controlCreated;

                    _controlsCreated.Clear();

                    //PictureManager.CommandButtons.Clear();

                    AddCommand(managerToolbar, "DsmSessionList", "DsmSessionList",
                               "Sessions", vsCommandControlType.vsCommandControlTypeDropDownCombo, 1,
                               vsCommandStyle.vsCommandStyleComboCaseSensitive, 0, out controlCreated);

                    CommandBarComboBox combo = controlCreated as CommandBarComboBox;
                    if (combo != null)
                    {
                        combo.Width = 200;
                    }

                    AddCommand(managerToolbar, "DsmLoadSession", "DsmLoadSession",
                               "Load session", vsCommandControlType.vsCommandControlTypeButton, 1,
                               vsCommandStyle.vsCommandStylePict, 2, out controlCreated);

                    AddCommand(managerToolbar, "DsmSaveSessionAs", "DsmSaveSessionAs",
                               "Save session as", vsCommandControlType.vsCommandControlTypeButton, 2,
                               vsCommandStyle.vsCommandStylePict, 6, out controlCreated);

                    AddCommand(managerToolbar, "DsmSaveSession", "DsmSaveSession",
                               "Save session", vsCommandControlType.vsCommandControlTypeButton, 3,
                               vsCommandStyle.vsCommandStylePict, 5, out controlCreated);

                    AddCommand(managerToolbar, "DsmDeleteSessions", "DsmDeleteSessions",
                               "Delete sessions", vsCommandControlType.vsCommandControlTypeButton, 4,
                               vsCommandStyle.vsCommandStylePict, 1, out controlCreated);

                    AddCommand(managerToolbar, "DsmReloadSession", "DsmReloadSession",
                               "Reload session", vsCommandControlType.vsCommandControlTypeButton, 5,
                               vsCommandStyle.vsCommandStylePict, 4, out controlCreated);

                    AddCommand(managerToolbar, "DsmRecentlyClosed", "DsmRecentlyClosed",
                               "Recently closed documents", vsCommandControlType.vsCommandControlTypeButton, 6,
                               vsCommandStyle.vsCommandStylePict, 3, out controlCreated);
                }
            }
            catch (Exception ex)
            {
                _exceptionManager.HandleException(ex);
            }
        }
コード例 #4
0
ファイル: Connect.cs プロジェクト: jrowies/dsmaddin
        /// <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)
        {
            try
              {
            _applicationObject = (DTE2)application;

            _addInInstance = (AddIn)addInInst;

            var container = new Container();

            _exceptionManager = container.GetIExceptionManager();

            _controller = container.GetAddinController(_applicationObject);

            _debugHook = container.GetDebugHook(_applicationObject);
            _debugHook.Hook();

            _settingsManager = container.GetIDsmSettingsManager();

            if ((connectMode == ext_ConnectMode.ext_cm_Startup) || (connectMode == ext_ConnectMode.ext_cm_AfterStartup))
            {
              //_settings = Settings.Default;
              //_settings.Reload();

              CommandBars commandBars = (CommandBars)_applicationObject.CommandBars;

              // Create a toolbar for this app
              string managerToolbarName = "Document Session Manager";
              managerToolbar = null;
              //try
              //{
              //  managerToolbar = ((Microsoft.VisualStudio.CommandBars.CommandBars)this._applicationObject.CommandBars)[managerToolbarName];
              //}
              //catch (ArgumentException)
              //{
              //}

              if (managerToolbar == null)
              {
            managerToolbar = (CommandBar)commandBars.Add(managerToolbarName, MsoBarPosition.msoBarTop, System.Type.Missing, true);

            _settingsManager.LoadSettings();
            managerToolbar.Position = (MsoBarPosition)Enum.Parse(typeof(MsoBarPosition),
              _settingsManager.DsmSettings.ToolBarPosition ?? MsoBarPosition.msoBarTop.ToString());
            managerToolbar.RowIndex = _settingsManager.DsmSettings.ToolBarRowIndex;
            managerToolbar.Visible = _settingsManager.DsmSettings.ToolBarVisible;

            if (_settingsManager.DsmSettings.ToolBarTop != -1)
              managerToolbar.Top = _settingsManager.DsmSettings.ToolBarTop;
            if (_settingsManager.DsmSettings.ToolBarLeft != -1)
              managerToolbar.Left = _settingsManager.DsmSettings.ToolBarLeft;
            //if (_settingsManager.DsmSettings.ToolBarWidth != -1)
            //  managerToolbar.Width = _settingsManager.DsmSettings.ToolBarWidth;
            //if (_settingsManager.DsmSettings.ToolBarHeight != -1)
            //  managerToolbar.Height = _settingsManager.DsmSettings.ToolBarHeight;

              }

              object controlCreated;

              _controlsCreated.Clear();

              //PictureManager.CommandButtons.Clear();

              AddCommand(managerToolbar, "DsmSessionList", "DsmSessionList",
            "Sessions", vsCommandControlType.vsCommandControlTypeDropDownCombo, 1,
            vsCommandStyle.vsCommandStyleComboCaseSensitive, 0, out controlCreated);

              CommandBarComboBox combo = controlCreated as CommandBarComboBox;
              if (combo != null)
            combo.Width = 200;

              AddCommand(managerToolbar, "DsmLoadSession", "DsmLoadSession",
            "Load session", vsCommandControlType.vsCommandControlTypeButton, 1,
            vsCommandStyle.vsCommandStylePict, 2, out controlCreated);

              AddCommand(managerToolbar, "DsmSaveSessionAs", "DsmSaveSessionAs",
            "Save session as", vsCommandControlType.vsCommandControlTypeButton, 2,
            vsCommandStyle.vsCommandStylePict, 6, out controlCreated);

              AddCommand(managerToolbar, "DsmSaveSession", "DsmSaveSession",
            "Save session", vsCommandControlType.vsCommandControlTypeButton, 3,
            vsCommandStyle.vsCommandStylePict, 5, out controlCreated);

              AddCommand(managerToolbar, "DsmDeleteSessions", "DsmDeleteSessions",
            "Delete sessions", vsCommandControlType.vsCommandControlTypeButton, 4,
            vsCommandStyle.vsCommandStylePict, 1, out controlCreated);

              AddCommand(managerToolbar, "DsmReloadSession", "DsmReloadSession",
            "Reload session", vsCommandControlType.vsCommandControlTypeButton, 5,
            vsCommandStyle.vsCommandStylePict, 4, out controlCreated);

              AddCommand(managerToolbar, "DsmRecentlyClosed", "DsmRecentlyClosed",
            "Recently closed documents", vsCommandControlType.vsCommandControlTypeButton, 6,
            vsCommandStyle.vsCommandStylePict, 3, out controlCreated);

            }
              }
              catch (Exception ex)
              {
            _exceptionManager.HandleException(ex);
              }
        }