Inheritance: Control, IDisposable
コード例 #1
0
        public CommandBar GetCommandBar(string key, CommandBar itemCmbBar)
        {
            string[] keys = key.Split('.');

            if (itemCmbBar == null)
                itemCmbBar = ((CommandBars)_applicationObject.CommandBars)[keys[0]];
            else
            {
                CommandBarControl toolsControl = itemCmbBar.Controls[key[0]];
                CommandBarPopup toolsPopup = (CommandBarPopup)toolsControl;

                itemCmbBar = toolsPopup.CommandBar;
            }


            if (itemCmbBar != null)
            {
                if (keys.Length == 1)
                {
                    return itemCmbBar;
                }
                else
                {
                    string newKey = key.Substring(key.IndexOf('.') + 1);
                    return GetCommandBar(newKey, itemCmbBar);
                }
            }

            return null;
        }
コード例 #2
0
ファイル: Utility.cs プロジェクト: kingservice/sipxecs
        /// <summary>
        /// 
        /// </summary>
        /// <param name="cbar"> commandBar on which the button is added.</param>
        /// <param name="tag"> button tag</param>
        /// <param name="desc">button description</param>
        /// <param name="caption">button caption</param>
        /// <param name="before"></param>
        /// <param name="temp"></param>
        /// <param name="handler"></param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static CommandBarButton addButton(CommandBar cbar, String tag, String desc, 
            String caption, Object before, bool temp, 
            _CommandBarButtonEvents_ClickEventHandler handler, String parameter)
        {

            CommandBarButton foundButton = (CommandBarButton)cbar.FindControl(
                MsoControlType.msoControlButton,
                Type.Missing, tag, false, true);

            if (foundButton != null)
            {
                foundButton.Caption = caption;
                setClickHandler(foundButton, handler);
                foundButton.Visible = true;
                foundButton.Parameter = parameter;
                return foundButton;
            }

            CommandBarButton button = (CommandBarButton)cbar.Controls.Add(
                MsoControlType.msoControlButton,
                Type.Missing, Type.Missing, before, temp);

            setClickHandler(button, handler);

            button.Tag = tag;
            button.DescriptionText = desc;
            button.BeginGroup = false;
            button.Caption = caption;
            button.Style = MsoButtonStyle.msoButtonIconAndCaption;
            button.Visible = true;
            button.Parameter = parameter;

            return button;
        }
コード例 #3
0
ファイル: ThisAddIn.cs プロジェクト: SergeyRyzhov/DLExt
        private void CreateToolbar()
        {
            try
            {
                toolBar = FindBar()
                    ?? Application.ActiveExplorer().CommandBars.Add(MenuToolbarTag, MsoBarPosition.msoBarTop, false, true);

                toolBarButton = (CommandBarButton)toolBar.Controls.Add(MsoControlType.msoControlButton, missing, missing, 1, true);
                toolBarButton.Style = MsoButtonStyle.msoButtonIconAndCaption;
                toolBarButton.Caption = "Generate Distribution List";
                toolBarButton.FaceId = 65;
                toolBarButton.Tag = MenuToolbarTag;
                toolBarButton.Click += (CommandBarButton ctrl, ref bool @default) =>
                {
                    MainWindow window = new MainWindow(
                        "NNVDC01",
                        "OU=Sites,OU=Company,DC=domain,DC=corp",
                        "OU=Sites,OU=Company,DC=domain,DC=corp");
                    window.Show();
                };
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Error Message");
            }
        }
コード例 #4
0
ファイル: Connect.cs プロジェクト: ssekoguchi/vsaddin11
 /// <summary></summary>
 public CommandBarPopup AddCommandBarPopup(CommandBar parent, string name, string caption)
 {
     var popup = (CommandBarPopup)parent.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, 1, true);
     _popUps.Add(name, popup);
     popup.CommandBar.Name = name;
     popup.Caption = caption;
     return popup;
 }
コード例 #5
0
        public int Add(CommandBar commandBar)
        {
            if (!this.Contains(commandBar))
            {
                int index = this.bands.Add(commandBar);
                this.commandBarManager.UpdateBands();
                return index;
            }

            return -1;
        }
コード例 #6
0
ファイル: Connect.cs プロジェクト: LuckyTeng/VBAddIn
        public CommandBarButton AddCommandBarButton(CommandBar cb)
        {
            CommandBarButton cbb;
            CommandBarControl cbc;

            cbc = cb.Controls.Add(MsoControlType.msoControlButton);
            cbb = cbc as CommandBarButton;

            cbb.Caption = "My Add-in Help";
            cbb.FaceId = 59;

            return cbb;
        }
コード例 #7
0
ファイル: XmlBuilder.cs プロジェクト: heon21st/flashdevelop
		/**
		* Creates a main menu from the specified xml file
		*/
		public CommandBar GenerateMainMenu(string menuXmlFile)
		{
			CommandBar mainMenu = new CommandBar(CommandBarStyle.Menu);
			XmlNode rootNode = this.LoadXMLFile(menuXmlFile);
			int count = rootNode.ChildNodes.Count;
			for (int i = 0; i<count; i++)
			{
				if (rootNode.ChildNodes[i].Name == "menu")
				{
					mainMenu.Items.Add(this.GetMenu(rootNode.ChildNodes[i]));
				}
			}
			return mainMenu;
		}
コード例 #8
0
ファイル: AddinInit.cs プロジェクト: Xenioz/qt-labs-vstools
 // Functions ------------------------------------------------------
 public AddinInit( _DTE a)
 {
     cmdBars = (_CommandBars)a.CommandBars;
     cmds    = a.Commands;
     try {
     cmdProjectContext = FindCommandBar
         (new Guid("{D309F791-903F-11D0-9EFC-00A0C911004F}"), 1026);
     cmdSolutionContext = FindCommandBar
         (new Guid("{D309F791-903F-11D0-9EFC-00A0C911004F}"), 1043);
     cmdItemContext = FindCommandBar
         (new Guid("{D309F791-903F-11D0-9EFC-00A0C911004F}"), 1072);
     }
     catch{
     //MessageBox.Show( e.Message );
     }
 }
			public override bool RegisterGUI(Command vsCommand, CommandBar vsCommandbar, bool toolBarOnly)
			{
				if(toolBarOnly)
				{
					_RegisterGUIBar(vsCommand, vsCommandbar);
				}
				else
				{
					_RegisterGuiContext(vsCommand, "Project");
					_RegisterGuiContext(vsCommand, "Item");
					_RegisterGuiContext(vsCommand, "Easy MDI Document Window");
					_RegisterGuiContext(vsCommand, "Cross Project Multi Item");
					_RegisterGuiContext(vsCommand, "Cross Project Multi Project");
				}
				return true;
			}
コード例 #10
0
ファイル: ThisAddIn.cs プロジェクト: joehosemann/BBEngage
 /// <summary>
 /// Creates the toolbar.
 /// </summary>
 private void CreateToolbar()
 {
     // Verify the BBAssist Toolbar exists and add to the application
     if (_bbaToolBar == null)
     {
         var packtBars = Application.ActiveExplorer().CommandBars;
         _bbaToolBar = packtBars.Add("Engage", MsoBarPosition.msoBarTop, false, true);
     }
     var myButton1 = (CommandBarButton)_bbaToolBar.Controls.Add(1, missing, missing, missing, missing);
     myButton1.Style = MsoButtonStyle.msoButtonCaption;
     myButton1.Caption = "Engage";
     myButton1.Tag = "Engage - Settings";
     if (_bbaButton == null)
     {
         _bbaButton = myButton1;
         _bbaButton.Click += ToolbarButtonClick;
     }
 }
コード例 #11
0
ファイル: Utility.cs プロジェクト: kingservice/sipxecs
        /// <summary>
        /// 
        /// </summary>
        /// <param name="theBar"></param>
        /// <param name="tag"></param>
        public static void RemoveButton(CommandBar theBar, String tag)
        {
            try
            {
                CommandBarButton foundButton = (CommandBarButton)
                    theBar.FindControl(MsoControlType.msoControlButton,
                    Type.Missing, tag, true, true);
                if (foundButton != null)
                {
                    foundButton.Delete(false);
                    foundButton = null;
                }
            }

            catch (System.Exception ex)
            {
                Logger.WriteEntry(LogLevel.Warning, ex.GetType() + ":" + ex.Message);
            }

        }
コード例 #12
0
ファイル: ApplicationWindow.cs プロジェクト: NickCorn/Writer
        public ApplicationWindow()
        {
            this.Icon = IconResource.Application;
            this.Font = new Font("Tahoma", 8.25f);

            this.StartPosition = FormStartPosition.WindowsDefaultLocation;

            this.Size = new Size(800, 800);

            this.view.Dock = DockStyle.Fill;
            this.view.TabStop = false;
            this.Controls.Add(this.view);

            this.menuBar = new CommandBar(this.commandBarManager, CommandBarStyle.Menu);
            this.toolBar = new CommandBar(this.commandBarManager, CommandBarStyle.ToolBar);

            this.commandBarManager.CommandBars.Add(this.menuBar);
            this.commandBarManager.CommandBars.Add(this.toolBar);
            this.Controls.Add(this.commandBarManager);

            this.Controls.Add(statusBar);
        }
コード例 #13
0
        private void CommandBar_TextChanged(object sender, EventArgs e)
        {
            CommandBar commandBar = (CommandBar)sender;

            this.UpdateBand(commandBar);
        }
コード例 #14
0
        private CommandBar RecurseCommandBarToFindCommandBarByName(CommandBar bar, string name)
        {
            //try
            //{
            //    CommandBarControl ctrl = bar.Controls[name]; //only works for US and international VS in VS2010
            //    return ((CommandBarPopup)ctrl).CommandBar;
            //}
            //catch { }

            //idea from http://www.mztools.com/articles/2007/MZ2007002.aspx
            if (bar.Name == name)
            {
                return bar;
            }
            //foreach (CommandBarControl cmd in bar.Controls)
            //{
            //    if (cmd.Type == MsoControlType.msoControlPopup)
            //    {
            //        CommandBarPopup popup = (CommandBarPopup)cmd;
            //        if (popup.CommandBar.Name == name)
            //        {
            //            return popup.CommandBar;
            //        }
            //    }
            //}
            foreach (CommandBarControl cmd in bar.Controls)
            {
                if (cmd.Type == MsoControlType.msoControlPopup)
                {
                    CommandBarPopup popup = (CommandBarPopup)cmd;
                    CommandBar oReturnVal = RecurseCommandBarToFindCommandBarByName(popup.CommandBar, name);
                    if (oReturnVal != null) return oReturnVal;
                }
            }
            return null;
        }
コード例 #15
0
        CommandBar GetCommandBarPopup(CommandBar parentCommandBar, string commandBarPopupName)
        {
            foreach (CommandBarControl commandBarControl in parentCommandBar.Controls)
              {

            if (commandBarControl.Type == MsoControlType.msoControlPopup)
            {

              CommandBarPopup commandBarPopup = commandBarControl as CommandBarPopup;

              if (commandBarPopup.CommandBar.Name == commandBarPopupName)
              {

            return commandBarPopup.CommandBar;

              }

            }

              }

              return null;
        }
コード例 #16
0
 internal CommandBarItemCollection()
 {
     this.commandBar = null;
     this.items      = new ArrayList();
 }
コード例 #17
0
ファイル: Connect.cs プロジェクト: erdincay/db4o
		/// <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;
			ViewBase.ResetToolWindowList();
			OutputWindow.Initialize(_applicationObject);

			try
			{
				if (connectMode == ext_ConnectMode.ext_cm_AfterStartup || connectMode == ext_ConnectMode.ext_cm_Startup)
				{
					CreateMenu();
					


					try
					{
						CommandBars toolBarCommandBars = ((CommandBars)_applicationObject.CommandBars);
						string toolbarName = Helper.GetResourceString(OMControlLibrary.Common.Constants.PRODUCT_CAPTION);
						try
						{
							omToolbar = toolBarCommandBars.Add(toolbarName, MsoBarPosition.msoBarTop, Type.Missing, false);
						}
						catch (ArgumentException)
						{
							omToolbar = toolBarCommandBars[toolbarName];
						}
						CreateToolBar();
						omToolbar.Visible = true;
					
					}
					catch (Exception oEx)
					{
						LoggingHelper.HandleException(oEx);
					}

					try
					{
						Events events = _applicationObject.Events;
						_windowsEvents = events.get_WindowEvents(null);
						
						_windowsEvents.WindowActivated += OnWindowActivated;

						_eve = _applicationObject.Events.DTEEvents;
						_eve.ModeChanged += DesignDebugModeChanged;
						
						
					}
					catch (Exception oEx)
					{
						LoggingHelper.HandleException(oEx);
					}
					
					try
					{
						//This function checks whether user already logged in.

						ViewBase.ApplicationObject = _applicationObject;
						//enable disable connect button while checking cfredentials
						connectDatabaseMenu.Enabled = false;
						connectDatabaseButton.Enabled = false;
						Cursor.Current = Cursors.WaitCursor;
						Cursor.Current = Cursors.Default;
						connectDatabaseMenu.Enabled = true;
						connectDatabaseButton.Enabled = true;
					}
					catch (Exception oEx)
					{
						LoggingHelper.HandleException(oEx);
					}
				}
			}
			catch (Exception oEx)
			{
				LoggingHelper.HandleException(oEx);
			}

		}
コード例 #18
0
ファイル: Connect.cs プロジェクト: jmecosta/VSSonarAddin
        private void FormatBarAndButtons(CommandBar codeCommandBar)
        {
            AddCommandByName(ref runServerViolationsCommand, MYCOMMANDREPORTSERVERVIOLATIONS, MYCOMMANDREPORTSERVERVIOLATIONSCAPTION, MYCOMMANDREPORTSERVERVIOLATIONSTOOLTIP, 1);
            runServerViolationsCommandBarButton = AddCommandToCmdBar(runServerViolationsCommand, codeCommandBar, MsoButtonStyle.msoButtonIconAndCaption);
            runServerViolationsCommandBarButton.Caption = MYCOMMANDREPORTSERVERVIOLATIONSCAPTION;
            runServerViolationsCommandBarButton.BeginGroup = true;
            runServerViolationsCommandBarButton = AddCommandToCmdBar(runServerViolationsCommand, temporaryToolbar, MsoButtonStyle.msoButtonIcon);
            runServerViolationsCommandBarButton.Caption = MYCOMMANDREPORTSERVERVIOLATIONSCAPTION;

            AddCommandByName(ref runLocalViolationsCommand, MYCOMMANDREPORTLOCALVIOLATIONS, MYCOMMANDREPORTLOCALVIOLATIONSCAPTION, MYCOMMANDREPORTLOCALVIOLATIONSTOOLTIP, 2);
            runLocalViolationsCommandBarButton = AddCommandToCmdBar(runLocalViolationsCommand, codeCommandBar, MsoButtonStyle.msoButtonIconAndCaption);
            runLocalViolationsCommandBarButton.Caption = MYCOMMANDREPORTLOCALVIOLATIONSCAPTION;
            runLocalViolationsCommandBarButton.BeginGroup = false;
            runLocalViolationsCommandBarButton = AddCommandToCmdBar(runLocalViolationsCommand, temporaryToolbar, MsoButtonStyle.msoButtonIcon);
            runLocalViolationsCommandBarButton.Caption = MYCOMMANDREPORTLOCALVIOLATIONSCAPTION;

            AddCommandByName(ref runServerCoverageCommand, MYCOMMANDREPORTCOVERAGE, MYCOMMANDREPORTCOVERAGECAPTION, MYCOMMANDREPORTCOVERAGETOOLTIP, 3);
            runServerCoverageCommandBarButton = AddCommandToCmdBar(runServerCoverageCommand, codeCommandBar, MsoButtonStyle.msoButtonIconAndCaption);
            runServerCoverageCommandBarButton.Caption = MYCOMMANDREPORTCOVERAGECAPTION;
            runServerCoverageCommandBarButton.BeginGroup = false;
            runServerCoverageCommandBarButton = AddCommandToCmdBar(runServerCoverageCommand, temporaryToolbar, MsoButtonStyle.msoButtonIcon);
            runServerCoverageCommandBarButton.Caption = MYCOMMANDREPORTCOVERAGECAPTION;

            AddCommandByName(ref runSourceDiffCommand, MYCOMMANDREPORTSOURCEDIFF, MYCOMMANDREPORTSOURCEDIFFCAPTION, MYCOMMANDREPORTSOURCEDIFFTOOLTIP, 4);
            runSourceDiffCommandBarButton = AddCommandToCmdBar(runSourceDiffCommand, codeCommandBar, MsoButtonStyle.msoButtonIconAndCaption);
            runSourceDiffCommandBarButton.Caption = MYCOMMANDREPORTSOURCEDIFFCAPTION;
            runSourceDiffCommandBarButton.BeginGroup = false;
            runSourceDiffCommandBarButton = AddCommandToCmdBar(runSourceDiffCommand, temporaryToolbar, MsoButtonStyle.msoButtonIcon);
            runSourceDiffCommandBarButton.Caption = MYCOMMANDREPORTSOURCEDIFFCAPTION;

            AddCommandByName(ref runAllLocalViolationsCommand, MYCOMMANDREPORTALLLOCALVIOLATIONS, MYCOMMANDREPORTALLLOCALVIOLATIONSCAPTION, MYCOMMANDREPORTALLLOCALVIOLATIONSTOOLTIP, 5);
            runAllLocalViolationsCommandBarButton = AddCommandToCmdBar(runAllLocalViolationsCommand, codeCommandBar, MsoButtonStyle.msoButtonIconAndCaption);
            runAllLocalViolationsCommandBarButton.Caption = MYCOMMANDREPORTALLLOCALVIOLATIONSCAPTION;
            runAllLocalViolationsCommandBarButton.BeginGroup = false;
            runAllLocalViolationsCommandBarButton = AddCommandToCmdBar(runAllLocalViolationsCommand, temporaryToolbar, MsoButtonStyle.msoButtonIcon);
            runAllLocalViolationsCommandBarButton.Caption = MYCOMMANDREPORTALLLOCALVIOLATIONSCAPTION;

            AddCommandByName(ref runResetCommand, MYCOMMANDRESET, MYCOMMANDRESETCAPTION, MYCOMMANDRESETTOOLTIP, 6);
            runResetCommandBarButton = AddCommandToCmdBar(runResetCommand, codeCommandBar, MsoButtonStyle.msoButtonIconAndCaption);
            runResetCommandBarButton.Caption = MYCOMMANDRESETCAPTION;
            runResetCommandBarButton.BeginGroup = false;
            runResetCommandBarButton = AddCommandToCmdBar(runResetCommand, temporaryToolbar, MsoButtonStyle.msoButtonIcon);
            runResetCommandBarButton.Caption = MYCOMMANDRESETCAPTION;
        }
コード例 #19
0
ファイル: Connect.cs プロジェクト: jmecosta/VSSonarAddin
        /// <summary>
        /// Builds the toolbar buttons and the context menu items.
        /// </summary>
        public void AddTemporaryUI()
        {
            const string VS_STANDARD_COMMANDBAR_NAME = "Standard";
            const string VS_CODE_WINDOW_COMMANDBAR_NAME = "Code Window";
            const string MY_TEMPORARY_TOOLBAR_CAPTION = "Sonar Toolbar";

            CommandBar standardCommandBar = null;
            CommandBar codeCommandBar = null;
            CommandBars commandBars = null;

            try
            {
                // Retrieve the collection of commandbars
                // Note:
                // - In VS.NET 2002/2003 (which uses the Office.dll reference)
                //   DTE.CommandBars returns directly a CommandBars type, so a cast
                //   to CommandBars is redundant
                // - In VS 2005 or higher (which uses the new Microsoft.VisualStudio.CommandBars.dll reference)
                //   DTE.CommandBars returns an Object type, so we do need a cast to CommandBars
                commandBars = (CommandBars)applicationObject.CommandBars;
                standardCommandBar = commandBars[VS_STANDARD_COMMANDBAR_NAME];
                codeCommandBar = commandBars[VS_CODE_WINDOW_COMMANDBAR_NAME];
                ModifyRegistry createRegistry = new ModifyRegistry(PLUGINKEY);

                temporaryToolbar = commandBars.Add(MY_TEMPORARY_TOOLBAR_CAPTION, MsoBarPosition.msoBarTop, System.Type.Missing, true);

                try
                {
                    int row_index = (int)createRegistry.Read(ROWINDEXKEY);
                    temporaryToolbar.RowIndex = row_index;
                }
                catch (System.Exception)
                {
                }

                FormatBarAndButtons(codeCommandBar);

                try
                {
                    bool visible = Convert.ToBoolean(createRegistry.Read(VISIBLEKEY));
                    temporaryToolbar.Visible = visible;
                }
                catch (System.Exception)
                {
                    temporaryToolbar.Visible = true;
                }

            }
            catch(System.Exception e)
            {
                System.Windows.Forms.MessageBox.Show("Cannot Add ToolBar: " + e.StackTrace);
            }
        }
コード例 #20
0
ファイル: Plugin.cs プロジェクト: TwistedHope/gitextensions
        private void AddToolbarOrMenuCommand(CommandBar bar, string commandName, string caption,
            string tooltip, int iconIndex, int insertIndex, vsCommandStyle commandStyle)
        {
            // Do not try to add commands to a null bar
            if (bar == null)
                return;

            // Get commands collection
            Commands2 commands = (Commands2)m_application.Commands;
            object[] contextGUIDS = new object[] { };

            // Add command
            Command command = GetCommand(commandName);
            if (!m_visualStudioCommands.ContainsKey(commandName))
            if (command == null)
            {
                if (iconIndex > 0)
                {
                    try
                    {
                        command = commands.AddNamedCommand2(m_addIn,
                                    commandName, caption, tooltip, false, iconIndex, ref contextGUIDS,
                                    (int)vsCommandStatus.vsCommandStatusSupported +
                                    (int)vsCommandStatus.vsCommandStatusEnabled,
                                    (int)commandStyle,
                                    vsCommandControlType.vsCommandControlTypeButton);
                        m_visualStudioCommands[commandName] = command;
                    }
                    catch
                    {
                    }
                }

                if (command == null && commandStyle != vsCommandStyle.vsCommandStylePict)
                {
                    command = commands.AddNamedCommand2(m_addIn,
                            commandName, caption, tooltip, true, -1, ref contextGUIDS,
                            (int)vsCommandStatus.vsCommandStatusSupported +
                            (int)vsCommandStatus.vsCommandStatusEnabled,
                            (int)commandStyle,
                            vsCommandControlType.vsCommandControlTypeButton);
                    m_visualStudioCommands[commandName] = command;
                }
            }
            if (command != null && bar != null)
            {
                if (!HasCommand(bar, caption))
                {
                    OutputPane.OutputString("Add toolbar command: " + caption + Environment.NewLine);
                    command.AddControl(bar, insertIndex);
                }
            }
        }
コード例 #21
0
ファイル: XmlBuilder.cs プロジェクト: heon21st/flashdevelop
		/**
		* Creates a toolbar from the specified xml file
		*/
		public CommandBar GenerateToolBar(string toolbarXmlFile)
		{
			CommandBar toolBar = new CommandBar(CommandBarStyle.ToolBar);
			XmlNode rootNode = this.LoadXMLFile(toolbarXmlFile);
			int count = rootNode.ChildNodes.Count;
			for (int i = 0; i<count; i++)
			{
				if (rootNode.ChildNodes[i].Name == "button")
				{
					toolBar.Items.Add(this.GetButton(rootNode.ChildNodes[i]));
				}
				else if (rootNode.ChildNodes[i].Name == "combobox")
				{
					toolBar.Items.Add(this.GetComboBox(rootNode.ChildNodes[i]));
				}
				else if (rootNode.ChildNodes[i].Name == "checkbox")
				{
					toolBar.Items.Add(this.GetCheckBox(rootNode.ChildNodes[i]));
				}
				else if (rootNode.ChildNodes[i].Name == "separator")
				{
					toolBar.Items.AddSeparator();
				}
			}
			return toolBar;
		}
コード例 #22
0
ファイル: Plugin.cs プロジェクト: TwistedHope/gitextensions
 public void AddToolbarCommandWithText(CommandBar bar, string commandName, string caption,
     string tooltip, int iconIndex, int insertIndex)
 {
     AddToolbarOrMenuCommand(bar, commandName, caption, tooltip, iconIndex, insertIndex,
         vsCommandStyle.vsCommandStylePictAndText);
 }
コード例 #23
0
 public void CopyTo(CommandBar[] array, int index)
 {
     this.bands.CopyTo(array, index);
 }
コード例 #24
0
ファイル: VS80AddIn.cs プロジェクト: siwiwit/andromda
        public void RegisterToolbar()
        {
            m_toolBar = null;

            // Remove the toolbar if it exists
            try
            {
                CommandBars bars = (CommandBars)m_applicationObject.CommandBars;
                m_toolBar = bars[TOOL_BAR_NAME];		// it seems this will never execute
                if (m_toolBar != null)
                {
                    m_toolBar.Delete();
                    m_toolBar = null;
                }
            } catch { }

            // Create the toolbar
            if (m_toolBar == null)
            {
                CommandBars bars = (CommandBars)m_applicationObject.CommandBars;
                m_toolBar = bars.Add(TOOL_BAR_NAME, MsoBarPosition.msoBarTop, System.Type.Missing, true);

                // Load saved toolbar settings
                m_toolBar.Visible = m_addInSettings.ToolBarVisible;
                m_toolBar.Position = m_addInSettings.ToolBarPosition;
                if (m_addInSettings.ToolBarTop.HasValue)
                {
                    m_toolBar.Top = m_addInSettings.ToolBarTop.Value;
                }
                if (m_addInSettings.ToolBarLeft.HasValue)
                {
                    m_toolBar.Left = m_addInSettings.ToolBarLeft.Value;
                }
                if (m_addInSettings.ToolBarRowIndex.HasValue)
                {
                    m_toolBar.RowIndex = m_addInSettings.ToolBarRowIndex.Value;
                }
            }

            // Add the buttons to the toolbar
            foreach (AddInCommandBase cmd in m_commands)
            {
                cmd.InitToolbars(m_toolBar);
            }
        }
コード例 #25
0
ファイル: Connect.cs プロジェクト: nberglund/sqlclrproject
        private object[] AddCmd(CommandBar parent, string name, string caption, string decription, int pos)
        {
            object[] contextGUIDS = new object[] { };
              string cmdName = string.Format("{0}.{1}", this.GetType().ToString(), name);
              Command cmd = null;
              //myCommand = applicationObject.Commands.Item(addInInstance.ProgID & "." & "MyCommand");
              //Add a command to the Commands collection:
              try {
            //look for the command in the hashtable
            cmd = (Command)cmdHt[cmdName];
            //cmd = commands.Item(cmdName, (int)System.Type.Missing);

            if (cmd == null) {
              cmd = commands.AddNamedCommand2(_addIn, name, caption, decription, true, 59, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled, (int)vsCommandStyle.vsCommandStyleText, vsCommandControlType.vsCommandControlTypeButton);
              cmdHt.Add(cmd.Name, cmd);
            }

            }

              catch (Exception e) {
            MessageBox.Show(e.Message, "Error");
              }

              //Add a control for the command to the menu:
              if ((cmd != null) && (parent != null)) {
               cmd.AddControl(parent, pos);
              }
              else
            MessageBox.Show("Command or parent == null");

              return contextGUIDS;
        }
コード例 #26
0
 public bool Contains(CommandBar commandBar)
 {
     return this.bands.Contains(commandBar);
 }
コード例 #27
0
		private void UpdateBand(CommandBar commandBar)
		{
			if (this.IsHandleCreated)
			{
				this.BeginUpdate();

				for (int i = 0; i < this.commandBars.Count; i++)
				{
					NativeMethods.REBARBANDINFO rbbi = new NativeMethods.REBARBANDINFO();
					rbbi.cbSize = Marshal.SizeOf(typeof(NativeMethods.REBARBANDINFO));
					rbbi.fMask = NativeMethods.RBBIM_STYLE | NativeMethods.RBBIM_ID | NativeMethods.RBBIM_TEXT | NativeMethods.RBBIM_STYLE | NativeMethods.RBBIM_CHILD | NativeMethods.RBBIM_SIZE | NativeMethods.RBBIM_CHILDSIZE | NativeMethods.RBBIM_IDEALSIZE;
					NativeMethods.SendMessage(this.Handle, NativeMethods.RB_GETBANDINFO, i, ref rbbi);

					if (commandBar.Handle == rbbi.hwndChild)
					{
						if ((rbbi.cyMinChild != commandBar.Height) || (rbbi.cx != commandBar.Width) || (rbbi.cxIdeal != commandBar.Width))
						{
							rbbi.cyMinChild = commandBar.Height;
							rbbi.cx = commandBar.Width;
 							rbbi.cxIdeal = commandBar.Width;
							NativeMethods.SendMessage(this.Handle, NativeMethods.RB_SETBANDINFO, i, ref rbbi);
						}
					}
				}

				this.UpdateSize();

				this.EndUpdate();
			}
		}
コード例 #28
0
 internal CommandBarItemCollection(CommandBar commandBar)
 {
     this.commandBar = commandBar;
     this.items      = new ArrayList();
 }
コード例 #29
0
ファイル: Connect.cs プロジェクト: jmecosta/VSSonarAddin
        /// <summary>
        /// Adds an command button to Visual Studio for the give command.
        /// </summary>
        /// <param name="command"></param>
        /// <param name="cmdBar"></param>
        /// <param name="buttonStyle"></param>
        /// <returns></returns>
        private CommandBarButton AddCommandToCmdBar(Command command, CommandBar cmdBar, MsoButtonStyle buttonStyle)
        {
            CommandBarButton tempCmdBarButton;

            tempCmdBarButton = (CommandBarButton)command.AddControl(cmdBar, cmdBar.Controls.Count + 1);
            tempCmdBarButton.BeginGroup = true;
            tempCmdBarButton.Style = buttonStyle;

            return tempCmdBarButton;
        }
コード例 #30
0
 public int IndexOf(CommandBar commandBar)
 {
     return this.bands.IndexOf(commandBar);
 }
コード例 #31
0
ファイル: Plugin.cs プロジェクト: Nexuapex/niftyplugins
 public static bool HasCommand(CommandBar commandBar, string caption)
 {
     foreach(CommandBarControl control in commandBar.Controls)
     {
         if(control.Caption == caption)
             return true;
     }
     return false;
 }
コード例 #32
0
 public int IndexOf(CommandBar commandBar)
 {
     return(this.bands.IndexOf(commandBar));
 }
コード例 #33
0
ファイル: Plugin.cs プロジェクト: TwistedHope/gitextensions
 private bool HasCommand(CommandBar commandBar, string caption)
 {
     foreach (CommandBarControl control in commandBar.Controls)
     {
         if (control.Caption.Trim().Equals(caption.Trim(), StringComparison.CurrentCultureIgnoreCase))
         {
             return true;
         }
     }
     return false;
 }
コード例 #34
0
 public void Remove(CommandBar commandBar)
 {
     this.bands.Remove(commandBar);
     this.commandBarManager.UpdateBands();
 }
コード例 #35
0
ファイル: EventSink.cs プロジェクト: zi-yu/midgard
 private CommandBarControl GetControl(CommandBar bar, string tag)
 {
     Object missing = Missing.Value;
     return bar.FindControl(missing, missing, tag, missing, missing);
 }
コード例 #36
0
 public bool Contains(CommandBar commandBar)
 {
     return(this.bands.Contains(commandBar));
 }