Пример #1
0
        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");
            }
        }
Пример #2
0
		public FDMenus(IMainForm mainForm)
		{
			// modify the view menu
			CommandBarMenu viewMenu = mainForm.GetCBMenu("ViewMenu");
			View = new CommandBarButton("&Project Explorer");
			View.Image = Icons.Project.Img;
			viewMenu.Items.Add(View);

			// modify the tools menu - add a nice GUI classpath editor
			GlobalClasspaths = new CommandBarButton("&Global Classpaths...");
			GlobalClasspaths.Shortcut = Keys.F9 | Keys.Control;

			mainForm.IgnoredKeys.Add(GlobalClasspaths.Shortcut);

			CommandBarMenu toolsMenu = mainForm.GetCBMenu("ToolsMenu");
			toolsMenu.Items.AddSeparator();
			toolsMenu.Items.Add(GlobalClasspaths);

			ProjectMenu = new ProjectMenu();

			CommandBar mainMenu = mainForm.GetCBMainMenu();
			mainMenu.Items.Insert(5, ProjectMenu);

			RecentComboBox = RecentComboBox.Create();

			CommandBar toolBar = mainForm.GetCBToolbar();

			if (toolBar != null) // you might have turned off the toolbar
			{
				toolBar.Items.AddSeparator();
				toolBar.Items.Add(ProjectMenu.TestMovie);
				toolBar.Items.Add(RecentComboBox);
			}
		}
Пример #3
0
		public ProjectMenu()
		{
			NewProject = new CommandBarButton("&New Project..");
			NewProject.Image = Icons.NewProject.Img;

			OpenProject = new CommandBarButton("&Open Project..");

			CloseProject = new CommandBarButton("&Close Project");

			TestMovie = new CommandBarButton("&Test Movie");
			TestMovie.Image = Icons.GreenCheck.Img;

			BuildProject = new CommandBarButton("&Build Project");
			BuildProject.Image = Icons.Gear.Img;

			Properties = new CommandBarButton("&Properties");
			Properties.Image = Icons.Options.Img;

			base.Text = "&Project";
			base.Items.Add(NewProject);
			base.Items.Add(OpenProject);
			base.Items.Add(CloseProject);
			base.Items.AddSeparator();
			base.Items.Add(TestMovie);
			base.Items.Add(BuildProject);
			base.Items.AddSeparator();
			base.Items.Add(Properties);
		}
Пример #4
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);
			}
		}
Пример #5
0
        public static void SetButtonImage(CommandBarButton button, Bitmap image)
        {
            button.FaceId = 0;

            if (image != null)
            {
                image.MakeTransparent(Color.Transparent);
                Clipboard.SetDataObject(image, true);
                button.PasteFace();
            }
        }
Пример #6
0
        /**
         * Creates a button from the specified xml node
         */
        public CommandBarButton GetButton(XmlNode node)
        {
            CommandBarButton button = new CommandBarButton();

            if (this.HasAttribute(node, "label"))
            {
                button.Text = this.GetAttribute(node, "label");
            }
            if (this.HasAttribute(node, "image"))
            {
                string image = this.GetAttribute(node, "image");
                button.Image = this.Images.GetImage(Convert.ToInt16(image));
            }
            if (this.HasAttribute(node, "name"))
            {
                string name = this.GetAttribute(node, "name");
                button.Name = name;
            }
            if (this.HasAttribute(node, "enabled"))
            {
                string enabled = this.GetAttribute(node, "enabled");
                button.IsEnabled = Convert.ToBoolean(enabled);
            }
            if (this.HasAttribute(node, "visible"))
            {
                string visible = this.GetAttribute(node, "visible");
                button.IsVisible = Convert.ToBoolean(visible);
            }
            if (this.HasAttribute(node, "shortcut"))
            {
                string shortcut = this.GetAttribute(node, "shortcut");
                button.Shortcut = this.ToShortcut(shortcut);
            }
            if (this.HasAttribute(node, "propertychanged"))
            {
                string propertyChanged = this.GetAttribute(node, "propertychanged");
                button.PropertyChanged += this.ToChangedHandler(propertyChanged);
            }
            if (this.HasAttribute(node, "click"))
            {
                string handler = this.GetAttribute(node, "click");
                button.Click += this.ToClickHandler(handler);
            }
            if (this.HasAttribute(node, "tag"))
            {
                string tag = this.GetAttribute(node, "tag");
                button.Tag = tag;
            }
            this.Items.Add(button);
            this.Buttons.Add(button);
            return(button);
        }
Пример #7
0
        /**
         * Gets a button by name
         */
        public CommandBarButton GetCommandBarButton(string name)
        {
            int count = this.xmlBuilder.Buttons.Count;

            for (int i = 0; i < count; i++)
            {
                CommandBarButton button = (CommandBarButton)this.xmlBuilder.Buttons[i];
                if (button.Name == name)
                {
                    return(button);
                }
            }
            return(null);
        }
Пример #8
0
 /// <summary>
 /// 关于响应事件
 /// </summary>
 /// <param name="Ctrl"></param>
 /// <param name="CancelDefault"></param>
 public static void btnAbout_Click(CommandBarButton Ctrl, ref bool CancelDefault)
 {
     ThisAddIn.g_log.Info("operator:btnAboutClicked begin");
     try
     {
         AboutBox aboutBox = new AboutBox();
         aboutBox.ShowDialog();
     }
     catch (Exception ex)
     {
         ThisAddIn.g_log.Error(string.Format("open about failed, because {0}", ex.Message));
         MessageBox.Show(ex.Message);
     }
     ThisAddIn.g_log.Info("operator:btnAboutClicked end");
 }
Пример #9
0
 /// <summary>
 /// 会议设置响应事件
 /// </summary>
 /// <param name="Ctrl"></param>
 /// <param name="CancelDefault"></param>
 public static void btnConfSettings_Click(CommandBarButton Ctrl, ref bool CancelDefault)
 {
     ThisAddIn.g_log.Info("operator:btnConfSettingsClicked begin");
     try
     {
         VideoConfSettingsForm videoConfSettings = new VideoConfSettingsForm(null);
         videoConfSettings.ShowDialog();
     }
     catch (Exception ex)
     {
         ThisAddIn.g_log.Error("open VideoConfSettingsForm failed!");
         MessageBox.Show(ex.Message);
     }
     ThisAddIn.g_log.Info("operator:btnConfSettingsClicked end");
 }
Пример #10
0
		public TreeBar(FDMenus menus, ProjectContextMenu treeMenu)
		{
			this.menus = menus;
			this.treeMenu = treeMenu;

			Refresh = new CommandBarButton("Refresh");
			Refresh.Image = Icons.Refresh.Img;

			EnableTrace = new CommandBarCheckBox(Icons.Debug.Img,"Enable Trace");

			Items.Add(treeMenu.ShowHidden);
			Items.Add(Refresh);
			Items.Add(new CommandBarSeparator());
			Items.Add(menus.ProjectMenu.Properties);
			Items.Add(new CommandBarSeparator());
			Items.Add(EnableTrace);
		}
 public VSMenuCommand(VSMenu menu, string name, string displayName, string description)
 {
     this._menu = menu;
     this._name = name;
     this._displayName = displayName;
     this._description = description;
     object[] array = new object[0];
     Commands2 commands = (Commands2)menu.VSAddin.ApplicationObject.Commands;
     try
     {
         this._command = commands.AddNamedCommand2(menu.VSAddin.AddInInstance, name, displayName, description, true, 0, ref array, 3, 3, vsCommandControlType.vsCommandControlTypeButton);
     }
     catch
     {
         this._command = commands.Item(menu.VSAddin.AddInInstance.ProgID + "." + name, 0);
     }
     this._button = (CommandBarButton)this._command.AddControl(this._menu.Popup.CommandBar, 1);
 }
Пример #12
0
        public void Initialize(CommandBarControls menuControls)
        {
            _menu = menuControls.Add(MsoControlType.msoControlPopup, Temporary: true) as CommandBarPopup;
            _menu.Caption = RubberduckUI.RubberduckMenu_Refactor;

            _extractMethodButton = AddButton(_menu, RubberduckUI.RefactorMenu_ExtractMethod, false, OnExtractMethodButtonClick);
            SetButtonImage(_extractMethodButton, Resources.ExtractMethod_6786_32, Resources.ExtractMethod_6786_32_Mask);

            _renameButton = AddButton(_menu, RubberduckUI.RefactorMenu_Rename, false, OnRenameButtonClick);
            
            _reorderParametersButton = AddButton(_menu, RubberduckUI.RefactorMenu_ReorderParameters, false, OnReorderParametersButtonClick, Resources.ReorderParameters_6780_32);
            SetButtonImage(_reorderParametersButton, Resources.ReorderParameters_6780_32, Resources.ReorderParameters_6780_32_Mask);

            _removeParametersButton = AddButton(_menu, RubberduckUI.RefactorMenu_RemoveParameter, false, OnRemoveParameterButtonClick);
            SetButtonImage(_removeParametersButton, Resources.RemoveParameters_6781_32, Resources.RemoveParameters_6781_32_Mask);

            InitializeRefactorContextMenu();
        }
Пример #13
0
        public void OnProcessText(CommandBarButton ctrl, ref bool canceldefault)
        {
            var span = new Stopwatch();
            span.Start();

            _application.ScreenUpdating = false;
            var state = _application.ActiveWindow.View.ShowHiddenText;
            _application.ActiveWindow.View.ShowHiddenText = true;

            var changes = RemoveHidden() + RemoveFragments("{}");

            _application.ActiveWindow.View.ShowHiddenText = state;
            _application.ScreenUpdating = true;
            ClearSelection();

            span.Stop();
            var secs = span.ElapsedMilliseconds / 1000d;
            const string Msg = "Deleted {0} fragments\r\nTime spent: {1} sec";
            MessageBox.Show(string.Format(Msg, changes, secs), "Fragments operations");
        }
Пример #14
0
 /// <summary>
 /// 帮助响应事件
 /// </summary>
 /// <param name="Ctrl"></param>
 /// <param name="CancelDefault"></param>
 public static void btnHelp_Click(CommandBarButton Ctrl, ref bool CancelDefault)
 {
     ThisAddIn.g_log.Info("operator:btnHelpClicked begin");
     try
     {
         if (File.Exists(ThisAddIn.helpFilePath))
         {
             System.Diagnostics.Process.Start(ThisAddIn.helpFilePath);
         }
         else
         {
             ThisAddIn.g_log.Error(string.Format("Help .chm can not find."));
             //MessageBox.Show("Help .chm can not find.");
         }
     }
     catch (Exception ex)
     {
         ThisAddIn.g_log.Error(string.Format("Help .chm can not find, cause {0}", ex.Message));
         MessageBox.Show(ex.Message);
     }
     ThisAddIn.g_log.Info("operator:btnHelpClicked end");
 }
Пример #15
0
        private void InitializeRefactorContextMenu()
        {
            var beforeItem = IDE.CommandBars["Code Window"].Controls.Cast<CommandBarControl>().First(control => control.Id == 2529).Index;
            _refactorCodePaneContextMenu = IDE.CommandBars["Code Window"].Controls.Add(Type: MsoControlType.msoControlPopup, Temporary: true, Before:beforeItem) as CommandBarPopup;
            _refactorCodePaneContextMenu.BeginGroup = true;
            _refactorCodePaneContextMenu.Caption = RubberduckUI.RubberduckMenu_Refactor;

            _extractMethodContextButton = AddButton(_refactorCodePaneContextMenu, RubberduckUI.RefactorMenu_ExtractMethod, false, OnExtractMethodButtonClick);
            SetButtonImage(_extractMethodContextButton, Resources.ExtractMethod_6786_32, Resources.ExtractMethod_6786_32_Mask);

            _renameContextButton = AddButton(_refactorCodePaneContextMenu, RubberduckUI.RefactorMenu_Rename, false, OnRenameButtonClick);

            _reorderParametersContextButton = AddButton(_refactorCodePaneContextMenu, RubberduckUI.RefactorMenu_ReorderParameters, false, OnReorderParametersButtonClick);
            SetButtonImage(_reorderParametersContextButton, Resources.ReorderParameters_6780_32, Resources.ReorderParameters_6780_32_Mask);

            _removeParametersContextButton = AddButton(_refactorCodePaneContextMenu, RubberduckUI.RefactorMenu_RemoveParameter, false, OnRemoveParameterButtonClick);
            SetButtonImage(_removeParametersContextButton, Resources.RemoveParameters_6781_32, Resources.RemoveParameters_6781_32_Mask);

            InitializeFindReferencesContextMenu(); //todo: untangle that mess...
            InitializeFindImplementationsContextMenu(); //todo: untangle that mess...
            InitializeFindSymbolContextMenu();
        }
Пример #16
0
        private void AddMenuBar()
        {
            try
            {
                Office.CommandBar menubar = (Office.CommandBar)Application.CommandBars.ActiveMenuBar;

                // Add the menu.
                menuCommand = (Office.CommandBarButton)menubar.Controls.Add(
                            Office.MsoControlType.msoControlButton, missing, missing, missing, true);
                menuCommand.Style = MsoButtonStyle.msoButtonIconAndWrapCaptionBelow;
                menuCommand.Caption = Resources.ItemMenu;
                menuCommand.Tag = "200";
                menuCommand.FaceId = 65;
                menuCommand.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(
                            menuCommand_Click);

                this.Enabled = false;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Пример #17
0
		public ProjectContextMenu(FDMenus menus)
		{
			this.menus = menus;

			AddNewClass = CreateButton("New &Class..",Icons.ActionScript.Img);
			AddNewXml = CreateButton("New &Xml File..",Icons.XmlFile.Img);
			AddNewFile = CreateButton("New &File..",Icons.AddFile.Img);
			AddNewFolder = CreateButton("New F&older",Icons.Folder.Img);
			AddLibraryAsset = CreateButton("Library &Asset..",Icons.ImageResource.Img);
			AddExistingFile = CreateButton("&Existing File..",Icons.HiddenFile.Img);
			Open = CreateButton("&Open",Icons.OpenFile.Img);
			Insert = CreateButton("&Insert Into Document",Icons.EditFile.Img);
			Execute = CreateButton("&Execute");
			Cut = CreateButton("Cu&t",Icons.Cut.Img);
			Copy = CreateButton("Cop&y");
			Paste = CreateButton("&Paste",Icons.Paste.Img);
			Delete = CreateButton("&Delete",Icons.Delete.Img);
			Rename = CreateButton("Rena&me");
			AlwaysCompile = new CommandBarCheckBox("Always &Compile");
			AddLibrary = new CommandBarCheckBox("Add to &Library");
			LibraryOptions = CreateButton("&Options...",Icons.Options.Img);
			Hide = new CommandBarCheckBox("&Hide File");
			ShowHidden = new CommandBarCheckBox(Icons.HiddenFile.Img,"&Show Hidden Items");
			NothingToDo = new CommandBarButton("Not a valid group");
			NothingToDo.IsEnabled = false;
			NoProjectOutput = new CommandBarButton("(Project output not built)");
			NoProjectOutput.IsEnabled = false;

			AddMenu = new CommandBarMenu("&Add");
			AddMenu.Items.Add(AddNewClass);
			AddMenu.Items.Add(AddNewXml);
			AddMenu.Items.Add(AddNewFile);
			AddMenu.Items.Add(AddNewFolder);
			AddMenu.Items.AddSeparator();
			AddMenu.Items.Add(AddLibraryAsset);
			AddMenu.Items.Add(AddExistingFile);
		}
Пример #18
0
        /// <summary>
        /// Releases unmanaged resources help by the event sink.
        /// </summary>
        public void Dispose()
        {
            foreach (Event e in _events)
            {
                e.Delete();
                Marshal.ReleaseComObject(e);
            }

            _events = null;

            string commandBarName = Resources.GetString(ResourceTokens.CommandBarName);
            CommandBar commandBar = VisioUtils.GetCommandBar(Application, commandBarName);

            if (commandBar != null)
            {
                commandBar.Delete();
                Marshal.ReleaseComObject(_exportXMLButton);
                Marshal.ReleaseComObject(_validateButton);

                _validateButton = null;
                _exportXMLButton = null;
            }
        }
Пример #19
0
        /// <summary>
        /// Creates a command-bar.
        /// </summary>
        public void CreateCommandBar()
        {
            string commandBarName = Resources.GetString(ResourceTokens.CommandBarName);
            Object missing = System.Reflection.Missing.Value;
            CommandBar commandBar = VisioUtils.GetCommandBar(Application, commandBarName);

            if (commandBar != null)
                return;

            //adicionar a barra ao Visio
            CommandBars applicationCommandBars = (CommandBars)Application.CommandBars;
            commandBar = applicationCommandBars.Add(commandBarName, MsoBarPosition.msoBarTop, false, true);

            // Validate transition Button
            _validateButton = (CommandBarButton)commandBar.Controls.Add(MsoControlType.msoControlButton, missing, missing, 1, false);
            _validateButton.Click += new _CommandBarButtonEvents_ClickEventHandler(this.validateTransition_Click);
            SetButtonProperties(_validateButton, ResourceTokens.ButtonValidate, ResourceTokens.ButtonValidateTooltip, TagValidateButton, "Validate.bmp", "Validate-Mask.bmp");

            // Export transition
            _exportXMLButton = (CommandBarButton)commandBar.Controls.Add(MsoControlType.msoControlButton, missing, missing, 2, false);
            _exportXMLButton.Click += new _CommandBarButtonEvents_ClickEventHandler(this.exportTransition_Click);
            SetButtonProperties(_exportXMLButton, ResourceTokens.ButtonExport, ResourceTokens.ButtonExportTooltip, TagExportXMLButton, "Export.bmp", "Export-Mask.bmp");

            // User cannot customize our commandbar
            commandBar.Protection = MsoBarProtection.msoBarNoCustomize;

            // Toolbar is only visible when viewing the drawing
            commandBar.Context = Convert.ToString((short)VisUIObjSets.visUIObjSetDrawing, CultureInfo.InvariantCulture) + "*";

            _application.DocumentCreated += new EApplication_DocumentCreatedEventHandler(_application_DocumentCreated);
            _application.DocumentOpened += new EApplication_DocumentOpenedEventHandler(_application_DocumentOpened);
            _application.BeforeDocumentClose += new EApplication_BeforeDocumentCloseEventHandler(_application_BeforeDocumentClose);
            _application.WindowActivated += new EApplication_WindowActivatedEventHandler(_application_WindowActivated);
            _application.ViewChanged += new EApplication_ViewChangedEventHandler(_application_ViewChanged);
        }
Пример #20
0
 private void Settings_Click(CommandBarButton cmdBarbutton, ref bool cancel)
 {
     Settings DialogSettings = new Settings(app);
     DialogSettings.ShowDialog();
     onDocumentLoad();
 }
Пример #21
0
 private void Search_Click(CommandBarButton cmdBarbutton, ref bool cancel)
 {
     DialogSearch = new Search(this);
     DialogSearch.ShowDialog();
     onDocumentLoad();
 }
Пример #22
0
        private void Save_Click(CommandBarButton cmdBarbutton, ref bool cancel)
        {
            if (app.ActiveWorkbook.FullName.StartsWith(getCacheFolder()))
            {
                makePut();
                return;
            }

            DialogSave = new NSave(this);
            DialogSave.setFileTypes(getFileTypes());
            DialogSave.ShowDialog();
        }
Пример #23
0
 private void SaveAs_Click(CommandBarButton cmdBarbutton, ref bool cancel)
 {
     DialogSave = new NSave(this);
     DialogSave.setFileTypes(getFileTypes());
     DialogSave.ShowDialog();
 }
Пример #24
0
 private void Open_Click(CommandBarButton cmdBarbutton, ref bool cancel)
 {
     DialogOpen = new NOpen(this);
     DialogOpen.ShowDialog();
     onDocumentLoad();
 }
Пример #25
0
 private void About_Click(CommandBarButton cmdBarbutton, ref bool cancel)
 {
     AboutBox AboutBox = new AboutBox(app);
     AboutBox.ShowDialog();
 }
Пример #26
0
        public void OnStartupComplete(ref System.Array custom)
        {
            CommandBars oCommandBars;
            CommandBar oStandardBar;

            object omissing = System.Reflection.Missing.Value;

            Thread.Sleep(50);

            app = (Microsoft.Office.Interop.Excel._Application)applicationObject;

            try
            {
                oCommandBars = (CommandBars)applicationObject.GetType().InvokeMember("CommandBars", BindingFlags.GetProperty, null, applicationObject, null);
            }
            catch (Exception)
            {
                return;
            }

            // Set up a custom button on the "Standard" commandbar.
            try
            {
                oStandardBar = oCommandBars["Worksheet Menu Bar"];
            }
            catch (Exception)
            {
                return;
            }

            CommandBarControls controls = oStandardBar.Controls;

            // remove old menus...
            foreach (CommandBarControl control in controls)
            {
                String caption = control.Caption;

                if (caption.EndsWith("Remote Documents") || caption.EndsWith("Remote documents"))
                {
                    control.Delete(null);
                }
            }

            // In case the button was not deleted, use the exiting one.
            try
            {
                eXoMenu = (CommandBarPopup)oStandardBar.Controls["Remote documents"];
                Open = (CommandBarButton)eXoMenu.Controls["Open"];
                Save = (CommandBarButton)eXoMenu.Controls["Save"];
                SaveAs = (CommandBarButton)eXoMenu.Controls["SaveAs"];
                Search = (CommandBarButton)eXoMenu.Controls["Search"];
                Settings = (CommandBarButton)eXoMenu.Controls["Settings"];
                About = (CommandBarButton)eXoMenu.Controls["About"];
            }

            catch (Exception)
            {
                eXoMenu = (CommandBarPopup)oStandardBar.Controls.Add(MsoControlType.msoControlPopup, omissing, omissing, omissing, true);
                eXoMenu.Caption = "Remote Documents";
                eXoMenu.Tag = eXoMenu.Caption;

                Open = (CommandBarButton)eXoMenu.Controls.Add(1, omissing, omissing, omissing, omissing);
                Open.Caption = "Open...";
                Open.Tag = Open.Caption;

                Save = (CommandBarButton)eXoMenu.Controls.Add(1, omissing, omissing, omissing, omissing);
                Save.Caption = "Save";
                Save.Tag = Save.Caption;

                SaveAs = (CommandBarButton)eXoMenu.Controls.Add(1, omissing, omissing, omissing, omissing);
                SaveAs.Caption = "Save As...";
                SaveAs.Tag = SaveAs.Caption;

                Search = (CommandBarButton)eXoMenu.Controls.Add(1, omissing, omissing, omissing, omissing);
                Search.Caption = "Search...";
                Search.Tag = Search.Caption;

                Settings = (CommandBarButton)eXoMenu.Controls.Add(1, omissing, omissing, omissing, omissing);
                Settings.Caption = "Settings...";
                Settings.Tag = Settings.Caption;

                About = (CommandBarButton)eXoMenu.Controls.Add(1, omissing, omissing, omissing, omissing);
                About.Caption = "About...";
                About.Tag = About.Caption;
            }
            Open.Visible = true;
            Open.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.Open_Click);

            Save.Visible = true;
            Save.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.Save_Click);

            SaveAs.Visible = true;
            SaveAs.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.SaveAs_Click);

            Search.Visible = true;
            Search.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.Search_Click);

            Settings.Visible = true;
            Settings.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.Settings_Click);

            About.Visible = true;
            About.Click += new Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.About_Click);

            object oName = applicationObject.GetType().InvokeMember("Name", BindingFlags.GetProperty, null, applicationObject, null);
            oStandardBar = null;
            oCommandBars = null;

            clearRepository();
        }
Пример #27
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)
        {
            Mfconsulting.Vsprj2make.RegistryHelper regHlpr = new RegistryHelper();
            string[] monoVersions = regHlpr.GetMonoVersions();

            _applicationObject = (DTE2)application;
            _addInInstance = (AddIn)addInInst;
            int selectedIndexForComboBox = 1;

            OutputWindow outputWindow = (OutputWindow)_applicationObject.Windows.Item(Constants.vsWindowKindOutput).Object;
            outputWindowPane = outputWindow.OutputWindowPanes.Add("Monoaddin Messages");

            if(connectMode == ext_ConnectMode.ext_cm_AfterStartup)
            {
                object []contextGUIDS = new object[] { };
                Commands2 commands = (Commands2)_applicationObject.Commands;
                string toolsMenuName;

                _CommandBars commandBars = (Microsoft.VisualStudio.CommandBars._CommandBars)_applicationObject.CommandBars;
                CommandBar cmdBarMonoBarra;
                CommandBarPopup popMenu;	// Prj2Make popupmenu
                CommandBarPopup popMenu2;	// Explorer Current Project

                try
                {
                    //If you would like to move the command to a different menu, change the word "Tools" to the
                    //  English version of the menu. This code will take the culture, append on the name of the menu
                    //  then add the command to that menu. You can find a list of all the top-level menus in the file
                    //  CommandBar.resx.
                    ResourceManager resourceManager = new ResourceManager("monoaddin.CommandBar", Assembly.GetExecutingAssembly());
                    CultureInfo cultureInfo = new System.Globalization.CultureInfo(_applicationObject.LocaleID);
                    string resourceName = String.Concat(cultureInfo.TwoLetterISOLanguageName, "Tools");
                    toolsMenuName = resourceManager.GetString(resourceName);
                }
                catch
                {
                    //We tried to find a localized version of the word Tools, but one was not found.
                    //  Default to the en-US word, which may work for the current culture.
                    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];
                CommandBarControls commandBarControls;
                commandBarControls = ((CommandBarPopup)toolsControl).Controls;

                // Create Makefile
                Command command1 = null;
                // Generate MonoDevelop files
                Command command2 = null;
                // Generate a distribution unit
                Command command3 = null;
                // Import MonoDevelop Solutions
                Command command4 = null;
                // Run on Mono
                Command command5 = null;
                // vsprj2make Options
                Command command6 = null;
                // Explore current solution
                Command command7 = null;
                // Explore current Project
                Command command8 = null;

                // ------------- Add Pop-up menu ----------------
                popMenu2 = (CommandBarPopup)commandBarControls.Add(
                    MsoControlType.msoControlPopup,
                    System.Reflection.Missing.Value, // Object ID
                    System.Reflection.Missing.Value, // Object parameters
                    1, // Object before
                    true
                    );

                popMenu2.Caption = "&Windows Explore";

                // ------------- Add Pop-up menu ----------------
                popMenu = (CommandBarPopup)commandBarControls.Add(
                    MsoControlType.msoControlPopup,
                    System.Reflection.Missing.Value, // Object ID
                    System.Reflection.Missing.Value, // Object parameters
                    1, // Object before
                    true
                    );

                popMenu.Caption = "Prj&2Make";

                //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 the create makefile command -- command1
                    //command1 = commands.AddNamedCommand2(
                    //    _addInInstance, "CreateMake", "Create &Makefile",
                    //    "Generate Makefile", true, 59, ref contextGUIDS,
                    //    (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled,
                    //    (int)vsCommandStyle.vsCommandStylePictAndText,
                    //    vsCommandControlType.vsCommandControlTypeButton
                    //);

                    // Add the create makefile command -- command1
                    command1 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "CreateMake",
                        "Create &Makefile",
                        "Generate Makefile",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command1 == null) && (popMenu != null))
                    {
                        command1 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.CreateMake");
                        command1.AddControl(popMenu.CommandBar, 1);
                    }

                }
                catch (System.ArgumentException exc)
                {
                    //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.
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the GenMDFiles command -- command2
                    command2 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "GenMDFiles",
                        "Create Mono&Develop Solution",
                        "Generate MonoDevelop Solution",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command2 == null) && (popMenu != null))
                    {
                        command2 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.GenMDFiles");
                        command2.AddControl(popMenu.CommandBar, 2);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the generate a dist unit command -- command3
                    command3 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "GenDistUnit",
                        "Generate Distribution &Unit",
                        "Generates a distribution unit (zip file)",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command3 == null) && (popMenu != null))
                    {
                        command3 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.GenDistUnit");
                        command3.AddControl(popMenu.CommandBar, 3);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the ImportMD Solution command -- command4
                    command4 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "PrjxToCsproj",
                        "&Import MonoDevelop Solution...",
                        "Imports a MonoDevelop Solution",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command4 == null) && (popMenu != null))
                    {
                        command4 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.PrjxToCsproj");
                        command4.AddControl(popMenu.CommandBar, 4);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the Run on Mono command -- command5
                    command5 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "RunOnMono",
                        "&Run on Mono",
                        "Run solution on mono",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command5 == null) && (popMenu != null))
                    {
                        command5 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.RunOnMono");
                        command5.AddControl(popMenu.CommandBar, 5);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the Options command -- command6
                    command6 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "Options",
                        "&Options...",
                        "Options for prj2make Add-in",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command6 == null) && (popMenu != null))
                    {
                        command6 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.Options");
                        command6.AddControl(popMenu.CommandBar, 6);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the ExploreCurrSln command -- command7
                    command7 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "ExploreCurrSln",
                        "Current &Solution",
                        "Explore the current solution",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command7 == null) && (popMenu != null))
                    {
                        command7 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.ExploreCurrSln");
                        command7.AddControl(popMenu2.CommandBar, 1);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                try
                {
                    // Add the ExploreCurrDoc command -- command8
                    command8 = CreateNamedCommand(
                        _addInInstance,
                        commands,
                        "ExploreCurrDoc",
                        "Current &Document",
                        "Explore the current Document",
                        ref contextGUIDS
                        );

                    //Add a control for the command to the tools menu:
                    if ((command8 == null) && (popMenu != null))
                    {
                        command8 = GetExistingNamedCommand(commands, "Mfconsulting.Vsprj2make.Connect.ExploreCurrDoc");
                        command8.AddControl(popMenu2.CommandBar, 2);
                    }
                }
                catch (System.ArgumentException exc)
                {
                    Trace.WriteLine(String.Format("Error during OnConnect of Add-in:\n {0}", exc.Message));
                }

                // Mono Toolbar
                CommandBar cmdBarBuild = (CommandBar)commandBars["Build"];

                try
                {
                    cmdBarMonoBarra = (CommandBar)commandBars["MonoBarra"];
                }
                catch (Exception)
                {
                    commands.AddCommandBar("MonoBarra",
                        vsCommandBarType.vsCommandBarTypeToolbar,
                        cmdBarBuild,
                        1
                        );

                    cmdBarMonoBarra = (CommandBar)commandBars["MonoBarra"];
                    cmdBarMonoBarra.Visible = true;
                }

                if (testInMonoCommandBarButton == null)
                {

                    // Create the Run on Mono Button
                    testInMonoCommandBarButton = (CommandBarButton)cmdBarMonoBarra.Controls.Add(
                        Microsoft.VisualStudio.CommandBars.MsoControlType.msoControlButton,
                        System.Reflection.Missing.Value,
                        System.Reflection.Missing.Value,
                        1,
                        false
                        );

                    testInMonoCommandBarButton.Caption = "Run on &Mono";
                    testInMonoCommandBarButton.DescriptionText = "Run solution with the mono runtime";
                    testInMonoCommandBarButton.TooltipText = "Run on mono";
                    testInMonoCommandBarButton.ShortcutText = "Run on &Mono";
                    testInMonoCommandBarButton.Style = MsoButtonStyle.msoButtonCaption;
                    testInMonoCommandBarButton.Click += new _CommandBarButtonEvents_ClickEventHandler(testInMonoCommandBarButton_Click);
                }

                if (versionComboBox == null)
                {

                    // Create the combobox
                    versionComboBox = (CommandBarComboBox)cmdBarMonoBarra.Controls.Add(
                        Microsoft.VisualStudio.CommandBars.MsoControlType.msoControlDropdown,
                        System.Reflection.Missing.Value,
                        System.Reflection.Missing.Value,
                        2,
                        false
                        );

                    for (int i = 0; i < monoVersions.Length; i++)
                    {
                        versionComboBox.AddItem(monoVersions[i], i + 1);
                        if (monoVersions[i].CompareTo(regHlpr.GetDefaultClr()) == 0)
                        {
                            selectedIndexForComboBox = i + 1;
                        }
                    }

                    versionComboBox.Change += new _CommandBarComboBoxEvents_ChangeEventHandler(versionComboBox_Change);

                    // Select the active index based on
                    // the current mono version
                    versionComboBox.ListIndex = selectedIndexForComboBox;
                }
            }
        }
Пример #28
0
        /// <summary>This method sets the button properties for the
        /// command bar button that is passed in.</summary>
        /// <param name="button">Command bar button for which the
        /// properties are to be set</param>
        /// <param name="caption">Caption of the button.</param>
        /// <param name="tooltip">Tool tip of the button.</param>
        /// <param name="tag">Tag of the button.</param>
        /// <param name="iconPath">Filename of the icon to be set.</param>
        /// <param name="maskPath">Filename of the mask to be set.</param>
        private void SetButtonProperties(
            CommandBarButton button,
            string caption,
            string tooltip,
            string tag,
            string iconPath,
            string maskPath)
        {
            // Use the Tag property for context switching and for
            // use with the FindControl method.
            button.Tag = tag;

            button.Caption = Resources.GetString(caption);
            button.TooltipText = Resources.GetString(tooltip);
            button.Picture = Resources.GetPicture(iconPath);
            button.Mask = Resources.GetPicture(maskPath);
            button.Enabled = false;
        }
Пример #29
0
        private void validateTransition_Click(CommandBarButton sender, ref bool CancelDefault)
        {
            _forceFormChange = false;
            if (Application.ActivePage == null)
                return;

            try
            {
                Midgard.Interop.Export.UiProcessExporter exporter = new Midgard.Interop.Export.UiProcessExporter();
                exporter.ValidatePage(Application.ActivePage);
            }
            catch (Exception ex)
            {
                ESIMessageBox.ShowError(ex);
            }
        }
Пример #30
0
        private void Open_Click(CommandBarButton cmdBarbutton, ref bool cancel)
        {
            isNeedCompare = false;

            DialogOpen = new NOpen(this);
            DialogOpen.ShowDialog();

            if (isNeedCompare)
            {
                onDocumentCompare();
            }
            else
            {
                onDocumentLoad();
            }
        }
Пример #31
0
 private void testInMonoCommandBarButton_Click(CommandBarButton Ctrl, ref bool CancelDefault)
 {
     TestInMono();
 }
Пример #32
0
        public void OnBeginShutdown(ref System.Array custom)
        {
            object omissing = System.Reflection.Missing.Value;

            Open.Delete(omissing);
            Open = null;

            eXoMenu.Delete(omissing);
            eXoMenu = null;

            Search.Delete(omissing);
            Search = null;
            Settings.Delete(omissing);
            Save.Delete(omissing);
        }