Example #1
0
		public static void CreateLoginToolWindow(CommandBarControl cmdBarCtrl,
			CommandBarButton cmdBarBtn, Assembly addIn_Assembly,
			CommandBarControl cmdBarCtrlBackup, CommandBarControl dbCreateDemoDbControl)
		{
			try
			{
				m_AddIn_Assembly = addIn_Assembly;
				m_cmdBarCtrlConnect = cmdBarCtrl;
				m_cmdBarBtnConnect = cmdBarBtn;
				m_cmdBarCtrlBackup = cmdBarCtrlBackup;
				m_cmdBarCtrlCreateDemoDb = dbCreateDemoDbControl;

                loginToolWindow = CreateToolWindow(Common.Constants.CLASS_NAME_LOGIN, Common.Constants.LOGIN, NewFormattedGuid());

                if (loginToolWindow.AutoHides)
				{
                    loginToolWindow.AutoHides = false;
				}
                loginToolWindow.Visible = true;
                loginToolWindow.Width = 460;
                loginToolWindow.Height = 210;
				Helper.CheckIfLoginWindowIsVisible = true;
				
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
			}
		}
Example #2
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);
            }
        }
Example #3
0
            protected override void OnClick(EventArgs e)
            {
                base.OnClick(e);

                CommandBarControl control = this.item as CommandBarControl;

                if (control != null)
                {
                    control.PerformClick(EventArgs.Empty);
                }
            }
        private bool PerformClick(CommandBarItem item)
        {
            Application.DoEvents();

            CommandBarControl control = item as CommandBarControl;

            if (control != null)
            {
                control.PerformClick(EventArgs.Empty);
                return(true);
            }

            return(false);
        }
Example #5
0
        protected override bool ProcessCmdKey(ref Message message, Keys keyData)
        {
            CommandBarItem[] shortcutHits = this.items[keyData];
            if (shortcutHits.Length != 0)
            {
                CommandBarControl control = shortcutHits[0] as CommandBarControl;
                if (control != null)
                {
                    control.PerformClick(EventArgs.Empty);
                    return(true);
                }
            }

            return(base.ProcessCmdKey(ref message, keyData));
        }
Example #6
0
        /// <summary>实现 IDTExtensibility2 接口的 OnConnection 方法。接收正在加载外接程序的通知。</summary>
        /// <param term='application'>宿主应用程序的根对象。</param>
        /// <param term='connectMode'>描述外接程序的加载方式。</param>
        /// <param term='addInInst'>表示此外接程序的对象。</param>
        /// <seealso class='IDTExtensibility2' />
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            _applicationObject = (DTE2)application;
            _addInInstance = (AddIn)addInInst;

            CommandBars cmdBars = (CommandBars)(_applicationObject.DTE.CommandBars);
            CommandBar vsBarProject = cmdBars["Project"];

            int idxMenuAddRef = 1;
            int iMenuCount = vsBarProject.Controls.Count;
            for (int i = 1; i <= vsBarProject.Controls.Count; i++)
            {
                if (vsBarProject.Controls[i].Caption.StartsWith("卸载项目")) cmdUnload = vsBarProject.Controls[i];
                if (vsBarProject.Controls[i].Caption.StartsWith("重新加载项目")) cmdReload = vsBarProject.Controls[i];
                if (vsBarProject.Controls[i].Caption.StartsWith("添加 Web 引用")) idxMenuAddRef = i;// cmdReload = vsBarProject.Controls[i];
            }

            #region 建立菜单
            // O/R Mapping
            CommandBarPopup menuCode = vsBarProject.Controls.Add(MsoControlType.msoControlPopup, Missing.Value, Missing.Value, iMenuCount, true) as CommandBarPopup;
            menuCode.Caption = "NXDO.RJacoste 实用工具集";
            menuCode.TooltipText = "NXDO.RJacoste 工具集";
            //(menuCode as CommandBarButton).Style = MsoButtonStyle.msoButtonIconAndCaption;
            //(menuCode as CommandBarButton).Picture = AxImage.StdPicture("NXDO.Component.Addin.Res.image.VSAddin.bmp");

            CommandBarControl menuItemClass = menuCode.Controls.Add(MsoControlType.msoControlButton, 1, "", 1, true);
            menuItemClass.Tag = "Java 的 C# Class";
            menuItemClass.Caption = "生成 jar 的 c# 包装类";
            menuItemClass.TooltipText = "生成 jar 的 c# 包装类";
            menuJacosteHandler = (CommandBarEvents)_applicationObject.DTE.Events.get_CommandBarEvents(menuItemClass);
            menuJacosteHandler.Click += new _dispCommandBarControlEvents_ClickEventHandler(EventAction);
            CommandBarButton cmdItemClass = (CommandBarButton)menuItemClass;
            cmdItemClass.Style = MsoButtonStyle.msoButtonIconAndCaption;
            cmdItemClass.Picture = AxImage.StdPicture("NXDO.RJacoste.Addin.Res.FormIco.png");

            //CommandBar vsBarProject2 = cmdBars["Web Project Folder"];
            #endregion
        }
Example #7
0
        /// <summary>
        /// Creates the user interface.
        /// </summary>
        public void CreateUserInterface()
        {
            //  Get the sil command name.
            var silCommandId = addInInstance.ProgID + "." + Command_Switch_Name;

            //  If we don't have the command, create it.
            if (applicationObject.Commands.OfType<Command>().Any(c => c.Name != silCommandId))
                CreateCommands();

            //  Create the control for the Sil command.
            try
            {
                var commandSwitch = applicationObject.Commands.Item(silCommandId);

                //  Retrieve the context menu of code windows.
                var commandBars = (CommandBars)applicationObject.CommandBars;
                var mainMenuCommandBar = commandBars[MenuBar_MainMenu];

                //  Add the switch line command.
                controlMainMenuSwitchCommand = (CommandBarControl)commandSwitch.AddControl(mainMenuCommandBar,
                    mainMenuCommandBar.Controls.Count + 1);
            }
            catch (Exception exception)
            {
                HandleException(@"Failed to create the 'Switch' command.", exception);
            }
        }
Example #8
0
	    private int AddSubMenu(out CommandBarControl menuItem, CommandBarPopup parent, out CommandBarEvents eventHandler, int position, string caption, string imagePath, string maskedImagePath)
		{
			menuItem = parent.Controls.Add(MsoControlType.msoControlButton, Missing.Value, Missing.Value, position, true);
            menuItem.Caption = caption;

			eventHandler = (CommandBarEvents)_applicationObject.Events.get_CommandBarEvents(menuItem);

			if (!string.IsNullOrEmpty(imagePath))
			{
				Helper.SetPicture(Assembly.GetExecutingAssembly(), (CommandBarButton) menuItem.Control, imagePath, maskedImagePath);
			}
			else if (string.Equals(caption, DB4O_HOMEPAGE))
			{
				menuItem.BeginGroup = true;
			}

		    return position + 1;
		}
Example #9
0
		private int AddSubMenu(out CommandBarControl menuItem, CommandBarPopup parent, out CommandBarEvents eventHandler, int position, string caption)
		{
			return AddSubMenu(out menuItem, parent, out eventHandler, position, caption, string.Empty, string.Empty);
		}
Example #10
0
 protected internal VsDevExpressMenuItem(CommandBarControl source)
 {
     vsSourceCore = source;
     if (source != null) {
         if (source.Type == MsoControlType.msoControlButton)
             ((CommandBarButton)source).Click += OnButtonClick;
         headerCore = source.Caption;
         toolTipCore = source.TooltipText;
     }
     CreateChildrenFromSource();
 }
Example #11
0
		private void CloseAllToolWindows()
		{
			try
			{



				dbInteraction.Closedb();

				dbInteraction.SetCurrentRecentConnection(null);
				Helper.ClearAllCachedAttributes();

				ForEachOMNWindow(delegate(Window window)
				                 	{

				                 		window.Close(vsSaveChanges.vsSaveChangesNo);

				                 	});


				CloseMiscToolwindows();

				if (oPopup != null)
				{
					RemoveMenuControls();
					omObjectBrowserControl = null;
					omQueryBuilderControl = null;
					omPropertiesControl = null;
				}
				RemoveAllQueryResultToolwindows();

			}

			catch (System.Runtime.InteropServices.COMException)
			{
			}
			catch (Exception oEx)
			{
				LoggingHelper.HandleException(oEx);
			}
		}
		/*
		 * OnConnection
		 */

		public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
		{
			if (application == null)
			{
				throw new ArgumentNullException("application");
			}

			if (addInInst == null)
			{
				throw new ArgumentNullException("addInInst");
			}

			if (application is DTE2)
			{
				_applicationObject = (DTE2)application;
			}
			else
			{
				throw new ArgumentException(Resources.Argument_InvalidApplicationType);
			}

			if (addInInst is AddIn)
			{
				_addInInstance = (AddIn)addInInst;
			}
			else
			{
				throw new ArgumentException(Resources.Argument_InvalidAddInInstanceType);
			}

			_taskListIdentifier = NuGenExtensibility.BuildCommandIdentifier(this.GetType(), Resources.Menu_TaskList_Identifier);

			Events applicationObjectEvents = _applicationObject.Events;
			Debug.Assert(applicationObjectEvents != null, "applicationObjectEvents != null");

			_solution = applicationObjectEvents.SolutionEvents;
			Debug.Assert(_solution != null, "_Solution != null");

			_solution.BeforeClosing += _Solution_BeforeClosing;
			_solution.Opened += _Solution_Opened;

			switch (connectMode)
			{
				case ext_ConnectMode.ext_cm_UISetup:
				{
					try
					{
						NuGenExtensibility.RemoveAddInCommands(this.GetType(), _applicationObject);
					}
					catch (Exception e)
					{
						if (_ErrorEnabled)
						{
							Trace.WriteLine("Error occured while removing add-in commands: " + e.Message);
						}
					}

					try
					{
						NuGenExtensibility.CreateAddInCommand(
							_applicationObject,
							_addInInstance,
							Resources.Menu_TaskList_Identifier,
							Resources.Menu_TaskList_Name,
							Resources.Menu_TaskList_Description,
							439
						);
					}
					catch (Exception e)
					{
						if (_ErrorEnabled)
						{
							Trace.WriteLine("Error occured while creating add-in commands: " + e.Message);
						}
					}

					break;
				}
				case ext_ConnectMode.ext_cm_AfterStartup:
				case ext_ConnectMode.ext_cm_Startup:
				{
					CommandBar menuBar = ((CommandBars)_applicationObject.CommandBars)["MenuBar"];
					Debug.Assert(menuBar != null, "menuBar != null");

					CommandBarPopup menuPopup = (CommandBarPopup)menuBar.Controls[this.GetFullMenuName(Resources.Menu_ParentMenu_Name)];
					Debug.Assert(menuPopup != null, "menuPopup != null");

					CommandBar menuCommandBar = menuPopup.CommandBar;
					Debug.Assert(menuCommandBar != null, "menuCommandBar != null");

					Command taskListCommand = null;

					try
					{
						taskListCommand = _applicationObject.Commands.Item(_taskListIdentifier, -1);
					}
					catch (ArgumentException)
					{
						NuGenExtensibility.RemoveAddInCommands(this.GetType(), _applicationObject);
						taskListCommand = NuGenExtensibility.CreateAddInCommand(
							_applicationObject,
							_addInInstance,
							Resources.Menu_TaskList_Identifier,
							Resources.Menu_TaskList_Name,
							Resources.Menu_TaskList_Description,
							439
						);
					}

					Debug.Assert(taskListCommand != null, "taskListCommand != null");

					try
					{
						_taskListMenuItem = NuGenExtensibility.CreateAddInMenu(
							taskListCommand,
							menuCommandBar,
							1
						);
					}
					catch (Exception e)
					{
						Trace.WriteLineIf(
							_ErrorEnabled,
							"Error occured while creating menu item.: " + e.Message
						);
					}

					try
					{
						_addInUI = this.CreateToolWindow(
							_addInInstance,
							typeof(NuGenTaskListUI),
							Resources.ToolWindow_Caption
						);
					}
					catch (Exception e)
					{
						Trace.WriteLineIf(
							_ErrorEnabled,
							"Error occured while creating tool window: " + e.Message
						);
					}

					break;
				}
			}
		}
        private void InitializeAddIn()
        {
            CommandBarControl myCommandBarControl;
            CommandBar codeWindowCommandBar;
            Command myCommand1;
            Command myCommand2;
            CommandBars commandBars;

            // Retrieve commands created in the ext_cm_UISetup phase of the OnConnection method
            myCommand1 = m_dte.Commands.Item(m_addIn.ProgID + "." + m_NAME_COMMAND1, -1);
            myCommand2 = m_dte.Commands.Item(m_addIn.ProgID + "." + m_NAME_COMMAND2, -1);

            // Retrieve the context menu of code windows
            commandBars = (CommandBars)m_dte.CommandBars;
            codeWindowCommandBar = commandBars["Code Window"];

            // Add a popup command bar
            myCommandBarControl = codeWindowCommandBar.Controls.Add(MsoControlType.msoControlPopup,
               System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing);

            m_commandBarPopup = (CommandBarPopup)myCommandBarControl;

            // Change its caption
            m_commandBarPopup.Caption = "My popup";

            // Add controls to the popup command bar
            m_commandBarControl1 = (CommandBarControl)myCommand1.AddControl(m_commandBarPopup.CommandBar,
               m_commandBarPopup.Controls.Count + 1);

            m_commandBarControl2 = (CommandBarControl)myCommand2.AddControl(m_commandBarPopup.CommandBar,
               m_commandBarPopup.Controls.Count + 1);
        }
Example #14
0
        public void Add(string commandName, CommandBarControl control)
        {
            control.Click += new EventHandler(this.CommandBarControl_Click);

            CommandState state = this.GetCommandState(commandName, control);
            state.AddItem(control);

            this.itemTable[control] = commandName;
        }
Example #15
0
        private CommandState GetCommandState(string commandName, CommandBarControl control)
        {
            foreach (CommandState commandState in this.states)
            {
                if (commandName == commandState.CommandName)
                {
                    return commandState;
                }
            }

            CommandBarButton button = control as CommandBarButton;
            if (button != null)
            {
                CommandButtonState commandState = new CommandButtonState(commandName);
                this.states.Add(commandState);
                return commandState;
            }

            CommandBarCheckBox checkBox = control as CommandBarCheckBox;
            if (checkBox != null)
            {
                CommandCheckBoxState commandState = new CommandCheckBoxState(commandName);
                this.states.Add(commandState);
                return commandState;
            }

            CommandBarComboBox comboBox = control as CommandBarComboBox;
            if (comboBox != null)
            {
                CommandComboBoxState commandState = new CommandComboBoxState(commandName);
                this.states.Add(commandState);
                return commandState;
            }

            throw new NotSupportedException();
        }
Example #16
0
		private static void SafeSetEnabled(CommandBarControl control, bool enabled)
		{
			if (control != null)
				control.Enabled = enabled;
		}
Example #17
0
 /// <summary>
 /// Adds handler to the menu item click event.
 /// </summary>
 /// <param name="menuItem">The menu item.</param>
 private void AddClickEventHandler(CommandBarControl menuItem)
 {
     CommandBarEvents menuItemHandler = (EnvDTE.CommandBarEvents)application.DTE.Events.get_CommandBarEvents(menuItem);
     menuItemHandler.Click += new _dispCommandBarControlEvents_ClickEventHandler(MenuItem_Click);
     menuItemHandlerList.Add(menuItemHandler);
 }
Example #18
0
		private CommandBarEvents AddControlToToolbar(ref CommandBarControl ctrl, string caption)
		{
			ctrl = oPopup.Controls.Add(MsoControlType.msoControlButton,
			                                             Missing.Value,
			                                             Missing.Value,
			                                             11, true);

			ctrl.BeginGroup = true;
			ctrl.Caption = Helper.GetResourceString(caption);
			return (CommandBarEvents)_applicationObject.Events.get_CommandBarEvents(ctrl);
		}