public CalDavSynchronizerToolBar (Application application, ComponentContainer componentContainer, object missing)
    {
      _componentContainer = componentContainer;

      var toolBar = application.ActiveExplorer().CommandBars.Add ("CalDav Synchronizer", MsoBarPosition.msoBarTop, false, true);

      var toolBarBtnOptions = (CommandBarButton) toolBar.Controls.Add (1, missing, missing, missing, missing);
      toolBarBtnOptions.Style = MsoButtonStyle.msoButtonIconAndCaption;
      toolBarBtnOptions.Caption = "Options";
      toolBarBtnOptions.FaceId = 222; // builtin icon: hand hovering above a property list
      toolBarBtnOptions.Tag = "View or set CalDav Synchronizer options";

      toolBarBtnOptions.Click += ToolBarBtn_Options_OnClick;

      _toolBarBtnSyncNow = (CommandBarButton) toolBar.Controls.Add (1, missing, missing, missing, missing);
      _toolBarBtnSyncNow.Style = MsoButtonStyle.msoButtonIconAndCaption;
      _toolBarBtnSyncNow.Caption = "Synchronize";
      _toolBarBtnSyncNow.FaceId = 107; // builtin icon: lightning hovering above a calendar table
      _toolBarBtnSyncNow.Tag = "Synchronize now";
      _toolBarBtnSyncNow.Click += ToolBarBtn_SyncNow_OnClick;

      var toolBarBtnAboutMe = (CommandBarButton) toolBar.Controls.Add (1, missing, missing, missing, missing);
      toolBarBtnAboutMe.Style = MsoButtonStyle.msoButtonIconAndCaption;
      toolBarBtnAboutMe.Caption = "About";
      toolBarBtnAboutMe.FaceId = 487; // builtin icon: blue round sign with "i" letter
      toolBarBtnAboutMe.Tag = "About CalDav Synchronizer";
      toolBarBtnAboutMe.Click += ToolBarBtn_About_OnClick;

      toolBar.Visible = true;
    }
 private void ToolBarBtn_About_OnClick (CommandBarButton Ctrl, ref bool CancelDefault)
 {
   using (var aboutForm = new AboutForm())
   {
     aboutForm.ShowDialog();
   }
 }
 private void _statusButton_Click(CommandBarButton Ctrl, ref bool CancelDefault)
 {
     if (_state.Status == ParserState.Error)
     {
         _command.Execute(null);
     }
 }
Example #4
0
        /// <summary>
        /// Creates the option button.
        /// </summary>
        /// <param name="manager">The manager.</param>
        public static void CreateButtons(SyncManager manager)
        {
            RemoveButtons();
            syncManager = manager;

            var missing = Type.Missing;
            var menubar = ApplicationData.Application.ActiveExplorer().CommandBars.ActiveMenuBar;

            var newMenuBar = (CommandBarPopup)menubar.Controls.Add(MsoControlType.msoControlPopup, missing, missing, missing, false);
            if (newMenuBar != null)
            {
                newMenuBar.Caption = "GoogleSync";
                newMenuBar.Tag = "GoogleSync";

                syncButton = (CommandBarButton)newMenuBar.Controls.Add(MsoControlType.msoControlButton, missing, missing, 1, true);
                syncButton.Style = MsoButtonStyle.msoButtonCaption;
                syncButton.Caption = "Sync now!";
                syncButton.Click += syncButton_Click;

                optionsButton = (CommandBarButton)newMenuBar.Controls.Add(MsoControlType.msoControlButton, missing, missing, missing, true);
                optionsButton.Style = MsoButtonStyle.msoButtonCaption;
                optionsButton.Caption = "Options";
                optionsButton.Click += optionsButton_Click;

                newMenuBar.Visible = true;
            }
        }
        public void Initialize()
        {
            var beforeItem = _vbe.CommandBars["Project Window"].Controls.Cast<CommandBarControl>().First(control => control.Id == 2578).Index;

            _findAllReferences = (CommandBarButton)_vbe.CommandBars["Project Window"].Controls.Add(Type: MsoControlType.msoControlButton, Temporary: true, Before: beforeItem);
            _findAllReferences.Caption = RubberduckUI.CodeExplorer_FindAllReferencesText;
            _findAllReferences.BeginGroup = true;
            _findAllReferences.Click += FindAllReferences_Click;

            _findAllImplementations = (CommandBarButton)_vbe.CommandBars["Project Window"].Controls.Add(Type: MsoControlType.msoControlButton, Temporary: true, Before: beforeItem + 1);
            _findAllImplementations.Caption = RubberduckUI.CodeExplorer_FindAllImplementationsText;
            _findAllImplementations.Click += FindAllImplementations_Click;

            _rename = (CommandBarButton)_vbe.CommandBars["Project Window"].Controls.Add(Type: MsoControlType.msoControlButton, Temporary: true, Before: beforeItem + 2);
            _rename.Caption = RubberduckUI.RefactorMenu_Rename;
            _rename.Click += Rename_Click;

            _inspect = (CommandBarButton)_vbe.CommandBars["Project Window"].Controls.Add(Type: MsoControlType.msoControlButton, Temporary: true, Before: beforeItem + 3);
            _inspect.Caption = RubberduckUI.Inspect;
            _inspect.Click += Inspect_Click;

            _runAllTests = (CommandBarButton)_vbe.CommandBars["Project Window"].Controls.Add(Type: MsoControlType.msoControlButton, Temporary: true, Before: beforeItem + 4);
            _runAllTests.Caption = RubberduckUI.CodeExplorer_RunAllTestsText;
            _runAllTests.Click += RunAllTests_Click;
        }
 public void Initialize()
 {
     var beforeItem = _vbe.CommandBars["MSForms Control"].Controls.Cast<CommandBarControl>().First(control => control.Id == 2558).Index;
     _rename = _vbe.CommandBars["MSForms Control"].Controls.Add(Type: MsoControlType.msoControlButton, Temporary: true, Before: beforeItem) as CommandBarButton;
     _rename.BeginGroup = true;
     _rename.Caption = RubberduckUI.FormContextMenu_Rename;
     _rename.Click += OnRenameButtonClick;
 }
    public CalDavSynchronizerToolBar (Explorer explorer, ComponentContainer componentContainer, object missing, bool wireClickEvents)
    {
      _componentContainer = componentContainer;

      _toolBar = explorer.CommandBars.Add("CalDav Synchronizer", MsoBarPosition.msoBarTop, false, true);

      _toolBarBtnOptions = (CommandBarButton) _toolBar.Controls.Add (1, missing, missing, missing, missing);
      _toolBarBtnOptions.Style = MsoButtonStyle.msoButtonIconAndCaption;
      _toolBarBtnOptions.Caption = "Synchronization Profiles";
      _toolBarBtnOptions.FaceId = 222; // builtin icon: hand hovering above a property list
      _toolBarBtnOptions.Tag = "View or set CalDav Synchronization Profiles";
      if(wireClickEvents)
        _toolBarBtnOptions.Click += ToolBarBtn_Options_OnClick;


      _toolBarBtnGeneralOptions = (CommandBarButton) _toolBar.Controls.Add (1, missing, missing, missing, missing);
      _toolBarBtnGeneralOptions.Style = MsoButtonStyle.msoButtonIconAndCaption;
      _toolBarBtnGeneralOptions.Caption = "General Options";
      _toolBarBtnGeneralOptions.FaceId = 222; // builtin icon: hand hovering above a property list
      _toolBarBtnGeneralOptions.Tag = "View or set CalDav Synchronizer general options";
      if (wireClickEvents)
        _toolBarBtnGeneralOptions.Click += ToolBarBtn_GeneralOptions_OnClick;

      _toolBarBtnSyncNow = (CommandBarButton) _toolBar.Controls.Add (1, missing, missing, missing, missing);
      _toolBarBtnSyncNow.Style = MsoButtonStyle.msoButtonIconAndCaption;
      _toolBarBtnSyncNow.Caption = "Synchronize";
      _toolBarBtnSyncNow.FaceId = 107; // builtin icon: lightning hovering above a calendar table
      _toolBarBtnSyncNow.Tag = "Synchronize now";
      if (wireClickEvents)
        _toolBarBtnSyncNow.Click += ToolBarBtn_SyncNow_OnClick;

      _toolBarBtnAboutMe = (CommandBarButton) _toolBar.Controls.Add (1, missing, missing, missing, missing);
      _toolBarBtnAboutMe.Style = MsoButtonStyle.msoButtonIconAndCaption;
      _toolBarBtnAboutMe.Caption = "About";
      _toolBarBtnAboutMe.FaceId = 487; // builtin icon: blue round sign with "i" letter
      _toolBarBtnAboutMe.Tag = "About CalDav Synchronizer";
      if (wireClickEvents)
        _toolBarBtnAboutMe.Click += ToolBarBtn_About_OnClick;

      _toolBarBtnReports = (CommandBarButton) _toolBar.Controls.Add(1, missing, missing, missing, missing);
      _toolBarBtnReports.Style = MsoButtonStyle.msoButtonIconAndCaption;
      _toolBarBtnReports.Caption = "Reports";
      _toolBarBtnReports.FaceId = 433; // builtin icon: statistics
      _toolBarBtnReports.Tag = "Show reports of last sync runs";
      if (wireClickEvents)
        _toolBarBtnReports.Click += ToolBarBtn_Reports_OnClick;

      _toolBarBtnStatus = (CommandBarButton) _toolBar.Controls.Add (1, missing, missing, missing, missing);
      _toolBarBtnStatus.Style = MsoButtonStyle.msoButtonIconAndCaption;
      _toolBarBtnStatus.Caption = "Status";
      _toolBarBtnStatus.FaceId = 433; // builtin icon: statistics
      _toolBarBtnStatus.Tag = "Show  syncronization status";
      if (wireClickEvents)
        _toolBarBtnStatus.Click += ToolBarBtn_Status_OnClick;

      _toolBar.Visible = true;
    }
Example #8
0
 /// <summary>
 /// Adds the "Visualize in WWT" button to the given Command bar of Excel.
 /// </summary>
 /// <param name="commandBarName">Command bar name</param>
 private void AddCommandBarButton(string commandBarName)
 {
     cellVisualizeMenu         = (CommandBarButton)ThisAddIn.ExcelApplication.CommandBars[commandBarName].Controls.Add(MsoControlType.msoControlButton, Temporary: true);
     cellVisualizeMenu.Style   = MsoButtonStyle.msoButtonCaption;
     cellVisualizeMenu.Caption = Properties.Resources.VisualizeMenuCaption;
     cellVisualizeMenu.Tag     = Properties.Resources.VisualizeMenuTag;
     cellVisualizeMenu.Visible = true;
     cellVisualizeMenu.Click  += OnVisualizeMenuClick;
 }
Example #9
0
        public void Initialize(CommandBarControls menuControls)
        {
            var menu = menuControls.Add(MsoControlType.msoControlPopup, Temporary: true) as CommandBarPopup;

            menu.Caption = "Te&st";

            _windowsTestExplorerButton = AddButton(menu, "&Test Explorer", false, new CommandBarButtonClickEvent(OnTestExplorerButtonClick), Resources.TestManager_8590_32);
            _runAllTestsButton         = AddButton(menu, "&Run All Tests", true, new CommandBarButtonClickEvent(OnRunAllTestsButtonClick), Resources.AllLoadedTests_8644_24);
        }
Example #10
0
 void OnButtonClick(CommandBarButton ctrl, ref bool cancelDefault)
 {
     if ((DateTime.Now - lastClick) < TimeSpan.FromSeconds(3))
     {
         return;
     }
     RaiseClickEvent();
     lastClick = DateTime.Now;
 }
Example #11
0
        private void OnRenameButtonClick(CommandBarButton Ctrl, ref bool CancelDefault)
        {
            if (IDE.ActiveCodePane == null)
            {
                return;
            }

            Rename();
        }
Example #12
0
        private void InitializeFindSymbolContextMenu()
        {
            var beforeItem = IDE.CommandBars["Code Window"].Controls.Cast <CommandBarControl>().First(control => control.Id == 2529).Index;

            _findSymbolContextMenu = IDE.CommandBars["Code Window"].Controls.Add(Type: MsoControlType.msoControlButton, Temporary: true, Before: beforeItem) as CommandBarButton;
            SetButtonImage(_findSymbolContextMenu, Resources.FindSymbol_6263_32, Resources.FindSymbol_6263_32_Mask);
            _findSymbolContextMenu.Caption = RubberduckUI.ContextMenu_FindSymbol;
            _findSymbolContextMenu.Click  += FindSymbolContextMenuClick;
        }
Example #13
0
        private void olustur()
        {
            const string vsStandardCommandbarName = "Standard";
            Command      myCommand = null;

            object[] contextUiGuids = new object[] { };

            try
            {
                // Try to retrieve the command, just in case it was already created, ignoring the
                // exception that would happen if the command was not created yet.
                try
                {
                    myCommand = _applicationObject.Commands.Item(_addInInstance.ProgID + "." + MyCommandName, -1);
                }
                catch
                {
                }

                // Add the command if it does not exist
                if (myCommand == null)
                {
                    myCommand = _applicationObject.Commands.AddNamedCommand(_addInInstance,
                                                                            MyCommandName, MyCommandCaption, MyCommandTooltip, true, 59, ref contextUiGuids,
                                                                            (int)(vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled));
                }

                // Retrieve the collection of commandbars
                CommandBars commandBars = (CommandBars)_applicationObject.CommandBars;

                // Retrieve some built-in commandbars
                CommandBar standardCommandBar = commandBars[vsStandardCommandbarName];

                // Add a button on the "Standard" toolbar
                _myStandardCommandBarButton = (CommandBarButton)myCommand.AddControl(standardCommandBar,
                                                                                     standardCommandBar.Controls.Count + 1);

                // Change some button properties
                _myStandardCommandBarButton.Caption    = MyCommandCaption;
                _myStandardCommandBarButton.BeginGroup = true;

                // Get if the toolwindow was visible when the add-in was unloaded last time to show it
                Microsoft.Win32.RegistryKey registryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\SaveTabs");
                if (registryKey != null)
                {
                    if ((int)registryKey.GetValue("SaveTabsVisible") == ToolwindowVisible)
                    {
                        showToolWindow();
                    }
                    registryKey.Close();
                }
            }
            catch (System.Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.ToString());
            }
        }
        public void Initialize(CommandBarControls menuControls)
        {
            _codeInspectionsButton = menuControls.Add(MsoControlType.msoControlButton, Temporary: true) as CommandBarButton;
            Debug.Assert(_codeInspectionsButton != null);

            _codeInspectionsButton.Caption = "Code &Inspections";

            _codeInspectionsButton.Click += OnCodeInspectionsButtonClick;
        }
Example #15
0
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            addInInstance     = (AddIn)addInInst;
            applicationObject = (DTE2)addInInstance.DTE;

            switch (connectMode)
            {
            case ext_ConnectMode.ext_cm_Startup:

                Commands2 commands = (Commands2)applicationObject.Commands;

                CommandBar menuBarCommandBar  = ((CommandBars)applicationObject.CommandBars)["MenuBar"];
                CommandBar standardCommandBar = ((CommandBars)applicationObject.CommandBars)["Standard"];

                this.openViewerButton = AddCommandBarButton(commands,
                                                            standardCommandBar,
                                                            "OpenInternalsViewer",
                                                            "Open Internals Viewer",
                                                            Properties.Resources.allocationMapIcon,
                                                            Properties.Resources.allocationMapIconMask);

                CommandBarPopup commandBarPopup = (CommandBarPopup)menuBarCommandBar.Controls.Add(MsoControlType.msoControlPopup,
                                                                                                  System.Type.Missing,
                                                                                                  System.Type.Missing,
                                                                                                  8,
                                                                                                  Properties.Resources.AppWindow);
                commandBarPopup.Caption = "Internals Viewer";

                AddCommandBarPopup(commands,
                                   commandBarPopup,
                                   "AllocationMap",
                                   "Allocation Map",
                                   "Show the Allocation Map",
                                   Properties.Resources.allocationMapIcon,
                                   Properties.Resources.allocationMapIconMask);

                AddCommandBarPopup(commands,
                                   commandBarPopup,
                                   "TransactionLog",
                                   "Display Transaction Log",
                                   "Include the Transaction Log with query results",
                                   Properties.Resources.TransactionLogIcon,
                                   Properties.Resources.allocationMapIconMask);

                IObjectExplorerEventProvider provider = ServiceCache.GetObjectExplorer().GetService(typeof(IObjectExplorerEventProvider)) as IObjectExplorerEventProvider;

                provider.NodesRefreshed     += new NodesChangedEventHandler(Provider_NodesRefreshed);
                provider.NodesAdded         += new NodesChangedEventHandler(Provider_NodesRefreshed);
                provider.BufferedNodesAdded += new NodesChangedEventHandler(Provider_NodesRefreshed);

                this.windowManager       = new WindowManager(applicationObject, addInInstance);
                this.queryEditorExtender = new QueryEditorExtender(applicationObject, this.windowManager);

                break;
            }
        }
Example #16
0
        public Application()
        {
            this.applicationWindow          = new ApplicationWindow();
            this.applicationWindow.Load    += new EventHandler(this.ApplicationWindow_Load);
            this.applicationWindow.Closing += new CancelEventHandler(this.ApplicationWindow_Closing);
            this.applicationWindow.ResourceBrowser.PropertyChanged      += new PropertyChangedEventHandler(this.ResourceBrowser_PropertyChanged);
            this.applicationWindow.ResourceBrowser.SelectedIndexChanged += new EventHandler(this.ResourceBrowser_SelectedIndexChanged);

            this.cutItem    = new CommandBarButton(CommandBarResource.Cut, "Cu&t", new EventHandler(this.Cut_Click), Keys.Control | Keys.X);
            this.copyItem   = new CommandBarButton(CommandBarResource.Copy, "&Copy", new EventHandler(this.Copy_Click), Keys.Control | Keys.C);
            this.pasteItem  = new CommandBarButton(CommandBarResource.Paste, "&Paste", new EventHandler(this.Paste_Click), Keys.Control | Keys.V);
            this.deleteItem = new CommandBarButton(CommandBarResource.Delete, "&Delete", new EventHandler(this.Delete_Click));

            // MenuBar
            CommandBar menuBar = this.applicationWindow.MenuBar;

            CommandBarMenu fileMenu = menuBar.Items.AddMenu("&File");

            fileMenu.Items.AddButton(CommandBarResource.New, "&New", new EventHandler(this.New_Click), Keys.Control | Keys.N);
            fileMenu.Items.AddButton(CommandBarResource.Open, "&Open...", new EventHandler(this.Open_Click), Keys.Control | Keys.O);
            fileMenu.Items.AddButton(CommandBarResource.Save, "&Save", new EventHandler(this.Save_Click), Keys.Control | Keys.S);
            fileMenu.Items.AddButton("Save &As...", new EventHandler(this.SaveAs_Click));
            fileMenu.Items.AddSeparator();
            fileMenu.Items.AddButton("E&xit", new EventHandler(this.Exit_Click));

            CommandBarMenu editMenu = menuBar.Items.AddMenu("&Edit");

            editMenu.Items.Add(this.cutItem);
            editMenu.Items.Add(this.copyItem);
            editMenu.Items.Add(this.pasteItem);
            editMenu.Items.Add(this.deleteItem);
            editMenu.Items.AddSeparator();
            editMenu.Items.AddButton(CommandBarResource.Edit, "Insert &Text...", new EventHandler(this.InsertText_Click), Keys.Control | Keys.T);
            editMenu.Items.AddButton(CommandBarResource.Parent, "Insert &Files...", new EventHandler(this.InsertFiles_Click), Keys.Control | Keys.F);

            CommandBarMenu helpMenu = menuBar.Items.AddMenu("&Help");

            helpMenu.Items.AddButton("&About .NET Resourcer...", new EventHandler(this.About_Click));

            // ToolBar
            CommandBar toolBar = this.applicationWindow.ToolBar;

            toolBar.Items.AddButton(CommandBarResource.New, "New", new EventHandler(this.New_Click), Keys.Control | Keys.N);
            toolBar.Items.AddButton(CommandBarResource.Open, "Open...", new EventHandler(this.Open_Click), Keys.Control | Keys.O);
            toolBar.Items.AddButton(CommandBarResource.Save, "Save", new EventHandler(this.Save_Click), Keys.Control | Keys.S);
            toolBar.Items.AddSeparator();
            toolBar.Items.Add(this.cutItem);
            toolBar.Items.Add(this.copyItem);
            toolBar.Items.Add(this.pasteItem);
            toolBar.Items.Add(this.deleteItem);
            toolBar.Items.AddSeparator();
            toolBar.Items.AddButton(CommandBarResource.Edit, "Insert &Text...", new EventHandler(this.InsertText_Click), Keys.Control | Keys.T);
            toolBar.Items.AddButton(CommandBarResource.Parent, "Insert &Files...", new EventHandler(this.InsertFiles_Click), Keys.Control | Keys.F);

            System.Windows.Forms.Application.Idle += new EventHandler(this.Application_Idle);
        }
Example #17
0
        //首先创建一个ribbonTab,功能栏的一个选项
        //接着创建一个ribbonGroup 是button的group
        //创建button 设定属性 放入ribbonGroup
        //对每个button设定相应的处理事件。
        private static void CreateButton()
        {
            Project.UndoContext.BeginUndoStep("Add Buttons");
            try
            {   //在功能栏添加了一个叫Mytab的选项
                RibbonTab ribbonTab = new RibbonTab("MyTab", "MyAdd-in");
                UIEnvironment.RibbonTabs.Add(ribbonTab);
                UIEnvironment.ActiveRibbonTab = ribbonTab;

                RibbonGroup ribbonGroup = new RibbonGroup("Mybutton", "Status");

                // Create first small button (id,text)
                CommandBarButton buttonFirst = new CommandBarButton("MyFirstButton", "OpenStatusWindow");
                buttonFirst.HelpText = "Help text for small button";
                // buttonFirst.Image = global::RobotStudioEmptyAddin1.Properties.Resources.iconCFimport;
                buttonFirst.DefaultEnabled = true;
                ribbonGroup.Controls.Add(buttonFirst);

                //Include Seperator between buttons
                CommandBarSeparator seperator = new CommandBarSeparator();
                ribbonGroup.Controls.Add(seperator);

                // Create second button. The largeness of the button is determined by RibbonControlLayout
                CommandBarButton buttonSecond = new CommandBarButton("MySecondButton", "TestButton");
                buttonSecond.HelpText       = "Help text for large button";
                buttonSecond.DefaultEnabled = true;
                ribbonGroup.Controls.Add(buttonSecond);

                // Set the size of the buttons.
                RibbonControlLayout[] ribbonControlLayout = { RibbonControlLayout.Small, RibbonControlLayout.Large };
                ribbonGroup.SetControlLayout(buttonFirst, ribbonControlLayout[0]);
                ribbonGroup.SetControlLayout(buttonSecond, ribbonControlLayout[1]);



                //Add ribbon group to ribbon tab
                ribbonTab.Groups.Add(ribbonGroup);

                // Add an event handler.
                buttonFirst.UpdateCommandUI += new UpdateCommandUIEventHandler(button_UpdateCommandUI);
                // Add an event handler for pressing the button.
                buttonFirst.ExecuteCommand += new ExecuteCommandEventHandler(button_ExecuteCommand);

                buttonSecond.UpdateCommandUI += new UpdateCommandUIEventHandler(button2_UpdateCommandUI);
                buttonSecond.ExecuteCommand  += new ExecuteCommandEventHandler(button2_ExecuteCommand);
            }
            catch (Exception ex)
            {
                Project.UndoContext.CancelUndoStep(CancelUndoStepType.Rollback);
                Logger.AddMessage(new LogMessage(ex.Message.ToString()));
            }
            finally
            {
                Project.UndoContext.EndUndoStep();
            }
        }
        private void btnImportAddresses_Click(CommandBarButton ctrl, ref bool cancel)
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                // System.Data.DataSet ds = new System.Data.DataSet();
                EmployeeTableAdapters.EmployeesTableAdapter td = new SyncMyAddress.EmployeeTableAdapters.EmployeesTableAdapter();
                Employee.EmployeesDataTable ds = new Employee.EmployeesDataTable();
                ds = td.GetData();

                MAPIFolder contactsFolder = Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts);

                //Outlook.ContactItem contactItem;
                Outlook.Items contacts;
                contacts = contactsFolder.Items.Restrict("[MessageClass]='IPM.Contact'");

                foreach (System.Data.DataRow dr in ds.Rows)
                {
                    Outlook.ContactItem existingContact = (Outlook.ContactItem)contacts.Find("[Email1Address] = '" + dr["EmailID"] + "'");
                    if (existingContact != null)
                    {
                        existingContact.FirstName     = (dr["FullName"] == null) ? string.Empty : dr["FullName"].ToString();
                        existingContact.CustomerID    = (dr["EmpID"] == null) ? string.Empty : dr["EmpID"].ToString();
                        existingContact.JobTitle      = (dr["Designation"] == null) ? string.Empty : dr["Designation"].ToString();
                        existingContact.Department    = (dr["Department"] == null) ? string.Empty : dr["Department"].ToString();
                        existingContact.Email1Address = (dr["EmailID"] == null) ? string.Empty : dr["EmailID"].ToString();
                        existingContact.ManagerName   = (dr["ManagerID"] == null) ? string.Empty : dr["ManagerID"].ToString();
                        existingContact.WebPage       = "www.appsassociates.com";
                        existingContact.Save();
                    }
                    else
                    {
                        Outlook.ContactItem newContact = Application.CreateItem(Outlook.OlItemType.olContactItem) as Outlook.ContactItem;
                        newContact.FirstName     = (dr["FullName"] == null) ? string.Empty : dr["FullName"].ToString();
                        newContact.CustomerID    = (dr["EmpID"] == null) ? string.Empty : dr["EmpID"].ToString();
                        newContact.JobTitle      = (dr["Designation"] == null) ? string.Empty : dr["Designation"].ToString();
                        newContact.Department    = (dr["Department"] == null) ? string.Empty : dr["Department"].ToString();
                        newContact.Email1Address = (dr["EmailID"] == null) ? string.Empty : dr["EmailID"].ToString();
                        newContact.ManagerName   = (dr["ManagerID"] == null) ? string.Empty : dr["ManagerID"].ToString();
                        newContact.WebPage       = "www.appsassociates.com";
                        newContact.Save();
                    }
                }
                MessageBox.Show("Successfully Imported...!");
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Sync Process is not completed. Error Message: " + ex.Message);
            }
            catch
            {
                MessageBox.Show("Sync Process is not completed");
            }
            Cursor.Current = Cursors.Default;
        }
Example #19
0
        public CommandBarButton AddButtonToPopup(CommandBarPopup popup, int beforeIndex, string caption, string tooltip)
        {
            CommandBarButton button = popup.Controls.Add(MsoControlType.msoControlButton,
                                                         Type.Missing, Type.Missing, beforeIndex, true) as CommandBarButton;

            button.Caption     = caption;
            button.TooltipText = tooltip;

            return(button);
        }
Example #20
0
        public void OnClick(object something, System.EventArgs args)
        {
            CommandBarButton button = (CommandBarButton)something;

            //			ToolBarButton button = args.Button;
            ChoiceBase control = (ChoiceBase)button.Tag;

            Debug.Assert(control != null);
            control.OnClick(button, null);
        }
Example #21
0
        public static void SetButtonImage(CommandBarButton button, Bitmap image)
        {
            button.FaceId = 0;

            if (image != null)
            {
                Clipboard.SetDataObject(image, true);
                button.PasteFace();
            }
        }
        /// <summary>
        /// Open Pending Changes Window
        /// </summary>
        /// <param name="cmdBar">Take CommanBars of the main Window </param>
        public static void OpenPendingChangesWindow(CommandBars cmdBar)
        {
            CommandBar       cmdMenuBar             = (CommandBar)cmdBar[1];
            CommandBarPopup  cmdBarPopupView        = (CommandBarPopup)cmdMenuBar.Controls[3];
            CommandBar       cmdBarView             = cmdBarPopupView.CommandBar;
            CommandBarPopup  cmdOtherWindowBarPopup = (CommandBarPopup)cmdBarView.Controls["Other Windows"];
            CommandBarButton buttonPendingChanges   = (CommandBarButton)cmdOtherWindowBarPopup.Controls[17];

            buttonPendingChanges.Execute();
        }
Example #23
0
        private void OnRenameButtonClick(CommandBarButton Ctrl, ref bool CancelDefault)
        {
            if (IDE.ActiveCodePane == null)
            {
                return;
            }
            var selection = IDE.ActiveCodePane.GetSelection();

            Rename(selection);
        }
        private void FindAllImplementations_Click(CommandBarButton Ctrl, ref bool CancelDefault)
        {
            var declaration = FindSelectedDeclaration();

            if (declaration == null)
            {
                return;
            }
            OnFindImplementations(this, new NavigateCodeEventArgs(declaration));
        }
Example #25
0
        private void CopyFromMarkdown(CommandBarButton ctrl, ref bool canceldefault)
        {
            var text = Clipboard.GetText();

            if (string.IsNullOrEmpty(text))
            {
                return;
            }

            var range = Application.Selection as Range;

            if (range == null)
            {
                MessageBox.Show(Properties.Resources.UnselectedErrorMessage);
                return;
            }

            var table       = new TableParser().Parse(new GridParser().Parse(text));
            var activeSheet = (Worksheet)Application.ActiveSheet;

            for (var i = 0; i < table.Rows.Count; i++)
            {
                var row = table.Rows[i];
                for (var j = 0; j < row.Count; j++)
                {
                    var cell            = row[j];
                    var activeSheetCell = (Range)activeSheet.Cells[range.Row + i, range.Column + j];
                    activeSheetCell.Value2 = cell.Value
                                             .Replace("<br>", "\n")
                                             .Replace("<br/>", "\n")
                                             .Replace("&#124;", "|");
                    switch (cell.Alignment)
                    {
                    case Alignment.Undefined:
                        activeSheetCell.HorizontalAlignment = AlignmentUndefined;
                        break;

                    case Alignment.Left:
                        activeSheetCell.HorizontalAlignment = AlignmentLeft;
                        break;

                    case Alignment.Center:
                        activeSheetCell.HorizontalAlignment = AlignmentCenter;
                        break;

                    case Alignment.Right:
                        activeSheetCell.HorizontalAlignment = AlignmentRight;
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }
        }
Example #26
0
        public void OnDisconnection(ext_DisconnectMode disconnectMode, ref Array custom)
        {
            try
            {
                switch (disconnectMode)
                {
                case ext_DisconnectMode.ext_dm_HostShutdown:
                case ext_DisconnectMode.ext_dm_UserClosed:

                    // Delete buttons on built-in commandbars
                    if ((_myStandardCommandBarButton != null))
                    {
                        _myStandardCommandBarButton.Delete();
                    }

                    if ((_myCodeWindowCommandBarButton != null))
                    {
                        _myCodeWindowCommandBarButton.Delete();
                    }

                    if ((_myToolsCommandBarButton != null))
                    {
                        _myToolsCommandBarButton.Delete();
                    }

                    // Disconnect event handlers
                    _myToolBarButton          = null;
                    _myCommandBarPopup1Button = null;
                    _myCommandBarPopup2Button = null;

                    // Delete commandbars created by the add-in
                    if ((_myToolbar != null))
                    {
                        _myToolbar.Delete();
                    }

                    if ((_myCommandBarPopup1 != null))
                    {
                        _myCommandBarPopup1.Delete();
                    }

                    if ((_myCommandBarPopup2 != null))
                    {
                        _myCommandBarPopup2.Delete();
                    }

                    break;
                }
            }
            catch (System.Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
            }
        }
Example #27
0
        public void Initialize(CommandBarControls menuControls)
        {
            var menu = menuControls.Add(Type: MsoControlType.msoControlPopup, Temporary: true) as CommandBarPopup;

            menu.Caption = "&Refactor";

            _extractMethodButton = AddButton(menu, "Extract &Method", false, OnExtractMethodButtonClick, Resources.ExtractMethod_6786_32);
            _renameButton        = AddButton(menu, "&Rename", false, OnRenameButtonClick);

            InitializeRefactorContextMenu();
        }
Example #28
0
        /// <summary>
        /// Adds the Visual studio menu item.
        /// </summary>
        /// <param name="vsmainMenu">visual studio menu item</param>
        /// <param name="menuToAdd">name of the menu item</param>
        /// <param name="position">position.of menu item.</param>
        /// <param name="seperator">if set to <c>true</c> [seperator].</param>
        /// <returns>
        /// CommandBarControl Object
        /// </returns>
        private static CommandBarButton AddVSMenuItem(CommandBarPopup vsmainMenu, string menuToAdd, int position, bool seperator)
        {
            CommandBarButton vsmenuItem = (CommandBarButton)vsmainMenu.Controls.Add(MsoControlType.msoControlButton, 1, string.Empty, position, true);

            vsmenuItem.BeginGroup  = seperator;
            vsmenuItem.Tag         = Guid.NewGuid().ToString();
            vsmenuItem.Style       = MsoButtonStyle.msoButtonIconAndCaption;
            vsmenuItem.Caption     = menuToAdd;
            vsmenuItem.TooltipText = string.Empty;
            return(vsmenuItem);
        }
Example #29
0
        private void bnSendSales_Click(CommandBarButton Ctrl, ref bool CancelDefault)
        {
            // Get the Selected Rows, Create SLSend.Recipients from them, Load SLSend
            try
            {
                SLSend slSend = new SLSend(AppMode.ExcelHostedAddin);

                //Excel.Worksheet wks =
                //	(Excel.Worksheet)excelApp.ActiveWorkbook.ActiveSheet;
                //Excel.Range selectedRange = (Excel.Range)excelApp.Selection;

                // TRY-FIND
                Excel.Areas areas = ((Excel.Range)excelApp.Selection).Areas;
                for (int ai = 1; ai < areas.Count + 1; ai++)
                {
                    Excel.Range selectedRange = areas[ai];
                    Excel.Range entireRange   = selectedRange.EntireRow;
                    entireRange.Select();

                    for (int i = 1; i < entireRange.Rows.Count + 1; i++)
                    {
                        Recipient recipient = new Recipient();
                        recipient.Company = (string)((Excel.Range)entireRange.Rows.Cells.get_Item(i, 2)).Text;
                        recipient.Name    = (string)((Excel.Range)entireRange.Rows.Cells.get_Item(i, 3)).Text;

                        string tmpEmail = (string)((Excel.Range)entireRange.Rows.Cells.get_Item(i, 8)).Text;
                        if (tmpEmail != null && tmpEmail.Length > 0)
                        {
                            recipient.EmailAddress = tmpEmail;
                        }
                        slSend.AddRecipient(recipient);
                    }
                }
                // END

//				Excel.Range entireRange = selectedRange.EntireRow;
//				entireRange.Select();
//
//				for (int i = 1; i < entireRange.Rows.Count + 1; i++)
//				{
//					Recipient recipient = new Recipient();
//					recipient.Company = (string)((Excel.Range)entireRange.Rows.Cells.get_Item(i,2)).Text;
//					recipient.Name = (string)((Excel.Range)entireRange.Rows.Cells.get_Item(i,3)).Text;
//
//					slSend.AddRecipient(recipient);
//				}

                slSend.Visible = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #30
0
 private void bnAbout_Click(CommandBarButton Ctrl, ref bool CancelDefault)
 {
     try
     {
         About.ShowAbout();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #31
0
        public void Initialize(CommandBarControls menuControls)
        {
            var menu = menuControls.Add(Type: MsoControlType.msoControlPopup, Temporary: true) as CommandBarPopup;

            menu.Caption = "&Refactor";

            _parseModuleButton         = AddMenuButton(menu);
            _parseModuleButton.Caption = "&Parse module";
            _parseModuleButton.FaceId  = 3039;
            _parseModuleButton.Click  += OnParseModuleButtonClick;
        }
        private CommandBarButton CreateButton(Command iCommand, CommandBar iCommandBar, string iCaption, bool iBeginGroup = false, int iPosition = -1)
        {
            int position = (iPosition == -1) ? iCommandBar.Controls.Count + 1 : iPosition;

            CommandBarButton button = (CommandBarButton)iCommand.AddControl(iCommandBar, position);

            button.Caption    = iCaption;
            button.BeginGroup = iBeginGroup;

            return(button);
        }
 private void ToolBarBtn_Status_OnClick (CommandBarButton Ctrl, ref bool CancelDefault)
 {
   try
   {
     _componentContainer.ShowProfileStatuses ();
   }
   catch (Exception x)
   {
     ExceptionHandler.Instance.DisplayException (x, s_logger);
   }
 }
Example #34
0
        public void Initialize(CommandBarControls menuControls)
        {
            _codeExplorerButton = menuControls.Add(MsoControlType.msoControlButton, Temporary: true) as CommandBarButton;
            Debug.Assert(_codeExplorerButton != null);

            _codeExplorerButton.Caption    = "&Code Explorer";
            _codeExplorerButton.BeginGroup = true;

            _codeExplorerButton.FaceId = 3039;
            _codeExplorerButton.Click += OnCodeExplorerButtonClick;
        }
Example #35
0
 private static void Button_Click(CommandBarButton Ctrl, ref bool CancelDefault)
 {
     Microsoft.Office.Interop.Excel.Range activeCell = ExcelApp.Application.ActiveCell;
     ExcelWvvm.Entities.GoogleHistory     history    = MainThreadLogic.EntityOperatior.GetHistoryByRange(activeCell);
     if (history != null)
     {
         MainThreadLogic.EntityOperatior.ShowRefreshingComment(history);
         history.OnRetrievedDataHandler = History_OnRetrievedData;
         history.ExecuteAsync();
     }
 }
Example #36
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Press or release the button
 /// </summary>
 /// <param name="btn"></param>
 /// <param name="fPress"></param>
 /// ------------------------------------------------------------------------------------
 public void PressButton(CommandBarButton btn, bool fPress)
 {
     if (fPress)
     {
         btn.State = MsoButtonState.msoButtonDown;
     }
     else
     {
         btn.State = MsoButtonState.msoButtonUp;
     }
 }
Example #37
0
        public Application()
        {
            this.applicationWindow = new ApplicationWindow();
            this.applicationWindow.Load +=new EventHandler(this.ApplicationWindow_Load);
            this.applicationWindow.Closing += new CancelEventHandler(this.ApplicationWindow_Closing);
            this.applicationWindow.ResourceBrowser.PropertyChanged += new PropertyChangedEventHandler(this.ResourceBrowser_PropertyChanged);
            this.applicationWindow.ResourceBrowser.SelectedIndexChanged += new EventHandler(this.ResourceBrowser_SelectedIndexChanged);

            this.cutItem = new CommandBarButton(CommandBarResource.Cut, "Cu&t", new EventHandler(this.Cut_Click), Keys.Control | Keys.X);
            this.copyItem = new CommandBarButton(CommandBarResource.Copy, "&Copy", new EventHandler(this.Copy_Click), Keys.Control | Keys.C);
            this.pasteItem = new CommandBarButton(CommandBarResource.Paste, "&Paste", new EventHandler(this.Paste_Click), Keys.Control | Keys.V);
            this.deleteItem = new CommandBarButton(CommandBarResource.Delete, "&Delete", new EventHandler(this.Delete_Click));

            // MenuBar
            CommandBar menuBar = this.applicationWindow.MenuBar;

            CommandBarMenu fileMenu = menuBar.Items.AddMenu("&File");
            fileMenu.Items.AddButton(CommandBarResource.New, "&New", new EventHandler(this.New_Click), Keys.Control | Keys.N);
            fileMenu.Items.AddButton(CommandBarResource.Open, "&Open...", new EventHandler(this.Open_Click), Keys.Control | Keys.O);
            fileMenu.Items.AddButton(CommandBarResource.Save, "&Save", new EventHandler(this.Save_Click), Keys.Control | Keys.S);
            fileMenu.Items.AddButton("Save &As...", new EventHandler(this.SaveAs_Click));
            fileMenu.Items.AddSeparator();
            fileMenu.Items.AddButton("E&xit", new EventHandler(this.Exit_Click));

            CommandBarMenu editMenu = menuBar.Items.AddMenu("&Edit");
            editMenu.Items.Add(this.cutItem);
            editMenu.Items.Add(this.copyItem);
            editMenu.Items.Add(this.pasteItem);
            editMenu.Items.Add(this.deleteItem);
            editMenu.Items.AddSeparator();
            editMenu.Items.AddButton(CommandBarResource.Edit, "Insert &Text...", new EventHandler(this.InsertText_Click), Keys.Control | Keys.T);
            editMenu.Items.AddButton(CommandBarResource.Parent, "Insert &Files...", new EventHandler(this.InsertFiles_Click), Keys.Control | Keys.F);

            CommandBarMenu helpMenu = menuBar.Items.AddMenu("&Help");
            helpMenu.Items.AddButton("&About .NET Resourcer...", new EventHandler(this.About_Click));

            // ToolBar
            CommandBar toolBar = this.applicationWindow.ToolBar;
            toolBar.Items.AddButton(CommandBarResource.New, "New", new EventHandler(this.New_Click), Keys.Control | Keys.N);
            toolBar.Items.AddButton(CommandBarResource.Open, "Open...", new EventHandler(this.Open_Click), Keys.Control | Keys.O);
            toolBar.Items.AddButton(CommandBarResource.Save, "Save", new EventHandler(this.Save_Click), Keys.Control | Keys.S);
            toolBar.Items.AddSeparator();
            toolBar.Items.Add(this.cutItem);
            toolBar.Items.Add(this.copyItem);
            toolBar.Items.Add(this.pasteItem);
            toolBar.Items.Add(this.deleteItem);
            toolBar.Items.AddSeparator();
            toolBar.Items.AddButton(CommandBarResource.Edit, "Insert &Text...", new EventHandler(this.InsertText_Click), Keys.Control | Keys.T);
            toolBar.Items.AddButton(CommandBarResource.Parent, "Insert &Files...", new EventHandler(this.InsertFiles_Click), Keys.Control | Keys.F);

            System.Windows.Forms.Application.Idle += new EventHandler(this.Application_Idle);
        }
Example #38
0
        public void Initialize(CommandBarControls menuControls)
        {
            _menuControls = menuControls;

            _menu = menuControls.Add(MsoControlType.msoControlPopup, Temporary: true) as CommandBarPopup;
            _menu.Caption = RubberduckUI.RubberduckMenu_UnitTests;

            _windowsTestExplorerButton = AddButton(_menu, RubberduckUI.TestMenu_TextExplorer, false, OnTestExplorerButtonClick);
            SetButtonImage(_windowsTestExplorerButton, Resources.TestManager_8590_32, Resources.TestManager_8590_32_Mask);

            _runAllTestsButton = AddButton(_menu, RubberduckUI.TestMenu_RunAllTests, true, OnRunAllTestsButtonClick);
            SetButtonImage(_runAllTestsButton, Resources.AllLoadedTests_8644_24, Resources.AllLoadedTests_8644_24_Mask);
        }
Example #39
0
		/// <summary>
		/// Sets an icon on a CommandBarButton
		/// </summary>
		/// <param name="btn"></param>
		/// <param name="bitmap"></param>
		/// <param name="mask"></param>
		public static void SetPicture(CommandBarButton button, string bitmapName, string maskName)
		{
			Assembly assembly = Assembly.GetAssembly(typeof(ImageHelper));
			System.IO.Stream stream = assembly.GetManifestResourceStream(typeof(ImageHelper),
				bitmapName);
			Bitmap bitmap = (Bitmap)Bitmap.FromStream(stream);
			stream = assembly.GetManifestResourceStream(typeof(ImageHelper), maskName);
			Bitmap mask = (Bitmap)Bitmap.FromStream(stream);

			stdole.IPictureDisp picDisp = GetIPictureDispFromHandle(bitmap.GetHbitmap());
			button.Picture = (stdole.StdPicture)picDisp;
			picDisp = GetIPictureDispFromHandle(mask.GetHbitmap());
			button.Mask = (stdole.StdPicture)picDisp;
		}
        public void Initialize()
        {
            _toolbar = _vbe.CommandBars.Add(RubberduckUI.CodeInspections, Temporary: true);
            _refreshButton = (CommandBarButton)_toolbar.Controls.Add(MsoControlType.msoControlButton, Temporary: true);
            _refreshButton.TooltipText = RubberduckUI.CodeInspections_Run;

            var refreshIcon = Resources.Refresh;
            refreshIcon.MakeTransparent(Color.Magenta);
            Menu.SetButtonImage(_refreshButton, refreshIcon);

            _statusButton = (CommandBarButton)_toolbar.Controls.Add(MsoControlType.msoControlButton, Temporary: true);
            _statusButton.Caption = string.Format(RubberduckUI.CodeInspections_NumberOfIssues_Plural, 0);
            _statusButton.FaceId = 463; // Resources.Warning doesn't look good here
            _statusButton.Style = MsoButtonStyle.msoButtonIconAndCaption;

            _quickFixButton = (CommandBarButton)_toolbar.Controls.Add(MsoControlType.msoControlButton, Temporary: true);
            _quickFixButton.Caption = RubberduckUI.Fix;
            _quickFixButton.Style = MsoButtonStyle.msoButtonIconAndCaption;
            _quickFixButton.FaceId = 305; // Resources.applycodechanges_6548_321 doesn't look good here
            _quickFixButton.Enabled = false;

            _navigatePreviousButton = (CommandBarButton)_toolbar.Controls.Add(MsoControlType.msoControlButton, Temporary:true);
            _navigatePreviousButton.BeginGroup = true;
            _navigatePreviousButton.Caption = RubberduckUI.Previous;
            _navigatePreviousButton.TooltipText = RubberduckUI.Previous;
            _navigatePreviousButton.Style = MsoButtonStyle.msoButtonIconAndCaption;
            _navigatePreviousButton.FaceId = 41; // Resources.112_LeftArrowLong_Blue_16x16_72 makes a gray Block when disabled
            _navigatePreviousButton.Enabled = false;

            _navigateNextButton = (CommandBarButton)_toolbar.Controls.Add(MsoControlType.msoControlButton, Temporary: true);
            _navigateNextButton.Caption = RubberduckUI.Next;
            _navigateNextButton.TooltipText = RubberduckUI.Next;
            _navigateNextButton.Style = MsoButtonStyle.msoButtonIconAndCaption;
            _navigateNextButton.FaceId = 39; // Resources.112_RightArrowLong_Blue_16x16_72 makes a gray Block when disabled
            _navigateNextButton.Enabled = false;

            _refreshButton.Click += _refreshButton_Click;
            _quickFixButton.Click += _quickFixButton_Click;
            _navigatePreviousButton.Click += _navigatePreviousButton_Click;
            _navigateNextButton.Click += _navigateNextButton_Click;

            _inspector.IssuesFound += OnIssuesFound;
            _inspector.Reset += OnReset;
            _inspector.ParseCompleted += _inspector_ParseCompleted;
        }
Example #41
0
		protected void UpdateDisplay(UIItemDisplayProperties display, CommandBarButton button)
		{
			//can't change text after button is created
			button.IsEnabled = display.Enabled;
/*
 * I started on this so that property-related toolbar buttons could somehow looked depressed when
 * the property that they set equalled the value they set, i.e. in the "checked" state.
 * I gave up because
 * 1) there's no way to tell the CommandBar manager to draw it differently others and changing the icon
 * 2) it would be a pain to define or create different icons, though it would be possible
 * 3) when you change the icon, the CommandBar manager does not bother to repaint it
 * 4) so the way I found to repay was to actually tell the CommandBar manager to refresh
 *		the entire view, which caused a visible flicker.
 * 5) so I am giving up for now.
 *
 * 	if(display.Checked)
			{
				button.Image =m_smallImages.GetImage("Pie");
				//m_commandBarManager. Style=this.Style;//goose it
			}
			else
				button.Image  =m_smallImages.GetImage(display.ImageLabel);

			m_commandBarManager.Refresh();
*/		}
 private void ToolBarBtn_SyncNow_OnClick (CommandBarButton Ctrl, ref bool CancelDefault)
 {
   ManualSynchronize();
 }
 private void ToolBarBtn_Options_OnClick (CommandBarButton Ctrl, ref bool CancelDefault)
 {
   _componentContainer.ShowOptionsNoThrow();
 }
Example #44
0
        private void InitializeRunTestsCommand()
        {
            CommandBar oCommandBar = ((Microsoft.VisualStudio.CommandBars.CommandBars)_applicationObject.CommandBars)["Code Window"];

            _runTestsCommand = oCommandBar.Controls["Run Tests"] as CommandBarButton;
        }
        public void Initialize()
        {
            var commandbar = _vbe.CommandBars.Add("Rubberduck", MsoBarPosition.msoBarTop, false, true);

            _refreshButton = (CommandBarButton)commandbar.Controls.Add(MsoControlType.msoControlButton);
            ParentMenuItemBase.SetButtonImage(_refreshButton, Resources.arrow_circle_double, Resources.arrow_circle_double_mask);
            _refreshButton.Style = MsoButtonStyle.msoButtonIcon;
            _refreshButton.Tag = "Refresh";
            _refreshButton.TooltipText =RubberduckUI.RubberduckCommandbarRefreshButtonTooltip;
            _refreshButton.Click += refreshButton_Click;

            _statusButton = (CommandBarButton)commandbar.Controls.Add(MsoControlType.msoControlButton);
            _statusButton.Style = MsoButtonStyle.msoButtonCaption;
            _statusButton.Tag = "Status";
            _statusButton.Click += _statusButton_Click;

            _selectionButton = (CommandBarButton)commandbar.Controls.Add(MsoControlType.msoControlButton);
            _selectionButton.Style = MsoButtonStyle.msoButtonCaption;
            _selectionButton.BeginGroup = true;
            _selectionButton.Enabled = false;

            commandbar.Visible = true;
        }
Example #46
0
		protected CommandBarItem CreateMenuItem(ChoiceBase choice)
		{
			//note that we could handle the details of display in two different ways.
			//either we can leave this up to the normal display mechanism, which will do its own polling,
			//or we could just build the menu in the desired state right here (enable checked etc.)

			UIItemDisplayProperties display = choice.GetDisplayProperties();

			string label = display.Text;
			bool isSeparatorBar = (label == "-");
			label = label.Replace("_", "&");
			Image image = null;
			if (display.ImageLabel!= "default")
				image = m_smallImages.GetImage(display.ImageLabel);
			CommandBarItem menuItem;
			if(choice is CommandChoice)
			{
				if (isSeparatorBar)
					menuItem = new CommandBarSeparator();
				else
					menuItem = new CommandBarButton(image, label, new EventHandler(OnClick));
			}
			else
			{
				CommandBarCheckBox cb = new CommandBarCheckBox(image, label);
				cb.Click += new System.EventHandler(choice.OnClick);
				cb.IsChecked = display.Checked;
				menuItem = cb;
			}
			if (!isSeparatorBar)
				((CommandBarButtonBase)menuItem).Shortcut = choice.Shortcut;

			menuItem.Tag = choice;
			menuItem.IsEnabled = !isSeparatorBar && display.Enabled;
			menuItem.IsVisible = display.Visible;
			choice.ReferenceWidget = menuItem;
			return menuItem;
		}
 public CommandBarButton AddButton(string text, EventHandler clickHandler)
 {
     CommandBarButton button = new CommandBarButton(text);
     button.Click += clickHandler;
     this.Add(button);
     return button;
 }
Example #48
0
 void InitCommandButtonPicture(CommandBarButton cmdButton)
 {
     stdole.IPictureDisp olePic = GetIPictureFromResource(
         "Find", /*makeTransparent=*/false);
     cmdButton.Picture = (stdole.StdPicture)olePic;
 }
Example #49
0
 void OnRunAllTestsButtonClick(CommandBarButton Ctrl, ref bool CancelDefault)
 {
     _presenter.Show();
     _presenter.RunTests();
 }
Example #50
0
        public void AddTemporaryUI()
        {
            const string vsCodeWindowCommandbarName = "Code Window";
            const string myTemporaryToolbarCaption = "Dotty";

            // The only command that will be created. We will create several buttons from it
            Command myCommand = null;

            // Built-in commandbars of Visual Studio

            // Buttons that will be created on a toolbars/commandbar popups created by the add-in
            // We don't need to keep them at class level to remove them when the add-in is unloaded
            // because we will remove the whole toolbars/commandbar popups

            // The collection of Visual Studio commandbars

            var contextUIGuids = new object[] { };

            try
            {
                // ------------------------------------------------------------------------------------

                // Try to retrieve the command, just in case it was already created, ignoring the
                // exception that would happen if the command was not created yet.
                try
                {
                    myCommand = applicationObject.Commands.Item(addInInstance.ProgID + "." + CommandName);
                }
                catch
                {
                }

                // Add the command if it does not exist
                if (myCommand == null)
                {
                    myCommand = applicationObject.Commands.AddNamedCommand(addInInstance,
                       CommandName, CommandCaption, CommandTooltip, true, 59, ref contextUIGuids,
                       (int)(vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled));
                }
                // ------------------------------------------------------------------------------------

                // 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
                var commandBars = (CommandBars)applicationObject.CommandBars;

                // Retrieve some built-in commandbars
                CommandBar codeCommandBar = commandBars[vsCodeWindowCommandbarName];

                // ------------------------------------------------------------------------------------
                // Button on the "Code Window" context menu
                // ------------------------------------------------------------------------------------

                // Add a button to the built-in "Code Window" context menu
                myCodeWindowCommandBarButton = (CommandBarButton)myCommand.AddControl(codeCommandBar,
                   codeCommandBar.Controls.Count + 1);

                // Change some button properties
                myCodeWindowCommandBarButton.Caption = CommandCaption;
                myCodeWindowCommandBarButton.BeginGroup = true; // Separator line above button

                // ------------------------------------------------------------------------------------
                // New toolbar
                // ------------------------------------------------------------------------------------

                // Add a new toolbar
                myTemporaryToolbar = commandBars.Add(myTemporaryToolbarCaption,
                   MsoBarPosition.msoBarTop, Type.Missing, true);

                // Add a new button on that toolbar
                var myToolBarButton = (CommandBarButton)myCommand.AddControl(myTemporaryToolbar,
                                                                                          myTemporaryToolbar.Controls.Count + 1);

                // Change some button properties
                myToolBarButton.Caption = CommandCaption;
                myToolBarButton.Style = MsoButtonStyle.msoButtonIconAndCaption; // It could be also msoButtonIcon

                // Make visible the toolbar
                myTemporaryToolbar.Visible = true;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
        /// <summary>
        /// Loads the plugin menus.
        /// </summary>
        /// <param name="sender"> Sender object.</param>
        /// <param name="e"> LoadPluginMenuEventArgs arguments.</param>
        public void inspector_LoadPluginMenusEvent(object sender, LoadPluginMenuEventArgs e)
        {
            // Root Menus
            MenuRootHashtable ht = e.MenuRoot;

            SortedList root = new SortedList(ht,null);

            this.SuspendLayout();

            //1: For each MenuRoot, add MenuItems
            foreach (DictionaryEntry de in root)
            {
                MenuRoot r = (MenuRoot)de.Value;

                // Create Menu Root
                CommandBarMenu menuRoot = new CommandBarMenu(r.Text);
                menuRoot.MenuShortcut = r.Shortcut;

                // add MenuRoot
                menubar.Items.Add(menuRoot);

                // if null then exit
                if ( r.MenuItems == null ) break;

                #region Create commands and commandlinks
                //2: Add Menu Children
                for (int i=0;i<r.MenuItems.Count;i++)
                {
                    Ecyware.GreenBlue.Controls.MenuItem mn = (Ecyware.GreenBlue.Controls.MenuItem)r.MenuItems[r.MenuItems.GetKey(i)];

                    if ( mn is Ecyware.GreenBlue.Controls.ToolbarItem )
                    {
                        #region Add Toolbar item

                        // Create Command and add to CommandHolder
                        Ecyware.GreenBlue.Controls.ToolbarItem tbItem = (Ecyware.GreenBlue.Controls.ToolbarItem)mn;

                        // add any submenu toolbar
                        if ( tbItem.IsDropDown )
                        {
                            /*
                            // for command with submenu
                            if ( tbItem.ImageIndex > -1 )
                            {
                                Image img = this.imgToolbar24.Images[tbItem.ImageIndex];
                            }
                            CommandBarMenu m = toolbar.Items.AddMenu(img, tbItem.Text);
                            m.DropDown += tbItem.DropDownDelegate;
                            */
                        }
                        else
                        {
                            if ( tbItem.Toggle )
                            {
                                #region Single Command for toggle or checked type
                                CommandBarCheckBox toolbarItem = new CommandBarCheckBox(tbItem.Text);

                                toolbarItem.IsEnabled = tbItem.Enabled;
                                toolbarItem.IsVisible = tbItem.Visible;
                                toolbarItem.MenuShortcut = tbItem.Shortcut;
                                if ( tbItem.ImageIndex > -1 )
                                    toolbarItem.Image = this.imgToolbar24.Images[tbItem.ImageIndex];

                                toolbarItem.Click += tbItem.CheckedChangedDelegate;
                                toolbar.Items.Add(toolbarItem);
                                #endregion

                            }
                            else
                            {
                                #region Single Command not checked
                                CommandBarButton toolbarItem = new CommandBarButton(tbItem.Text);

                                toolbarItem.IsEnabled = tbItem.Enabled;
                                toolbarItem.IsVisible = tbItem.Visible;
                                toolbarItem.MenuShortcut = tbItem.Shortcut;
                                if ( tbItem.ImageIndex > -1 )
                                    toolbarItem.Image = this.imgToolbar24.Images[tbItem.ImageIndex];

                                toolbarItem.Click += tbItem.ClickDelegate;
                                toolbar.Items.Add(toolbarItem);
                                #endregion
                            }
                            // Add delimiter
                            if ( mn.Delimiter )
                            {
                                toolbar.Items.AddSeparator();
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        if ( mn.Toggle )
                        {
                            #region Add menu with checked
                            CommandBarCheckBox menuItem = new CommandBarCheckBox(mn.Text);
                            menuItem.IsVisible = mn.Visible;
                            menuItem.IsEnabled = mn.Enabled;
                            //if ( mn.ImageIndex > -1 )
                            //	menuItem.Image = this.imgToolbar16.Images[mn.ImageIndex];
                            menuItem.MenuShortcut = mn.Shortcut;
                            menuItem.Click += mn.CheckedChangedDelegate;
                            #endregion
                            // Add delimiter
                            if ( mn.Delimiter )
                            {
                                menuRoot.Items.AddSeparator();
                            }

                            menuRoot.Items.Add(menuItem);
                        }
                        else
                        {
                            #region Add Menu
                            CommandBarButton menuItem = new CommandBarButton(mn.Text);
                            menuItem.IsVisible = mn.Visible;
                            menuItem.IsEnabled = mn.Enabled;
                            if ( mn.ImageIndex > -1 )
                                menuItem.Image = this.imgToolbar16.Images[mn.ImageIndex];
                            menuItem.MenuShortcut = mn.Shortcut;
                            menuItem.Click += mn.ClickDelegate;
                            #endregion
                            // Add delimiter
                            if ( mn.Delimiter )
                            {
                                menuRoot.Items.AddSeparator();
                            }

                            menuRoot.Items.Add(menuItem);
                        }
                    }
                }
                #endregion
            }
            this.ResumeLayout(false);
        }
Example #52
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;

            AStyle = new AStyleInterface();
            AStyle.LoadDefaults();
            AStyleInterface.LoadSettings(ref AStyle);

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

                #region Set up toolbar

                var commandBars = (CommandBars)_applicationObject.CommandBars;

                // Add a new toolbar
                CommandBar myTemporaryToolbar = null;
                try
                {
                    myTemporaryToolbar = commandBars[_toolBarName];
                }
                catch { }

                if (myTemporaryToolbar == null)
                    myTemporaryToolbar = commandBars.Add(_toolBarName, MsoBarPosition.msoBarTop, System.Type.Missing, false);

                Command optionsCommand = commands.AddNamedCommand2(_addInInstance, _optionsCommandStr, "Options", "Configure AstyleWrapper",
                     true, 2946, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled,
                     (int)vsCommandStyle.vsCommandStylePict, vsCommandControlType.vsCommandControlTypeButton);

                Command executeCommand = commands.AddNamedCommand2(_addInInstance, _execCommandStr, "Format selection", "Format selection",
                     true, 611, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled,
                     (int)vsCommandStyle.vsCommandStylePict, vsCommandControlType.vsCommandControlTypeButton);

                Command switchCommand = commands.AddNamedCommand2(_addInInstance, _switchCommandStr, "Switcher", AStyle.working ? _switchOffStr : _switchOnStr,
                    true, AStyle.working ? 1087 : 1088, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled,
                     (int)vsCommandStyle.vsCommandStylePict, vsCommandControlType.vsCommandControlTypeButton);

                // Add a new button on that toolbar

                //_switchCommandBtn = (CommandBarButton)switchCommand.AddControl(myTemporaryToolbar, myTemporaryToolbar.Controls.Count + 1);
                _switchCommandBtn = (CommandBarButton)switchCommand.AddControl(myTemporaryToolbar, myTemporaryToolbar.Controls.Count + 1);
                _optionsCommandBtn = (CommandBarButton)optionsCommand.AddControl(myTemporaryToolbar, myTemporaryToolbar.Controls.Count + 1);
                _execCommandBtn = (CommandBarButton)executeCommand.AddControl(myTemporaryToolbar, myTemporaryToolbar.Controls.Count + 1);

                // Make visible the toolbar
                myTemporaryToolbar.Visible = true;

                #endregion
            }
            else
            {
                // try get buttons
                var commandBars = (CommandBars)_applicationObject.CommandBars;
                try
                {
                    var myTemporaryToolbar = commandBars[_toolBarName];
                    _switchCommandBtn = (CommandBarButton)myTemporaryToolbar.Controls[1];
                    _execCommandBtn = (CommandBarButton)myTemporaryToolbar.Controls[2];
                    _optionsCommandBtn = (CommandBarButton)myTemporaryToolbar.Controls[3];
                }
                catch { }

                _hashes = new HashSet<int>();

                _textEditorEvents = _applicationObject.Events.get_TextEditorEvents(null);
                _textEditorEvents.LineChanged += new _dispTextEditorEvents_LineChangedEventHandler(_textEditorEvents_LineChanged);
            }
        }
Example #53
0
		public void CreateUIForChoiceGroup (ChoiceGroup group)
		{
			foreach(ChoiceRelatedClass item  in group)
			{
				CommandBar toolbar = (CommandBar)group.ReferenceWidget;
				Debug.Assert( toolbar != null);

				if(item is SeparatorChoice)
				{
					toolbar.Items.Add(new CommandBarSeparator());
				}
				else if(item is ChoiceBase)
				{
					ChoiceBase control=(ChoiceBase) item;
					//System.Windows.Forms.Keys shortcut = System.Windows.Forms.Keys.
					UIItemDisplayProperties display = control.GetDisplayProperties();
					display.Text  = display.Text .Replace("_", "");

					Image image =m_smallImages.GetImage(display.ImageLabel);
					CommandBarButton button = new CommandBarButton(image,display.Text, new EventHandler(OnClick));
					UpdateDisplay(display, button);
					button.Tag = control;

					control.ReferenceWidget = button;
					toolbar.Items.Add(button);
					button.IsEnabled = true;
				}
					//if this is a submenu
/*
 * I started playing with being able to have been used in here, but it. Complicated fast because
 * we would need to be referring over to the menubar adapter to fill in the menu items.
 * 				else if(item is ChoiceGroup)
				{
					if(((ChoiceGroup)item).IsSubmenu)
					{
						string label = item.Label.Replace("_", "&");
						CommandBarMenu submenu = new CommandBarMenu(label);// menu.Items.AddMenu(label);
						toolbar.Items.Add(submenu);
						submenu.Tag = item;
						item.ReferenceWidget = submenu;
						//submenu.IsEnabled= true;
						//the drop down the event seems to be ignored by the submenusof this package.
						//submenu.DropDown += new System.EventHandler(((ChoiceGroup)item).OnDisplay);
						//therefore, we need to populate the submenu right now and not wait
						((ChoiceGroup)item).OnDisplay(this, null);
						//this was enough to make the menu enabled, but not enough to trigger the drop down event when chosen
						//submenu.Items.Add(new CommandBarSeparator());
					}
//					else if(((ChoiceGroup)item).IsInlineChoiceList)
//					{
//						((ChoiceGroup)item).PopulateNow();
//						foreach(ChoiceRelatedClass inlineItem in ((ChoiceGroup)item))
//						{
//							Debug.Assert(inlineItem is ChoiceBase, "It should not be possible for a in line choice list to contain anything other than simple items!");
//							menu.Items.Add(CreateMenuItem ((ChoiceBase)inlineItem));
//						}
//					}

			}
*/			}
		}
Example #54
0
		private void SetupTreeviewContextMenu() 
		{
			treeviewContextMenu.Items.Clear();

			// get selected node
			TreeNode node = tvwProject.SelectedNode; //.GetNodeAt(tvwProject.PointToClient(Cursor.Position));
			if (node == null) {
				return; //node = tvwProject.SelectedNode;
			}

			if (_project == null || node == null || node.Tag == null) {
				return;
			}
			if (node.Tag.GetType() == typeof (Project)) {
				treeviewContextMenu.Items.Add(cbiEditProjectParameters);
				treeviewContextMenu.Items.Add(cbiRunProject);
			}
			if (node.Tag.GetType() == typeof (MetadataFile)) {
				CommandBarItem command;
				foreach (IMetadataEntity entity in ((MetadataFile) node.Tag).MetadataEntities) {
					if ((entity as Entity) != null) {
						command = new CommandBarButton(Images.Edit, "&Edit O/R Entity", new EventHandler(EditOREntity_Click));
						command.Tag = entity;
						treeviewContextMenu.Items.Add(command);
					}
				}
				command = new CommandBarButton(Images.Delete, "&Remove Metadata File", new EventHandler(RemoveMetadataFile_Click));
				treeviewContextMenu.Items.Add(command);
				command.Tag = node.Tag;
			}
			if (node.Tag.GetType() == typeof (MetadataFilePlaceholder)) {
				CommandBarItem command =
					new CommandBarButton(Images.DocumentText, "&Include Metadata File", new EventHandler(IncludeMetadataFile_Click));
				treeviewContextMenu.Items.Add(command);
				command.Tag = node.Tag;
			}
			if (node.Tag.GetType() == typeof (MetadataFileCollection)) {
				treeviewContextMenu.Items.Add(cbiAddExistingMetadataFile);
				treeviewContextMenu.Items.Add(cbiAddNewMetadataFile);
			}
			if (node.Tag.GetType() == typeof (CodeGeneratorCommand)) {
				CommandBarItem command;
				command = new CommandBarButton("&Edit Template", new EventHandler(EditTemplate_Click));
				command.Tag = node.Tag;
				treeviewContextMenu.Items.Add(command);
				command = new CommandBarButton(Images.ArrowGreen, "&Run Command", new EventHandler(RunCommand_Click));
				command.Tag = node.Tag;
				treeviewContextMenu.Items.Add(command);
				command = new CommandBarButton(Images.Delete, "Re&move Command", new EventHandler(RemoveCommand_Click));
				command.Tag = node.Tag;
				treeviewContextMenu.Items.Add(command);
			}
			if (node.Tag.GetType() == typeof (GeneratorCommandCollection)) {
				treeviewContextMenu.Items.Add(cbiAddCodeGenCommand);
			}
			if (node.Tag.GetType() == typeof (DataSourceCollection)) {
				treeviewContextMenu.Items.Add(cbiAddDataSource);
			}

		}
 public CommandBarButtonNodeFactory(CommandBarButton button) : base(button, false)
 {
     _button = button;
 }
Example #56
0
		private void SetupMRUList(CommandBarMenu fileMenu) {
			bool added = true;

			_mruList = new MRUList();

			foreach (MRUList.MRUEntry entry in _mruList) {
				if (entry.Path != null) {
					CommandBarButton item = new CommandBarButton(entry.ToString(), new EventHandler(MRUEntry_Click));
					item.Tag = entry;
					fileMenu.Items.Add(item);
					added = true;
				}
			}

			if (added) {
				fileMenu.Items.AddSeparator();
			}
		}
 public void Initialize(CommandBarPopup parentMenu)
 {
     _codeExplorerButton = AddButton(parentMenu, RubberduckUI.RubberduckMenu_CodeExplorer, true, new CommandBarButtonClickEvent(OnCodeExplorerButtonClick), 3039);
 }
 private void refreshButton_Click(CommandBarButton Ctrl, ref bool CancelDefault)
 {
     OnRefresh();
 }
Example #59
0
 void OnTestExplorerButtonClick(CommandBarButton Ctrl, ref bool CancelDefault)
 {
     _presenter.Show();
 }
 private void OnCodeExplorerButtonClick(CommandBarButton button, ref bool cancelDefault)
 {
     _presenter.Show();
 }