示例#1
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_UISetup)
            {
                object [] contextGUIDS  = new object[] { };
                Commands2 commands      = (Commands2)applicationObject.Commands;
                string    toolsMenuName = "Tools";

                //Place the command on the tools menu.
                //Find the MenuBar command bar, which is the top-level command bar holding all the main menu items:
                Microsoft.VisualStudio.CommandBars.CommandBar menuBarCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)applicationObject.CommandBars)["MenuBar"];

                //Find the Tools command bar on the MenuBar command bar:
                CommandBarControl toolsControl = menuBarCommandBar.Controls[toolsMenuName];
                CommandBarPopup   toolsPopup   = (CommandBarPopup)toolsControl;

                //This try/catch block can be duplicated if you wish to add multiple commands to be handled by your Add-in,
                //  just make sure you also update the QueryStatus/Exec method to include the new command names.
                try
                {
                    //Add a command to the Commands collection:
                    Command command = commands.AddNamedCommand2(_addInInstance, "XnaLevelEditor", "XnaLevelEditor", "Executes the command for XnaLevelEditor", true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStylePictAndText, vsCommandControlType.vsCommandControlTypeButton);

                    //Add a control for the command to the tools menu:
                    if ((command != null) && (toolsPopup != null))
                    {
                        command.AddControl(toolsPopup.CommandBar, 1);
                    }
                }
                catch (System.ArgumentException)
                {
                    //If we are here, then the exception is probably because a command with that name
                    //  already exists. If so there is no need to recreate the command and we can
                    //  safely ignore the exception.
                }
            }
            else if (connectMode == ext_ConnectMode.ext_cm_AfterStartup)
            {
                windows2        = (Windows2)applicationObject.Windows;
                userControlType = typeof(MainUserControl);
                asm             = Assembly.GetAssembly(userControlType);

                mainUserControls = new Dictionary <Window, MainUserControl>();

                Events2 events = (Events2)applicationObject.Events;
                windowVisibilityEvents = events.get_WindowVisibilityEvents();
                windowVisibilityEvents.WindowShowing += new _dispWindowVisibilityEvents_WindowShowingEventHandler(windowVisibilityEvents_WindowShowing);
                windowVisibilityEvents.WindowHiding  += new _dispWindowVisibilityEvents_WindowHidingEventHandler(windowVisibilityEvents_WindowHiding);
            }
        }
示例#2
0
		public QueryResult()
		{
			strstoreTreeValue = string.Empty;
			strstoreValue = string.Empty;
			try
			{
				SetStyle(ControlStyles.CacheText | ControlStyles.OptimizedDoubleBuffer, true);

				InitializeComponent();
				Events events = ApplicationObject.Events;
				_windowsEvents = events.get_WindowEvents(null);
				_windowsEvents.WindowActivated += _windowsEvents_WindowActivated;
				


				Events2 eventsSource = (Events2)ApplicationObject.Events;
				_events = eventsSource.get_WindowVisibilityEvents(Helper.QueryResultToolWindow);
				_events.WindowHiding += WindowHiding;
				InitializeResultDataGridView();
				InitializeTabControl();
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
			}
		}
示例#3
0
文件: Connect.cs 项目: erdincay/db4o
		//FIXME: Add the window to OM window list. See ViewBase.CreateToolWindow() for details.
		private void OpenHelp()
		{
			string filepath = Assembly.GetExecutingAssembly().CodeBase.Remove(0, 8);
			filepath = Path.Combine(Path.GetDirectoryName(filepath), FAQ_PATH);

			if (winHelp == null || winHelp.Visible == false)
			{
				winHelp = _applicationObject.DTE.ItemOperations.Navigate(filepath, vsNavigateOptions.vsNavigateOptionsNewWindow);

				helpWindowEvents = ((Events2) _applicationObject.Events).get_WindowVisibilityEvents(null);
				helpWindowEvents.WindowHiding += helpWindowEvents_WindowHiding;
			}
			else
				winHelp.Visible = true;
		}