private void AddButton(RibbonTabData tab, string goupName, RibbonControlData button) { var group = (from g in tab.GroupDataCollection where g.Header == goupName select g).FirstOrDefault(); if (group == null) throw new PluginException(Messages.PluginException_HomeMenuVoid); group.ButtonDataCollection.Add(button); // I use ToList() because it makes a copy of the list. Otherwise, clearing the ObservableCollection // clears the linq result. group.ButtonDataCollection.Refill(group.ButtonDataCollection.OrderBy(e => e.Order).ToList()); }
/// <summary> /// Adds the specified button in the specified group in home menu. /// </summary> /// <param name="button">The button.</param> /// <param name="group">The group.</param> public void AddInHome(RibbonControlData button, Groups group) { string criteria = this.GetGroupName(group); var tab = (from menu in App.RibbonData.TabDataCollection where menu.Header == Messages.Title_Home select menu).FirstOrDefault(); if (tab == null) throw new PluginException(Messages.PluginException_HomeMenuVoid); this.Dispatcher.Invoke((Action)delegate { switch (group) { case Groups.Managers: this.AddButton(tab, Messages.Title_SessionManagers, button); break; case Groups.Tools: this.AddButton(tab, Messages.Title_Tools, button); break; case Groups.GlobalTools: this.AddButton(tab, Messages.Title_GlobalTools, button); break; case Groups.DebugTools: this.AddButton(tab, Messages.Title_DebugTools, button); break; default: Assert.FailOnEnumeration(group); break; } }); }
/// <summary> /// Adds the specified control into the application menu. /// </summary> /// <param name="control">The control.</param> public void AddToApplicationMenu(RibbonControlData control) { this.Dispatcher.Invoke((Action)delegate { App.RibbonData.ApplicationMenuData.ControlDataCollection.Add(control); App.RibbonData.ApplicationMenuData.ControlDataCollection.Refill( App.RibbonData.ApplicationMenuData.ControlDataCollection.OrderBy(e => e.Order).ToList()); }); }
private void InitialiseUpdateUserPage() { var pwd = new RibbonControlData(Messages.Title_ChangePwd, uri.FormatWith("Keys"), changePwdCommand) { Order = 3 }; var menu = new RibbonControlData(Messages.Menu_ManagePersonalData, uri.FormatWith("Users"), showUpdateUserCommand) { Order = 3 }; PluginContext.Host.AddToApplicationMenu(pwd); PluginContext.Host.AddToApplicationMenu(menu); }