Пример #1
0
 public static void Init(DTE2 app, EnvDTE.AddIn addin)
 {
     VSApp = app;
     Addin = addin;
     CreateWindow();
     WireupEvents();
 }
Пример #2
0
        public DTE_Command AddCommand(
            EnvDTE.AddIn InInstance, DTE_Addin InAddin, DTE_Command.ConstructProperties InProps)
        {
            object[] contextGuids = InProps.ContextGuids;

            //Add a command to the Commands collection:
            EnvDTE.Command command =
                mCmds.AddNamedCommand(
                    InAddin.addin, InProps.Name, InProps.ButtonText, InProps.TooltipText,
                    InProps.IsMsoButton, InProps.BitmapIx,
                    ref contextGuids,
                    InProps.Useable);

            InProps.ContextGuids = contextGuids;

            DTE_Command cmd = new DTE_Command(mMain, command);

            return(cmd);
        }
Пример #3
0
 public EnvDTE.Window CreateToolWindow(EnvDTE.AddIn AddInInst, string ProgID, string Caption, string GuidPosition, ref object DocObj)
 {
     throw new System.NotImplementedException();
 }
Пример #4
0
 /// <summary>
 /// Called when the AddIn is discarded. This method allows each of the commands to
 /// to unregister and close down on exiting.
 /// </summary>
 /// <param name="application"> Root object in the application </param>
 /// <param name="connectMode"> 'Mode' in which the environment is closing the addin </param>
 /// <param name="addIn"> Object representing this AddIn in the Object Model</param>
 public void OnDisconnection(EnvDTE._DTE application, Extensibility.ext_DisconnectMode disconnectMode, EnvDTE.AddIn addIn)
 {
     application.Commands.Item("StudentClient.Connect." + m_strCommandName, 0).Delete();
 }
Пример #5
0
        /// <summary>
        /// Registers a command and places it on the Tools menu.
        /// </summary>
        public void OnConnection(EnvDTE._DTE application, Extensibility.ext_ConnectMode connectMode, EnvDTE.AddIn addIn)
        {
            m_applicationObject = (EnvDTE._DTE)application;
            m_addInInstance     = (EnvDTE.AddIn)addIn;

            m_strCommandName = "AMStudentGotoHomePage";
            m_strName        = AMResources.GetLocalizedString("AMStudentGotoHomePageName");
            m_strItemText    = AMResources.GetLocalizedString("AMStudentGotoHomePageItemText");
            m_strHomePageUrl = "vs:/default.htm?tab=" + AMResources.GetLocalizedString("AMStudentGotoHomePagePageName");

            string strDescription = AMResources.GetLocalizedString("GotoHomePageDescription");

            EnvDTE.Commands commands = null;
            EnvDTE.Command  command  = null;
            Microsoft.Office.Core._CommandBars      officeCommandBars    = null;
            Microsoft.Office.Core.CommandBar        officeCommandBar     = null;
            Microsoft.Office.Core.CommandBarControl officeCommandControl = null;
            Microsoft.Office.Core.CommandBar        officeAcademic       = null;
            object [] contextGuids;
            contextGuids = new object[] { };

            commands = m_applicationObject.Commands;
            try
            {
                command = commands.AddNamedCommand(m_addInInstance, m_strCommandName, m_strName, strDescription,
                                                   false, 108, ref contextGuids, (int)(EnvDTE.vsCommandStatus.vsCommandStatusEnabled | EnvDTE.vsCommandStatus.vsCommandStatusSupported));

                // Add the new command to the tools menu
                officeCommandBars = m_applicationObject.CommandBars;
                string amStudentMenuItem = AMResources.GetLocalizedString("AMStudentMenuItem");
                try
                {
                    officeAcademic = (CommandBar)officeCommandBars[amStudentMenuItem];
                }
                catch
                {
                }
                if (officeAcademic == null)
                {
                    officeCommandBar = (CommandBar)officeCommandBars["Tools"];
                    officeAcademic   = (CommandBar)m_applicationObject.Commands.AddCommandBar(amStudentMenuItem, EnvDTE.vsCommandBarType.vsCommandBarTypeMenu, officeCommandBar, 1);
                }
                officeCommandControl         = command.AddControl((object)officeAcademic, 1);
                officeCommandControl.Caption = m_strItemText;
            }
            catch (System.Exception /*e*/)
            {
                // Falling into this simply means that the command was already registered.
            }
        }
Пример #6
0
        /// <summary>
        /// Registers a command and places it onto the context menu for the editor
        /// window.
        /// </summary>
        public void OnConnection(EnvDTE._DTE application, Extensibility.ext_ConnectMode connectMode, EnvDTE.AddIn addIn)
        {
            m_applicationObject = (EnvDTE._DTE)application;
            m_addInInstance     = (EnvDTE.AddIn)addIn;

            m_strCommandName = "MarkCodeForExtraction";
            m_strName        = AMResources.GetLocalizedString("CodeMarkerName");
            m_strItemText    = AMResources.GetLocalizedString("CodeMarkerItemText");

            string description = AMResources.GetLocalizedString("CodeMarkerDescription");

            EnvDTE.Commands commands = null;
            EnvDTE.Command  command  = null;
            Microsoft.Office.Core._CommandBars      officeCommandBars    = null;
            Microsoft.Office.Core.CommandBar        officeCommandBar     = null;
            Microsoft.Office.Core.CommandBarControl officeCommandControl = null;
            Microsoft.Office.Core.CommandBar        officeAcademic       = null;
            object [] contextGuids;
            contextGuids = new object[] { };

            commands = m_applicationObject.Commands;
            try
            {
                command = commands.AddNamedCommand(m_addInInstance, m_strCommandName, m_strName, description,
                                                   true, 12, ref contextGuids, (int)(EnvDTE.vsCommandStatus.vsCommandStatusEnabled | EnvDTE.vsCommandStatus.vsCommandStatusSupported));

                // Add the new command to the top-level context menu for the editor
                // code window, if possible.
                officeCommandBars            = m_applicationObject.CommandBars;
                officeCommandBar             = (CommandBar)officeCommandBars["Code Window"];
                officeCommandControl         = command.AddControl((object)officeCommandBar, 1);
                officeCommandControl.Caption = m_strItemText;

                string amFacultyMenuItem = AMResources.GetLocalizedString("AMFacultyMenuItem");
                // Also attempt to add it to the Tools menu as well, for accessibility.
                try
                {
                    officeAcademic = (CommandBar)officeCommandBars[amFacultyMenuItem];
                }
                catch
                {
                }
                if (officeAcademic == null)
                {
                    officeCommandBar = (CommandBar)officeCommandBars["Tools"];
                    officeAcademic   = (CommandBar)m_applicationObject.Commands.AddCommandBar(amFacultyMenuItem, EnvDTE.vsCommandBarType.vsCommandBarTypeMenu, officeCommandBar, 1);
                }

                officeCommandControl         = command.AddControl((object)officeAcademic, 1);
                officeCommandControl.Caption = AMResources.GetLocalizedString("CodeMarkerToolsMenuItemText");
            }
            catch (System.Exception /*e*/)
            {
                // Falling into this simply means that the command was already registered.
            }
        }