private void initiateCommandBar()
        {
            CommandBar bar = new CommandBar();
            AppBarButton logou = new AppBarButton() { Icon = new SymbolIcon(Symbol.Cancel), Label = "Log out" };
            logou.Click += logout;
            AppBarButton refr = new AppBarButton() { Icon = new BitmapIcon() { UriSource = new Uri("ms-appx:Assets/Buttons/appbar.refresh.png") }, Label = "Refresh" };
            refr.Click += refresh;
            AppBarButton search = new AppBarButton() { Icon = new SymbolIcon(Symbol.Find), Label = "Search" };
            search.Click += search_Click;

            AppBarButton ideas = new AppBarButton() { Label = "Suggest a feature" };
            ideas.Click += openForum;
            AppBarButton bugs = new AppBarButton() { Label = "Report a bug" };
            ideas.Click += openForum;
            AppBarButton contact = new AppBarButton() { Label = "Contact Developer" };
            contact.Click += sendEmail;

            bar.PrimaryCommands.Add(refr);
            bar.PrimaryCommands.Add(search);
            bar.PrimaryCommands.Add(logou);

            bar.SecondaryCommands.Add(ideas);
            bar.SecondaryCommands.Add(bugs);
            bar.SecondaryCommands.Add(contact);

            bar.ClosedDisplayMode = AppBarClosedDisplayMode.Minimal;

            BottomAppBar = bar;
        }
예제 #2
0
		public void CreateUIForChoiceGroupCollection(ChoiceGroupCollection groupCollection)
		{
			bool weCreatedTheBarManager = GetCommandBarManager();

			foreach(ChoiceGroup group in groupCollection)
			{
				CommandBar toolbar = new CommandBar(CommandBarStyle.ToolBar);
				toolbar.Tag = group;
				group.ReferenceWidget = toolbar;

				//whereas the system was designed to only populate groups when
				//the OnDisplay method is called on a group,
				//this particular widget really really wants to have all of the buttons
				//populated before it gets added to the window.
				//therefore, we don't hope this up but instead call a bogus OnDisplay() now.
				//toolbar.VisibleChanged  += new System.EventHandler(group.OnDisplay);

				group.OnDisplay(null,null);

				this.m_commandBarManager.CommandBars.Add(toolbar);
			}

			if(weCreatedTheBarManager)
				m_window.Controls.Add(m_commandBarManager);
		}
예제 #3
0
        public static void AddBottomAppBar(Page myPage)
        {
            var commandBar = new CommandBar();
            var searchButton = new AppBarButton
            {
                Label = "Поиск",
                Icon = new SymbolIcon(Symbol.Find),
            };

            var aboutButton = new AppBarButton
            {
                Label = "О прилож.",
                Icon = new SymbolIcon(Symbol.Help),
            };

            if (RootFrame != null)
            {
                searchButton.Click += SearchButtonClick;
                aboutButton.Click += AboutButtonClick;
            }

            commandBar.PrimaryCommands.Add(searchButton);
            commandBar.PrimaryCommands.Add(aboutButton);
            myPage.BottomAppBar = commandBar;
        }
예제 #4
0
        public static CommandBar ToAppCommandBar(this IContextMenu source, CommandBar menu, bool isSecondary)
        {
            var commandsVector = isSecondary ? menu.SecondaryCommands : menu.PrimaryCommands;
            commandsVector.Clear();

            foreach(var item in source.Items)
            {
                AppBarButton button = new AppBarButton();
                commandsVector.Add(button);
                button.Label = item.Header;
                button.Command = item.Command;
                button.CommandParameter = item.CommandParameter;

                if (!string.IsNullOrEmpty(item.Icon))
                {
                    var icon = new SymbolIcon();
                    icon.Symbol = (Symbol)System.Enum.Parse(typeof(Symbol), item.Icon);
                    button.Icon = icon;
                }
                else
                    button.Icon = new SymbolIcon(Symbol.Emoji);
            }

            return menu;
        }
예제 #5
0
        public ApplicationWindow()
        {
            this.Icon = new Icon(this.GetType().Assembly.GetManifestResourceStream("Resourcer.Application.ico"));
            this.Font = new Font("Tahoma", 8.25f);
            this.Text = (this.GetType().Assembly.GetCustomAttributes(typeof(System.Reflection.AssemblyTitleAttribute), false)[0] as System.Reflection.AssemblyTitleAttribute).Title;
            this.Size = new Size(480, 600);
            this.MinimumSize = new Size (240, 300);

            this.resourceBrowser = new ResourceBrowser();
            this.resourceBrowser.Dock = DockStyle.Fill;
            this.Controls.Add(this.resourceBrowser);

            this.verticalSplitter = new Splitter ();
            this.verticalSplitter.Dock = DockStyle.Bottom;
            this.verticalSplitter.BorderStyle = BorderStyle.None;
            this.Controls.Add(this.verticalSplitter);

            this.resourceViewer = new ResourcerViewer();
            this.resourceViewer.Dock = DockStyle.Bottom;
            this.resourceViewer.Height = 100;
            this.Controls.Add(this.resourceViewer);

            this.statusBar = new StatusBar();
            this.Controls.Add(this.statusBar);

            this.commandBarManager = new CommandBarManager();
            this.menuBar = new CommandBar(this.commandBarManager, CommandBarStyle.Menu);
            this.commandBarManager.CommandBars.Add(this.menuBar);
            this.toolBar = new CommandBar(this.commandBarManager, CommandBarStyle.ToolBar);
            this.commandBarManager.CommandBars.Add(this.toolBar);
            this.Controls.Add(this.commandBarManager);
        }
		public virtual bool RegisterGUI(Command vsCommand, CommandBar vsCommandbar, bool toolBarOnly)
		{
			// The default command is registered in the toolbar.
			if(IconIndex >= 0 && toolBarOnly)
				vsCommand.AddControl(vsCommandbar, vsCommandbar.Controls.Count + 1);

			return true;
		}
예제 #7
0
 public static void SetCommandBar(DependencyObject obj, CommandBar value)
 {
     if (obj == null)
     {
         throw new ArgumentNullException("obj");
     }
     obj.SetValue(CommandBarProperty, value);
 }
예제 #8
0
 public static CommandBar GetSolutionCommandBar(this DTE2 application)
 {
     if (_solutionCommandBar == null)
     {
         _solutionCommandBar = ((CommandBars)application.CommandBars)["Solution"];
     }
     return _solutionCommandBar;
 }
예제 #9
0
 public static CommandBar GetCodeWindowCommandBar(this DTE2 application)
 {
     if (_codeWindowCommandBar == null)
     {
         _codeWindowCommandBar = ((CommandBars)application.CommandBars)["Code Window"];
     }
     return _codeWindowCommandBar;
 }
예제 #10
0
 public static CommandBar GetProjectCommandBar(this DTE2 application)
 {
     if (_projectCommandBar == null)
     {
         _projectCommandBar = ((CommandBars)application.CommandBars)["Project"];
     }
     return _projectCommandBar;
 }
			public override bool RegisterGUI(Command vsCommand, CommandBar vsCommandbar, bool toolBarOnly)
			{
				if(!toolBarOnly)
				{
					_RegisterGuiContext(vsCommand, "Solution");
				}
				return true;
			}
예제 #12
0
        public CommandBarButton AddButtonToCmdBar(CommandBar cmdBar, int beforeIndex, string caption, string tooltip)
        {
            CommandBarButton button = cmdBar.Controls.Add(MsoControlType.msoControlButton,
                        Type.Missing, Type.Missing, beforeIndex, true) as CommandBarButton;
            button.Caption = caption;
            button.TooltipText = tooltip;

            return button;
        }
예제 #13
0
 public CommandRegistry(Plugin plugin, CommandBar commandBar, Guid packageGuid, Guid cmdGroupGuid)
 {
     mCommands = new Dictionary<string, CommandBase>();
     mCommandsById = new Dictionary<uint, CommandBase>();
     mPlugin = plugin;
     mCommandBar = commandBar;
     mPackageGuid = packageGuid;
     mCmdGroupGuid = cmdGroupGuid;
 }
예제 #14
0
		public System.Windows.Forms.Control Init (System.Windows.Forms.Form window,  IImageCollection smallImages, IImageCollection largeImages, Mediator mediator)
		{
			m_window = window;
			m_smallImages = smallImages;
			m_largeImages = largeImages;
			m_menuBar = new CommandBar(CommandBarStyle.Menu);

			return null; //this is not available yet. caller should call GetCommandBarManager() after CreateUIForChoiceGroupCollection() is called
		}
예제 #15
0
		protected override void Dispose(bool fDisposing)
		{
			if (fDisposing)
			{
				if (m_menuBar != null)
					m_menuBar.Dispose();
			}
			m_menuBar = null;
			base.Dispose(fDisposing);
		}
예제 #16
0
        public NewAlarmView()
        {
            this.InitializeComponent();

            this.navigationHelper = new NavigationHelper(this);
            this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
            this.navigationHelper.SaveState += this.NavigationHelper_SaveState;
            //defaultViewModel.Add("newAlarm", new NewAlarmViewModel());
            alarmViewCommandBar = BottomAppBar as CommandBar;
        }
        private CommandBarPopup CreateFmgPopupMenu( CommandBar mainMenuBar, int menuPositionOnBar )
        {
            CommandBarPopup fmgPluginsPopupMenu = mainMenuBar.Controls.Add( MsoControlType.msoControlPopup, Type.Missing, Type.Missing, menuPositionOnBar, true ) as CommandBarPopup;

            if ( fmgPluginsPopupMenu != null )
            {
                fmgPluginsPopupMenu.Caption = "FMG Plug-ins";
            }

            return fmgPluginsPopupMenu;
        }
예제 #18
0
        public int Add(CommandBar commandBar)
        {
            if (!this.Contains(commandBar))
            {
                int index = this.bands.Add(commandBar);
                this.commandBarManager.UpdateBands();
                return index;
            }

            return -1;
        }
 /// <summary>
 /// Returns an instance of the selected command bar by name
 /// </summary>
 /// <param name="commandBars">A vector of command bars</param>
 /// <param name="commandBarName">Command bar name</param>
 /// <param name="commandBar">Handle of the selected command bar</param>
 private void getCommandBarInstanceByName(CommandBars commandBars, string commandBarName, out CommandBar commandBar)
 {
     try
     {
         commandBar = null;
         commandBar = Globals.ThisAddIn.Application.CommandBars[commandBarName];
     }
     catch (Exception)
     {
         commandBar = null;
     }
 }
예제 #20
0
            public CommandsListMonitor(CommandBar bar,
                IObservableCollection<AppBarCommandViewModel> source)
            {
                if (bar == null) throw new ArgumentNullException("bar");
                if (source == null) throw new ArgumentNullException("source");

                _bar = bar;
                _source = source;

                _bar.Unloaded += OnUnloaded;
                _source.CollectionChanged += OnCollectionChanged;
            }
예제 #21
0
 public static void RefreshUIOnDataLoaded(ProgressBar pb, CommandBar cb)
 {
     if (cb != null)
     {
         cb.Visibility = Windows.UI.Xaml.Visibility.Visible;
     }
     if (pb != null)
     {
         pb.IsIndeterminate = false;
         pb.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
     }
 }
예제 #22
0
        public static void SwitchState(CommandBar appBar, IEnumerable<ICommandBarElement> primary,
            IEnumerable<ICommandBarElement> secondary = null)
        {
            appBar.PrimaryCommands.Clear();
            appBar.SecondaryCommands.Clear();

            if (primary != null)
                appBar.PrimaryCommands.AddRange(primary);

            if (secondary != null)
                appBar.SecondaryCommands.AddRange(secondary);
        }
예제 #23
0
    public void Init(CommandBar commandBar)
    {
        this.commandBar = commandBar;
        gameObject.layer = commandBar.Layer;

        var collider = gameObject.GetComponent<BoxCollider2D>();
        collider.size = new Vector2(1f, 1f);

        var renderer = gameObject.GetComponent<SpriteRenderer>();
        renderer.sprite = commandBar.DefaultButtonImage;
        renderer.sortingLayerName = "GUI";
        renderer.sortingOrder = 5;
    }
예제 #24
0
        public static void BlockNavigation(bool hideNavBar = true)
        {
            SupressBackEvents = true;

            if (!hideNavBar) return;

            _commandBar = (App.RootFrame.Content as Page).BottomAppBar as CommandBar;

            if (_commandBar != null)
            {
                _commandPrevVisibility = _commandBar.Visibility;
                _commandBar.Visibility = Visibility.Collapsed;
            }
        }
예제 #25
0
        public static void RestorePreviousState(CommandBar appBar)
        {
            if (_originalCommands != null)
            {
                appBar.PrimaryCommands.Clear();
                appBar.PrimaryCommands.AddRange(_originalCommands);
            }

            if (_originalSecondaryCommands != null)
            {
                appBar.SecondaryCommands.Clear();
                appBar.SecondaryCommands.AddRange(_originalSecondaryCommands);
            }
        }
예제 #26
0
 public override bool RegisterGUI(OleMenuCommand vsCommand, CommandBar vsCommandbar, bool toolBarOnly)
 {
     if (toolBarOnly)
     {
         _RegisterGUIBar(vsCommand, vsCommandbar);
     }
     else
     {
         _RegisterGuiContext(vsCommand, "Project");
         _RegisterGuiContext(vsCommand, "Item");
         _RegisterGuiContext(vsCommand, "Easy MDI Document Window");
     }
     return true;
 }
        private void PutMenuCommandsOnCommandBar( CommandBar commandBar )
        {
            Commands commands = _pluginContext.Application.Commands;

            foreach ( FMGPluginMenuItem fmgPluginMenuItem in FMGPluginMenu.MenuItems )
            {
                Command command = commands.AddNamedCommand( _pluginContext.AddInInstance, fmgPluginMenuItem.Id, fmgPluginMenuItem.DisplayName, fmgPluginMenuItem.DisplayName, true );

                var commandBarButton = ( CommandBarButton )command.AddControl( commandBar, fmgPluginMenuItem.Order );

                commandBarButton.Enabled = true;
                commandBarButton.Visible = true;
                commandBarButton.Caption = fmgPluginMenuItem.DisplayName;
            }
        }
예제 #28
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Deletes the toolbar.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public void DeleteToolbar()
		{
			try
			{
				if (m_cmdBar != null)
				{
					DTE.Commands.RemoveCommandBar(m_cmdBar);
					m_cmdBar = null;
				}
			}
			catch(Exception e)
			{
				System.Diagnostics.Debug.WriteLine("Got exception deleting toolbar: " + e.Message);
			}
		}
예제 #29
0
        /// <summary>
        /// Получить нижнюю строку команд.
        /// </summary>
        /// <returns>Строка команд.</returns>
        public AppBar GetBottomAppBar()
        {
            var appBar = new CommandBar();

            var syncButton = new AppBarButton()
            {
                Label = "Обновить",
                Icon = new SymbolIcon(Symbol.Sync)
            };

            syncButton.Click += SyncButtonOnClick;

            appBar.PrimaryCommands.Add(syncButton);

            return appBar;
        }
예제 #30
0
        public AppBar GetBottomAppBar()
        {
            var appBar = new CommandBar();

            var saveButton = new AppBarButton()
            {
                Label = "Сохранить",
                Icon = new SymbolIcon(Symbol.Accept)
            };

            saveButton.Click += SaveButtonOnClick;

            appBar.PrimaryCommands.Add(saveButton);

            return appBar;
        }
예제 #31
0
        private void SetCommandBarState(bool activate)
        {
            bool enabled;

            if (activate && _openDocuments == 1)
            {
                enabled = true;
            }
            else if (activate == false && _openDocuments == 0)
            {
                enabled = false;
            }
            else
            {
                return;
            }

            CommandBar bar = GetCommandBar();

            GetControl(bar, TagValidateButton).Enabled  = enabled;
            GetControl(bar, TagExportXMLButton).Enabled = enabled;
        }
예제 #32
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _split = GetTemplateChild("SplitView") as SplitView;
            if (_split == null)
            {
                return;
            }

            var paneToggle = GetTemplateChild("PaneTogglePane") as Windows.UI.Xaml.Controls.Button;

            if (paneToggle != null)
            {
                paneToggle.Click += OnToggleClicked;
            }

            var contentToggle = GetTemplateChild("ContentTogglePane") as Windows.UI.Xaml.Controls.Button;

            if (contentToggle != null)
            {
                contentToggle.Click += OnToggleClicked;
            }

            _masterPresenter = GetTemplateChild("MasterPresenter") as FrameworkElement;
            _detailPresenter = GetTemplateChild("DetailPresenter") as FrameworkElement;

            _commandBar = GetTemplateChild("CommandBar") as CommandBar;

            UpdateMode();

            TaskCompletionSource <CommandBar> tcs = _commandBarTcs;

            if (tcs != null)
            {
                _commandBarTcs = null;
                tcs.SetResult(_commandBar);
            }
        }
예제 #33
0
        /*
         * CreateAddInMenu
         */

        /// <summary>
        /// </summary>
        /// <param name="menuCommand"></param>
        /// <param name="commandBarToAddMenuTo"></param>
        /// <param name="menuPosition"></param>
        /// <exception cref="ArgumentNullException">
        /// <para>
        ///		<paramref name="menuCommand"/> is <see langword="null"/>.
        /// </para>
        /// -or-
        /// <para>
        ///		<paramref name="commandBarToAddMenuTo"/> is <see langword="null"/>.
        /// </para>
        /// </exception>
        public static CommandBarControl CreateAddInMenu(
            Command menuCommand,
            CommandBar commandBarToAddMenuTo,
            int menuPosition
            )
        {
            if (menuCommand == null)
            {
                throw new ArgumentNullException("menuCommand");
            }

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

            CommandBarControl menuItem = null;

            try
            {
                menuItem = (CommandBarControl)menuCommand.AddControl(commandBarToAddMenuTo, menuPosition);
            }
            catch (Exception e)
            {
                if (_errorEnabled)
                {
                    Trace.TraceError(e.Message);
                }
            }
            finally
            {
                if (menuItem != null)
                {
                    menuItem.Visible = true;
                }
            }

            return(menuItem);
        }
예제 #34
0
        public Shell(Frame frame)
        {
            Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().SetPreferredMinSize(
                new Windows.Foundation.Size {
                Width = 320, Height = 320
            });                                                             //set this in appxmanifest when it b ecomes an option

            this.contentFrame = frame;
            this.InitializeComponent();
            cb = this.CommandBar;

            this.ShellSplitView.Content = frame;
            var update = new Action(() =>
            {
                this.ShellSplitView.IsPaneOpen = false;
            });

            frame.Navigated += (s, e) => update();

            this.Loaded     += (s, e) => update();
            this.DataContext = this;
        }
예제 #35
0
        public TCommand Add <TCommand>(CommandBar bar, int atIndex)
            where TCommand : ButtonCommand, new()
        {
            _logger.Log(Level.DEBUG, "Adding command " + typeof(TCommand).Name + " on " + bar.Name + " at index " + atIndex);

            TCommand command = getOrCreate <TCommand>();

            CommandBarButton ctl = (CommandBarButton)
                                   bar.Controls.Add(MsoControlType.msoControlButton,
                                                    System.Type.Missing, System.Type.Missing, atIndex, true);

            ctl.Click += delegate(CommandBarButton btn, ref bool Cancel)
            {
                command.Execute(_buildContext());
            };
            ctl.Caption = command.Caption;
            ctl.Visible = true;

            _keepReferences.Add(ctl);

            return(command);
        }
예제 #36
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _split = GetTemplateChild("SplitView") as SplitView;
            if (_split == null)
            {
                return;
            }

            var paneToggle = GetTemplateChild("PaneTogglePane") as Windows.UI.Xaml.Controls.Button;

            if (paneToggle != null)
            {
                paneToggle.Click += OnToggleClicked;
            }

            var contentToggle = GetTemplateChild("ContentTogglePane") as Windows.UI.Xaml.Controls.Button;

            if (contentToggle != null)
            {
                contentToggle.Click += OnToggleClicked;
            }

            _masterPresenter    = GetTemplateChild("MasterPresenter") as FrameworkElement;
            _detailPresenter    = GetTemplateChild("DetailPresenter") as FrameworkElement;
            _titleViewPresenter = GetTemplateChild("TitleViewPresenter") as FrameworkElement;

            _commandBar = GetTemplateChild("CommandBar") as CommandBar;
            _toolbarPlacementHelper.Initialize(_commandBar, () => ToolbarPlacement, GetTemplateChild);
            UpdateToolbarDynamicOverflowEnabled();

            UpdateMode();

            if (_commandBarTcs != null)
            {
                _commandBarTcs.SetResult(_commandBar);
            }
        }
        public static void UpdateToolbarPlacement(CommandBar toolbar, ToolbarPlacement toolbarPlacement, Border bottomCommandBarArea, Border topCommandBarArea)
        {
            if (toolbar == null || bottomCommandBarArea == null || topCommandBarArea == null)
            {
                // Haven't applied the template yet, so we're not ready to do this
                return;
            }

            // Figure out what's hosting the command bar right now
            var current = toolbar.Parent as Border;

            // And figure out where it should be
            Border target;

            switch (toolbarPlacement)
            {
            case ToolbarPlacement.Top:
                target = topCommandBarArea;
                break;

            case ToolbarPlacement.Bottom:
                target = bottomCommandBarArea;
                break;

            case ToolbarPlacement.Default:
            default:
                target = Device.Idiom == TargetIdiom.Phone ? bottomCommandBarArea : topCommandBarArea;
                break;
            }

            if (current == null || target == null || current == target)
            {
                return;
            }

            // Remove the command bar from its current host and add it to the new one
            current.Child = null;
            target.Child  = toolbar;
        }
예제 #38
0
        public ApplicationWindow()
        {
            this.Icon = IconResource.Application;
            this.Font = new Font("Tahoma", 8.25f);

            this.StartPosition = FormStartPosition.WindowsDefaultLocation;

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

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

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

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

            this.Controls.Add(statusBar);
        }
        /// <summary>
        /// Step4. Add command to Tool menubar by getting CommandBar with name "MenuBar" and its
        /// child CommandBarPopup control "Tools" and adding command into it.
        /// </summary>
        /// <param name="applicationObject"></param>
        /// <param name="command"></param>
        private void AddCommandToToolMenubar(DTE2 applicationObject, Command command)
        {
            string toolsMenuName = "Tools";

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

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

            //Add a control for the command to the tools menu:
            if ((command != null) && (toolsPopup != null))
            {
                CommandBarControl commandBarControl =
                    (CommandBarControl)command.AddControl(toolsPopup.CommandBar, 1);
                commandBarControl.Caption = "All-In-One Add-In";
            }
        }
예제 #40
0
파일: Connect.cs 프로젝트: bazile/VsAddons
        //public Connect()
        //{
        //    // Place your initialization code within this method
        //}

        /// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
        /// <param name='application'>Root object of the host application.</param>
        /// <param name='connectMode'>Describes how the Add-in is being loaded.</param>
        /// <param name='addInInst'>Object representing this Add-in.</param>
        /// <param name="custom"></param>
        /// <seealso class='IDTExtensibility2' />
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            _applicationObject = (DTE2)application;
            _addInInstance     = (AddIn)addInInst;
            if (connectMode == ext_ConnectMode.ext_cm_UISetup)
            {
                object []    contextGUIDS  = new object[] { };
                Commands2    commands      = (Commands2)_applicationObject.Commands;
                const string toolsMenuName = "Tools";

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

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

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

                    //Add a control for the command to the tools menu:
                    if ((command != null) && (toolsPopup != null))
                    {
                        command.AddControl(toolsPopup.CommandBar, 1);
                    }
                }
                catch (ArgumentException)
                {
                    //If we are here, then the exception is probably because a command with that name
                    //  already exists. If so there is no need to recreate the command and we can
                    //  safely ignore the exception.
                }
            }
        }
        private void InstallButton(CommandBar cb, string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                _beginGrouop = true;
                return;
            }

            CommandBarButton thisButton;

            _buttons.TryGetValue(id, out thisButton);

            // Recreate the button, otherwise it's state may be broken in Visio in some cases
            if (thisButton != null)
            {
                thisButton.Click -= CommandBarButtonClicked;
                _buttons.Remove(id);
                Marshal.ReleaseComObject(thisButton);
            }

            var button = (CommandBarButton)cb.FindControl(Tag: id) ??
                         (CommandBarButton)cb.Controls.Add(MsoControlType.msoControlButton);

            button.Enabled = Globals.ThisAddIn.IsCommandEnabled(id);

            var checkState = Globals.ThisAddIn.IsCommandChecked(id);

            button.State = checkState ? MsoButtonState.msoButtonDown : MsoButtonState.msoButtonUp;

            button.BeginGroup      = _beginGrouop;
            button.Tag             = id;
            button.Caption         = Globals.ThisAddIn.GetCommandLabel(id);
            button.DescriptionText = Globals.ThisAddIn.GetCommandSupertip(id);
            SetCommandBarButtonImage(button, id);

            button.Click += CommandBarButtonClicked;

            _buttons.Add(id, button);
        }
예제 #42
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _backButton = GetTemplateChild("backButton") as AppBarButton;
            if (_backButton != null)
            {
                _backButton.Click += OnBackClicked;
            }

            _presenter = GetTemplateChild("presenter") as Windows.UI.Xaml.Controls.ContentPresenter;

            _commandBar = GetTemplateChild("CommandBar") as CommandBar;
#if WINDOWS_UWP
            _bottomCommandBarArea = GetTemplateChild("BottomCommandBarArea") as Border;
            _topCommandBarArea    = GetTemplateChild("TopCommandBarArea") as Border;
            UpdateToolbarPlacement();
#endif

            TaskCompletionSource <CommandBar> tcs = _commandBarTcs;
            tcs?.SetResult(_commandBar);
        }
        private CommandBar RecurseCommandBarToFindCommandBarByName(CommandBar bar, string name)
        {
            //try
            //{
            //    CommandBarControl ctrl = bar.Controls[name]; //only works for US and international VS in VS2010
            //    return ((CommandBarPopup)ctrl).CommandBar;
            //}
            //catch { }

            //idea from http://www.mztools.com/articles/2007/MZ2007002.aspx
            if (bar.Name == name)
            {
                return(bar);
            }
            //foreach (CommandBarControl cmd in bar.Controls)
            //{
            //    if (cmd.Type == MsoControlType.msoControlPopup)
            //    {
            //        CommandBarPopup popup = (CommandBarPopup)cmd;
            //        if (popup.CommandBar.Name == name)
            //        {
            //            return popup.CommandBar;
            //        }
            //    }
            //}
            foreach (CommandBarControl cmd in bar.Controls)
            {
                if (cmd.Type == MsoControlType.msoControlPopup)
                {
                    CommandBarPopup popup      = (CommandBarPopup)cmd;
                    CommandBar      oReturnVal = RecurseCommandBarToFindCommandBarByName(popup.CommandBar, name);
                    if (oReturnVal != null)
                    {
                        return(oReturnVal);
                    }
                }
            }
            return(null);
        }
예제 #44
0
        public void seleccionarCachorroActivo(Mascota cachorro)
        {
            mascotaSeleccionada = cachorro;
            CommandBar   commandBar   = new CommandBar();
            AppBarButton appBarButton = new AppBarButton();

            appBarButton.Icon   = new SymbolIcon(Symbol.Add);
            appBarButton.Label  = "Agregar";
            appBarButton.Click += agregarCachorro;
            commandBar.PrimaryCommands.Add(appBarButton);
            appBarButton        = new AppBarButton();
            appBarButton.Icon   = new SymbolIcon(Symbol.Delete);
            appBarButton.Label  = "Eliminar";
            appBarButton.Click += eliminarMascota;
            commandBar.PrimaryCommands.Add(appBarButton);
            appBarButton        = new AppBarButton();
            appBarButton.Icon   = new SymbolIcon(Symbol.Edit);
            appBarButton.Label  = "Editar";
            appBarButton.Click += editarMascota;
            commandBar.PrimaryCommands.Add(appBarButton);
            paginaPrincipal.BottomAppBar = commandBar;
        }
예제 #45
0
        /// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification
        /// that the Add-in is being loaded.</summary>
        /// <param term='application'>Root object of the host application.</param>
        /// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
        /// <param term='addInInst'>Object representing this Add-in.</param>
        /// <seealso class='IDTExtensibility2' />
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            _applicationObject = (DTE2)application;
            _addInInstance     = (AddIn)addInInst;

            if (connectMode == ext_ConnectMode.ext_cm_UISetup)
            {
                Commands2 commands      = (Commands2)_applicationObject.Commands;
                string    toolsMenuName = "Tools";
                object[]  contextGUIDs  = new object[] { };

                CommandBar        menuBarCommandBar = ((CommandBars)_applicationObject.CommandBars)["MenuBar"];
                CommandBarControl toolsControl      = menuBarCommandBar.Controls[toolsMenuName];
                CommandBarPopup   toolsPopup        = (CommandBarPopup)toolsControl;

                try
                {
                    Command command = commands.AddNamedCommand2(
                        _addInInstance,
                        "SSMSQueryHistory",
                        "SSMS Query History",
                        "Opens the SSMS Query History search window",
                        true,
                        183,
                        ref contextGUIDs,
                        (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled,
                        (int)vsCommandStyle.vsCommandStylePictAndText,
                        vsCommandControlType.vsCommandControlTypeButton);

                    if ((command != null) && (toolsPopup != null))
                    {
                        command.AddControl(toolsPopup.CommandBar, 1);
                    }
                }
                catch (System.ArgumentException)
                {
                }
            }
        }
예제 #46
0
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            const string barNameKey = "myBar";

            CommandBar cmd    = null;
            CommandBar cmdTmp = null;

            for (int i = 1; i <= Application.ActiveExplorer().CommandBars.Count; i++)
            {
                cmdTmp = Application.ActiveExplorer().CommandBars[i];
                if (cmdTmp.Name.Equals(barNameKey))
                {
                    cmd = cmdTmp;
                    break;
                }
            }

            if (cmd == null)
            {
                CommandBar cmdtmp = Application.ActiveExplorer().CommandBars.Add(
                    "myBar",
                    MsoBarPosition.msoBarTop,
                    missing,
                    missing);
            }
            cmd.Visible = true;

            CommandBarButton ctr = (CommandBarButton)cmd.Controls.Add(
                MsoControlType.msoControlButton,
                1,
                "Name",
                this.missing,
                true
                );

            ctr.Caption = "Globant Button";
            ctr.Click  += ctr_Click;
        }
예제 #47
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, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
        {
            applicationObject = (_DTE)application;
            addInInstance     = (AddIn)addInInst;

            if (connectMode == Extensibility.ext_ConnectMode.ext_cm_UISetup)
            {
                object []    contextGUIDS = new object[] { };
                Commands     commands     = applicationObject.Commands;
                _CommandBars commandBars  = applicationObject.CommandBars;

                // When run, the Add-in wizard prepared the registry for the Add-in.
                // At a later time, the Add-in or its commands may become unavailable for reasons such as:
                //   1) You moved this project to a computer other than which is was originally created on.
                //   2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in.
                //   3) You add new commands or modify commands already defined.
                // You will need to re-register the Add-in by building the BusinessObjectJumpStartSetup project,
                // right-clicking the project in the Solution Explorer, and then choosing install.
                // Alternatively, you could execute the ReCreateCommands.reg file the Add-in Wizard generated in
                // the project directory, or run 'devenv /setup' from a command prompt.
                try
                {
                    Command command = commands.AddNamedCommand(addInInstance,
                                                               "BusinessObjectJumpStart",
                                                               "BusinessObjectJumpStart",
                                                               "Executes the command for .NET Business Objects 2003",
                                                               true,
                                                               274,
                                                               ref contextGUIDS,
                                                               (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled);
                    CommandBar        commandBar        = (CommandBar)commandBars["Tools"];
                    CommandBarControl commandBarControl = command.AddControl(commandBar, 1);
                }
                catch (System.Exception /*e*/)
                {
                }
            }
        }
예제 #48
0
        private void ContextMenuStripDelete_Opening(object sender, CancelEventArgs eventArgs)
        {
            eventArgs.Cancel = true;

            TreeViewHitTestInfo treeViewHitTestInfo = this.TreeView.HitTest(this.TreeView.PointToClient(Cursor.Position));

            if (treeViewHitTestInfo == null)
            {
                m_CurrentDeleteTreeNode = null;
                return;
            }

            if (treeViewHitTestInfo.Location != TreeViewHitTestLocations.Label)
            {
                m_CurrentDeleteTreeNode = null;
                return;
            }

            if (treeViewHitTestInfo.Node == null)
            {
                m_CurrentDeleteTreeNode = null;
                return;
            }

            if (treeViewHitTestInfo.Node.Parent != null && treeViewHitTestInfo.Node.Text == "所有的股票")
            {
                m_CurrentDeleteTreeNode = null;
                return;
            }

            m_CurrentDeleteTreeNode = treeViewHitTestInfo.Node;

            CommandBar popupCommandBar = MainForm.Instance.AxCommandBars.Add("ConfigAControl", XTPBarPosition.xtpBarPopup);

            CommandBarControl commandBarControl = popupCommandBar.Controls.Add(XTPControlType.xtpControlButton, ResourceId.ID_CONFIG_FORM_TREEVIEW_DELETE, "删除(&D)", -1, false);

            popupCommandBar.ShowPopup(XTPTrackPopupFlags.TPM_RIGHTBUTTON, null, null);
        }
예제 #49
0
        protected override void OnApplyTemplate()
        {
            _toggle      = base.GetTemplateChild("toggle") as Button;
            _exitFS      = base.GetTemplateChild("exitFS") as Button;
            _splitView   = base.GetTemplateChild("splitView") as SplitView;
            _commandBarT = base.GetTemplateChild("commandBarT") as CommandBar;
            _commandBarB = base.GetTemplateChild("commandBarB") as CommandBar;
            _paneContent = base.GetTemplateChild("paneContent") as Panel;
            _lview       = base.GetTemplateChild("lview") as ListView;
            _lviewSub    = base.GetTemplateChild("lviewSub") as ListView;
            _container   = base.GetTemplateChild("container") as Panel;
            _content     = base.GetTemplateChild("content") as Panel;
            _panes       = base.GetTemplateChild("panes") as Panel;
            _presenter   = base.GetTemplateChild("presenter") as ContentPresenter;
            _topPane     = base.GetTemplateChild("topPane") as ContentControl;
            _rightPane   = base.GetTemplateChild("rightPane") as ContentControl;
            _clip        = base.GetTemplateChild("clip") as RectangleGeometry;

            _lview.ItemContainerStyleSelector    = new NavigationStyleSelector(_lview.ItemContainerStyle, this.SeparatorStyle);
            _lview.ItemContainerStyle            = null;
            _lviewSub.ItemContainerStyleSelector = new NavigationStyleSelector(_lview.ItemContainerStyle, this.SeparatorStyle);
            _lviewSub.ItemContainerStyle         = null;

            _toggle.Click           += OnToggleClick;
            _exitFS.Click           += OnExitFSClick;
            _splitView.PaneClosed   += OnPaneClosed;
            _lview.ItemClick        += OnItemClick;
            _lviewSub.ItemClick     += OnItemClick;
            _lview.SelectionChanged += OnSelectionChanged;

            _isInitialized = true;

            this.ArrangeCommands();

            this.SizeChanged += OnSizeChanged;

            base.OnApplyTemplate();
        }
예제 #50
0
        private CommandBarPopup GetCommandBarPopup(string name, CommandBar parentCommandBar)
        {
            CommandBarPopup result    = null;
            string          localName = this.GetLocalizedName(name);

            foreach (CommandBarControl control in parentCommandBar.Controls)
            {
                if (control is CommandBarPopup)
                {
                    CommandBarPopup popup = (CommandBarPopup)control;
                    Debug.WriteLine("Name: " + popup.CommandBar.Name);



                    if (localName.Equals(popup.CommandBar.Name, StringComparison.InvariantCultureIgnoreCase))
                    {
                        result = popup;
                        break;
                    }
                }
            }
            return(result);
        }
예제 #51
0
        private void CleanUpPopup(CommandBar commandBar, string name)
        {
            Debug.WriteLine("Commandbars to delete: " + commandBar.Controls.Count);
            List <CommandBarPopup> popups = new List <CommandBarPopup>();

            foreach (CommandBarControl control in commandBar.Controls)
            {
                if (control is CommandBarPopup)
                {
                    popups.Add(control as CommandBarPopup);
                }
            }

            foreach (CommandBarPopup commandbarPopup in popups)
            {
                if (commandbarPopup.CommandBar.Name == name)
                {
                    CleanUpControls(commandbarPopup);
                    Debug.WriteLine("Commandbar delete: " + commandbarPopup.CommandBar.Name + " from Bar " + commandBar.Name);
                    commandbarPopup.Delete(false);
                }
            }
        }
예제 #52
0
        /// <summary>
        /// return the CommandBar that the CommandBarControl represents.
        /// </summary>
        /// <param name="InControl"></param>
        /// <returns></returns>
        public static CommandBar ControlToCommandBar(CommandBarControl InControl)
        {
            CommandBar bar = null;

            if (InControl == null)
            {
                throw new ArgumentNullException(
                          "InControl", "Control to convert to CommandBar is null");
            }

            else if (InControl.Type == MsoControlType.msoControlPopup)
            {
                CommandBarPopup pu = (CommandBarPopup)InControl;
                bar = pu.CommandBar;
            }

            else
            {
                throw new ArgumentException("Control type " + InControl.Type.ToString() +
                                            " not supported by ControlToCommandBar method.");
            }
            return(bar);
        }
예제 #53
0
        private void GitPluginUISetupCommandBar()
        {
            // Try to delete the commandbar if it exists from a previous execution,
            // because the /resetaddin command-line switch of VS 2005 (or higher) add-in
            // projects only resets commands and buttons, not commandbars
            _gitPlugin.DeleteGitExtCommandBar();

            try
            {
                CommandBar commandBar = _gitPlugin.AddGitExtCommandBar(MsoBarPosition.msoBarTop);

                _gitPlugin.AddToolbarCommandWithText(commandBar, "Commit", "Commit", "Commit changes", 7, 1);
                _gitPlugin.AddToolbarCommand(commandBar, "Browse", "Browse", "Browse repository", 12, 2);
                _gitPlugin.AddToolbarCommand(commandBar, "Pull", "Pull", "Pull changes from remote repository", 9, 3);
                _gitPlugin.AddToolbarCommand(commandBar, "Push", "Push", "Push changes to remote repository", 8, 4);
                _gitPlugin.AddToolbarCommand(commandBar, "Stash", "Stash", "Stash changes", 3, 5);
                _gitPlugin.AddToolbarCommand(commandBar, "Settings", "Settings", "Settings", 2, 6);
            }
            catch (Exception ex)
            {
                _gitPlugin.OutputPane.OutputString("Error creating toolbar: " + ex);
            }
        }
예제 #54
0
 public static bool ChangeCommandCaption(DTE2 application, string commandBarName, string tooltipText, string caption)
 {
     try
     {
         var        cmdBars    = (CommandBars)application.CommandBars;
         CommandBar commandBar = cmdBars[commandBarName];
         var        cbcc       = commandBar.Controls.Cast <CommandBarButton>().ToArray();
         foreach (var control in cbcc)
         {
             if (control.TooltipText.Trim().Equals(tooltipText.Trim(), StringComparison.CurrentCultureIgnoreCase))
             {
                 control.Caption = caption;
                 control.Style   = MsoButtonStyle.msoButtonIconAndCaption;
             }
         }
         return(true);
     }
     catch (Exception)
     {
         //ignore!
         return(false);
     }
 }
예제 #55
0
        public void Initialize()
        {
            _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;
        }
예제 #56
0
        public TablesPage()
        {
            Grid.VisibleColumns.Add(new ColumnViewModel(nameof(CloudTable.Name).ToConsoleString(Theme.DefaultTheme.H1Color)));
            Grid.NoDataMessage           = "No tables";
            Grid.NoVisibleColumnsMessage = "Loading...";
            addButton = CommandBar.Add(new Button()
            {
                Text = "Add table"
            });
            addButton.Activated.SubscribeForLifetime(AddTable, LifetimeManager);

            deleteButton = CommandBar.Add(new Button()
            {
                Text = "Delete table", Shortcut = new KeyboardShortcut(ConsoleKey.Delete, null), CanFocus = false
            });
            deleteButton.Activated.SubscribeForLifetime(DeleteSelectedTable, LifetimeManager);


            Grid.SelectedItemActivated += NavigateToTable;

            CommandBar.Add(new NotificationButton(ProgressOperationManager));
            Grid.SubscribeForLifetime(nameof(Grid.SelectedItem), SelectedItemChanged, this.LifetimeManager);
        }
예제 #57
0
        public void RegisterUI(CommandBar menu, int index = 1, bool isFirstInGroup = false)
        {
            List <CommandBarControl> toRemove = new List <CommandBarControl>();

            foreach (CommandBarControl control in menu.Controls)
            {
                int    commandId;
                string commandGroup;
                UICommands.DTE.Commands.CommandInfo(control, out commandGroup, out commandId);
                if (new Guid(commandGroup) == CommandGroupGuid && commandId == CommandId)
                {
                    toRemove.Add(control);
                }
            }
            foreach (var value in toRemove)
            {
                value.Delete();
            }
            var dteCommand = UICommands.DTE.Commands.Named(CanonicalName);

            _uiControl            = (CommandBarControl)dteCommand.AddControl(menu, index);
            _uiControl.BeginGroup = isFirstInGroup;
        }
예제 #58
0
        /// <summary>
        /// Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.
        /// </summary>
        /// <param name="Application">The application.</param>
        /// <param name="ConnectMode">The connect mode.</param>
        /// <param name="AddInInst">The add in inst.</param>
        /// <param name="custom">The custom.</param>
        /// <seealso class="IDTExtensibility2" />
        public void OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
        {
            _DTE   = (DTE)Application;
            _AddIn = (AddIn)AddInInst;

            _CommandNameFormatted = String.Format("{0}.{1}", _AddIn.ProgID, _CommandName);

            var commandBars = _DTE.CommandBars as CommandBars;

            if (commandBars == null)
            {
                return;
            }
            foreach (CommandBar commandBar in commandBars)
            {
                if (!_comparer.Equals(commandBar.Name, "Execution Plan Context"))
                {
                    continue;
                }
                _ExecutionPlanBar = commandBar;
                break;
            }
        }
예제 #59
0
 /// <summary>
 ///		Applies this toolbar to the given CommandBar.
 /// </summary>
 /// <param name="window">The window that the CommandBar belongs to.</param>
 /// <param name="commandbar"></param>
 internal void Apply(OfficeWindow window, CommandBar commandbar)
 {
     commandbar.Enabled  = enabled.GetValue(window);
     commandbar.RowIndex = rowIndex;
     commandbar.Visible  = visible.GetValue(window);
     if (left >= 0)
     {
         commandbar.Left = left;
     }
     else if (right >= 0)
     {
         commandbar.Left = (window.Width - commandbar.Width) - right;
     }
     if (top >= 0)
     {
         commandbar.Top = top;
     }
     else if (bottom >= 0)
     {
         commandbar.Top = (window.Height - commandbar.Height) - bottom;
     }
     Apply(window, commandbar.Controls);
 }
예제 #60
0
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _backButton = GetTemplateChild("backButton") as AppBarButton;
            if (_backButton != null)
            {
                _backButton.Click += OnBackClicked;
            }

            _presenter = GetTemplateChild("presenter") as Windows.UI.Xaml.Controls.ContentPresenter;

            _titleViewPresenter = GetTemplateChild("TitleViewPresenter") as FrameworkElement;

            _commandBar = GetTemplateChild("CommandBar") as CommandBar;


            _toolbarPlacementHelper.Initialize(_commandBar, () => ToolbarPlacement, GetTemplateChild);

            TaskCompletionSource <CommandBar> tcs = _commandBarTcs;

            tcs?.SetResult(_commandBar);
        }