internal override void ShowModule(bool firstShow) { base.ShowModule(firstShow); this.appointmentCategory = FindAppointmentPage(this.ribbonControl1); SubscribeSchedulerEvents(); UpdateAppointmentCategory(); MainRibbon.SelectedPage = MainRibbon.MergedPages.GetPageByName(homeRibbonPage1.Name); }
private void addButtonGroupToButtonGroupCache(IButtonGroup buttonGroup, RibbonPageCategory pageCategory) { var buttonGroups = _buttonGroupCache[identifierForCategory(pageCategory)]; buttonGroups.Add(buttonGroup); _buttonGroupCache[identifierForCategory(pageCategory)] = buttonGroups; }
/// <summary> /// 加载RibbonPage /// </summary> /// <param name="ribbonPageCategory"></param> /// <returns></returns> private string InitialRibbonPage(RibbonPageCategory ribbonPageCategory) { if (ribbonPageCategory == null) { return(string.Format("无父控件")); } string strFid = ribbonPageCategory.Tag.ToString(); DataRow[] pSelectRows = _AppUser.UserRole.RoleFunDt.Select(string.Format("{0}='{1}' and {2}='{3}'", ColumnName.PID, strFid, ColumnName.ControlType, PluginControlType.RibbonPage.ToString())); if (pSelectRows.Length <= 0) { return(string.Format("无权限")); } foreach (DataRow pRow in pSelectRows) { RibbonPage ribbonPage = new RibbonPage(); string FName = pRow[ColumnName.FName].ToString(); if (AllPlugin.dicPlugins.ContainsKey(FName)) { PluginOnCreate(AllPlugin.dicPlugins[FName], _pIAppFrm); } ribbonPage.Name = FName; ribbonPage.Text = pRow[ColumnName.Caption].ToString(); ribbonPage.Tag = pRow[ColumnName.FID]; ribbonPageCategory.Pages.Add(ribbonPage); //加载RibbonPageGroup InitialRibbonPageGroup(ribbonPage); } return(string.Empty); }
RibbonPage GetFirstVisiblePage(RibbonPageCategory ribbonPageCategory) { foreach (RibbonPage page in ribbonPageCategory.Pages) if (page.Visible) return page; return null; }
internal override void ShowModule(bool firstShow) { base.ShowModule(firstShow); this.appointmentCategory = FindAppointmentPage(this.ribbonControl1); SubscribeSchedulerEvents(); UpdateAppointmentCategory(); MainRibbon.SelectedPage = MainRibbon.MergedPages.GetPageByName(homeRibbonPage1.Name); }
public void RemoveCommandCategory(string categoryName) { RibbonPageCategory category = this._regionManager.Regions[RegionNames.RibbonRegion].Views .Where(v => v is RibbonPageCategory && (v as RibbonPageCategory).Caption == categoryName) .FirstOrDefault() as RibbonPageCategory; if (category != null) { this._regionManager.Regions[RegionNames.RibbonRegion].Remove(category); } }
RibbonPage GetFirstVisiblePage(RibbonPageCategory ribbonPageCategory) { foreach (RibbonPage page in ribbonPageCategory.Pages) { if (page.Visible) { return(page); } } return(null); }
public RibPageMachine(RibbonControl ribbon) : this() { this.page = new RibbonPage { Text = "正在加工" }; this.category = new RibbonPageCategory { Text = "加工" }; this.category.Pages.Add(this.page); this.Ribbon = ribbon; this.Ribbon.SelectedPageChanging += Ribbon_SelectedPageChanging; }
public void AddCommandGroupExtension(string categoryName, string pageName, RibbonPageGroup group) { RibbonPageCategory category = new RibbonPageCategory(); category.Caption = categoryName; RibbonPage page = new RibbonPage(); page.Caption = pageName; page.Groups.Add(group); category.Pages.Add(page); this._regionManager.AddToRegion(RegionNames.RibbonRegion, category); }
/// <summary> /// 根据用户权限加载控件 /// </summary> private string LoadControls() { if (_pIAppFrm == null) { return(string.Format("初始化控件失败:无主应用对象")); } if (_AppUser == null) { return(string.Format("初始化控件失败:无登录用户")); } DataTable pRoleFunDt = _AppUser.UserRole.RoleFunDt; if (pRoleFunDt == null || pRoleFunDt.Rows.Count <= 0) { return(string.Format("初始化控件失败:登录用户没有相应的权限")); } //级别为0即系统名称 DataRow[] pRows = pRoleFunDt.Select(string.Format("{0}='{1}'", ColumnName.LevelID, '0')); if (pRows.Length <= 0) { return(string.Format("无法获取系统名称")); } _pIAppFrm.MainForm.Text = pRows[0][ColumnName.Caption].ToString(); //初始化RibbonPageCategory pRows = pRoleFunDt.Select(string.Format("{0}='{1}'", ColumnName.ControlType, PluginControlType.RibbonPageCategory.ToString())); if (pRows.Length <= 0) { return(string.Format("当前用户:{0}缺少相应的权限", _AppUser.UserName)); } _pIAppFrm.MainForm.SuspendLayout(); _pIAppFrm.MainForm.mainRibbon.PageCategories.Clear(); _pIAppFrm.MainForm.mainRibbon.Pages.Clear(); foreach (DataRow pRow in pRows) { RibbonPageCategory ribbonPageCategory = new RibbonPageCategory(); string FName = pRow[ColumnName.FName].ToString(); if (AllPlugin.dicPlugins.ContainsKey(FName)) { PluginOnCreate(AllPlugin.dicPlugins[FName], _pIAppFrm); } ribbonPageCategory.Name = FName; ribbonPageCategory.Text = pRow[ColumnName.Caption].ToString(); ribbonPageCategory.Tag = pRow[ColumnName.FID]; _pIAppFrm.MainForm.mainRibbon.PageCategories.Add(ribbonPageCategory); //初始化RibbonPage控件 InitialRibbonPage(ribbonPageCategory); } _pIAppFrm.MainForm.ResumeLayout(false); _pIAppFrm.MainForm.PerformLayout(); //创建RibbonControl _pIAppFrm.MainForm.Size = new Size(1028, 742); return(string.Empty); }
internal override void InitModule(DevExpress.Utils.Menu.IDXMenuManager manager, object data) { base.InitModule(manager, data); schedulerControl1.MenuManager = manager; this.ribbon = manager as RibbonControl; this.appointmentCategory = FindAppointmentPage(this.ribbon); if (calendarControls == null) { this.calendarControls = data as ucCalendar; this.calendarControls.InitDateNavigator(this.schedulerControl1); this.calendarControls.InitResourcesTree(this.schedulerStorage1); this.calendarControls.InitBarController(this.schedulerControl1); } }
public static RibbonPageCategory CreateCategory(XmlNode xmlNode) { RibbonPageCategory pageCategory = new RibbonPageCategory(); pageCategory.AutoStretchPageHeaders = true; if (XMLManager.GetNodeType(xmlNode) != XMLNodeType.PageCategory) { pageCategory = null; } else { //只是用来赋空的值而已 GetXMLCategory(xmlNode); } return pageCategory; }
private static void BuildCategory(RibbonPageCategory currentCategory, PageCategory cat) { if (cat == null) { return; } foreach (var page in cat.Parts.OfType <Page>()) { var currentPage = new RibbonPage() { Caption = page.DisplayName }; currentCategory.Pages.Add(currentPage); BuildPage(currentPage, page); } }
public void ShowHideFormatCategory() { RibbonPageCategory selectionCategory = Ribbon.PageCategories[0] as RibbonPageCategory; if (selectionCategory == null) { return; } if (CurrentRichTextBox == null) { selectionCategory.Visible = false; } else { selectionCategory.Visible = CurrentRichTextBox.SelectionLength != 0; } if (selectionCategory.Visible) { Ribbon.SelectedPage = selectionCategory.Pages[0]; } }
void RibbonControlWrapper_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (RibbonItemViewModel vm in e.NewItems) { var category = Target.Categories.FirstOrDefault(c => String.Equals(c.Name, vm.Category) || String.Equals(c.Caption, vm.Category)); if (category == null) { category = new RibbonPageCategory() { Name = vm.Category.Replace(" ", ""), Caption = vm.Category }; Target.Categories.Add(category); } var page = category.Pages.FirstOrDefault(p => String.Equals(p.Name, vm.Page) || String.Equals(p.Caption, vm.Page)); if (page == null) { page = new RibbonPage() { Name = vm.Page.Replace(" ", ""), Caption = vm.Page }; category.Pages.Add(page); } var group = page.Groups.FirstOrDefault(g => String.Equals(g.Name, vm.Group) || String.Equals(g.Caption, vm.Group)); if (group == null) { group = new RibbonPageGroup() { Name = vm.Group.Replace(" ", ""), Caption = vm.Group }; page.Groups.Add(group); } group.Items.Add(new BarButtonItem() { Content = vm.Content, Glyph = vm.Glyph }); } } }
void AddDemoModuleBar(DemoModule demoModule) { var isVisible = CurrentCategory == ((ClassicShowType)demoModule.ShowMethodType).Category; RibbonPageCategoryBase rpcb; if (_subcategories.ContainsKey(((ClassicShowType)demoModule.ShowMethodType).Subcategory)) { rpcb = _subcategories[((ClassicShowType)demoModule.ShowMethodType).Subcategory]; } else { rpcb = new RibbonPageCategory() { Caption = ((ClassicShowType)demoModule.ShowMethodType).Subcategory }; Ribbon.Categories.Add(rpcb); _subcategories.Add(((ClassicShowType)demoModule.ShowMethodType).Subcategory, rpcb); } rpcb.IsVisible = isVisible; demoModule.Bar.IsVisible = isVisible; this.ribbonManager.Merge(rpcb, demoModule.BarManager, demoModule.RibbonControl); }
/// <summary> /// Builds the specified ribbon. /// </summary> /// <param name="ribbon">The ribbon.</param> /// <param name="items">The items.</param> /// <param name="doAppletItemClicked">The do applet item clicked.</param> public static void Build(RibbonControl control, MenuContainer items, Action <object, RunMode> doAppletItemClicked) { ClearDynamicPages(control); _appletClickedAction = doAppletItemClicked; if (items == null) { return; } var c = items.Parts.OfType <PageCategory>().Count(); var s = String.Format(c.ToString()); foreach (var cat in items.Parts.OfType <PageCategory>()) { var currentCategory = new RibbonPageCategory() { Tag = "CanDelete", ToolTip = cat.ToolTip, Caption = cat.DisplayName }; control.Categories.Add(currentCategory); BuildCategory(currentCategory, cat); } }
public void CreateDynamicPageCategory(string pageCategoryName, Color categoryColor) { var page = new RibbonPageCategory(pageCategoryName, categoryColor, false); _barManager.Ribbon.PageCategories.Add(page); }
/// <summary> /// 修正菜单 /// </summary> /// <param name="ribbonPageCategoryCollection"></param> /// <param name="_c"></param> virtual public void ChangeMenu(RibbonPageCategoryCollection ribbonPageCategoryCollection, IChildForm _c) { RibbonPageCategory selectionCategory = ribbonPageCategoryCollection[0] as RibbonPageCategory; if (selectionCategory == null) { return; } selectionCategory.Pages.Clear(); if (_c == null) { selectionCategory.Visible = false; } else { selectionCategory.Visible = true; IList <FrmMenuPage> _menuPages = _c.GetMenuPages(); foreach (FrmMenuPage _page in _menuPages) { int _index = selectionCategory.Pages.Add(new RibbonPage(_page.PageTitle)); IList <FrmMenuGroup> _menugroups = _page.MenuGroups; foreach (FrmMenuGroup _mg in _menugroups) { int _groupIndex = selectionCategory.Pages[_index].Groups.Add(new RibbonPageGroup(_mg.DisplayTitle)); RibbonPageGroup _mgroup = selectionCategory.Pages[_index].Groups[_groupIndex]; IList <FrmMenuItem> _items = _mg.MenuItems; foreach (FrmMenuItem _item in _items) { BarButtonItem _menuitem = new BarButtonItem(); _menuitem.Caption = _item.MenuTitle; _menuitem.Tag = _item.CommandName; _menuitem.LargeGlyph = _item.MenuIcon; _menuitem.Glyph = _item.MenuIcon; _menuitem.LargeWidth = _item.MenuPicWidth; _menuitem.Enabled = _item.ButtonEnable; if (_item.ChildMenus.Count < 1) { _menuitem.ItemClick += new ItemClickEventHandler(_menuitem_ItemClick); } else { _menuitem.ButtonStyle = BarButtonStyle.DropDown; PopupMenu _cMenu = new PopupMenu(); _menuitem.DropDownControl = _cMenu; _cMenu.Ribbon = this.Ribbon; foreach (FrmMenuItem _citem in _item.ChildMenus) { BarButtonItem _cmItem = new BarButtonItem(); _cmItem.Caption = _citem.MenuTitle; _cmItem.Tag = _citem.CommandName; _cmItem.LargeGlyph = _citem.MenuIcon; _cmItem.Glyph = _citem.MenuIcon; _cmItem.LargeWidth = _citem.MenuPicWidth; _cmItem.Enabled = _citem.ButtonEnable; _cmItem.ItemClick += new ItemClickEventHandler(_menuitem_ItemClick); this.Ribbon.Items.Add(_cmItem); _cMenu.ItemLinks.Add(_cmItem); } } _mgroup.ItemLinks.Add(_menuitem); } } } } if (selectionCategory.Visible && selectionCategory.Pages.Count > 0) { ribbonPageCategoryCollection.Ribbon.SelectedPage = selectionCategory.Pages[0]; } }
internal override void InitModule(DevExpress.Utils.Menu.IDXMenuManager manager, object data) { base.InitModule(manager, data); schedulerControl1.MenuManager = manager; this.ribbon = manager as RibbonControl; this.appointmentCategory = FindAppointmentPage(this.ribbon); if (calendarControls == null) { this.calendarControls = data as ucCalendar; this.calendarControls.InitDateNavigator(this.schedulerControl1); this.calendarControls.InitResourcesTree(this.schedulerStorage1); this.calendarControls.InitBarController(this.schedulerControl1); } }
private void DocGroup_SelectedItemChanged(object sender, SelectedItemChangedEventArgs e) { if (ribbonControl.Categories.Count > 1) { ribbonControl.Categories.RemoveAt(1); } DocumentPanel panel = e.Item as DocumentPanel; if (panel == null) { return; } Page win = panel.Tag as Page; if (win == null) { return; } #region 合并ribbon菜单 RibbonControl ribCtor = win.FindName("ribbonControl") as RibbonControl; if (ribCtor != null) { RibbonDefaultPageCategory pageCategory = ribCtor.Categories.FirstOrDefault() as RibbonDefaultPageCategory; RibbonPageCategory ribPageCategory = new RibbonPageCategory(); ribPageCategory.Color = Colors.Orange; ribPageCategory.Caption = pageCategory.Caption; ribbonControl.Categories.Add(ribPageCategory); foreach (RibbonPage page in pageCategory.Pages) { RibbonPage newPage = new RibbonPage(); foreach (RibbonPageGroup group in page.Groups) { RibbonPageGroup newGroup = new RibbonPageGroup() { Caption = group.Caption }; foreach (var item in group.Items) { if (item is BarButtonItem) { BarButtonItem btn = item as BarButtonItem; BarButtonItem newBtn = new BarButtonItem() { Content = btn.Content, RibbonStyle = btn.RibbonStyle, Glyph = btn.Glyph, LargeGlyph = btn.LargeGlyph, KeyGesture = btn.KeyGesture, }; newBtn.ItemClick += (s, arg) => { btn.Focusable = true; btn.Focus(); //TextBox 失去焦点后才反馈给绑定值 btn.PerformClick(); }; Binding binding = new Binding() { Source = btn, Path = new PropertyPath("IsEnabled") }; BindingOperations.SetBinding(newBtn, IsEnabledProperty, binding); binding = new Binding() { Source = btn, Path = new PropertyPath("Visibility") }; BindingOperations.SetBinding(newBtn, VisibilityProperty, binding); newGroup.Items.Add(newBtn); } } newPage.Groups.Add(newGroup); } newPage.Caption = "工作栏"; newPage.IsSelected = true; ribPageCategory.Pages.Add(newPage); } ribPageCategory.IsVisible = true; } ribbonControl.UpdateLayout(); #endregion }
protected override void Adapt(IRegion region, RibbonControl regionTarget) { region.Views.CollectionChanged += (s, e) => { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (object element in e.NewItems) { if (element is RibbonPageCategory) { RibbonPageCategory category = (RibbonPageCategory)element; if (category.Pages.Count == 0) { return; } RibbonPageCategory realCategory = regionTarget.Items.Where(item => { if (item is RibbonPageCategory && ((RibbonPageCategory)item).Caption == category.Caption) { return(true); } return(false); }).FirstOrDefault() as RibbonPageCategory; if (realCategory != null) { RibbonPage page = category.Pages.First(); RibbonPage realPage = realCategory.Pages.Where(item => { if (item.Caption.ToString() == page.Caption.ToString()) { return(true); } return(false); }).FirstOrDefault() as RibbonPage; if (realPage != null) { realCategory.Pages.Remove(realPage); foreach (var group in page.Groups) { realPage.Groups.Add(group); } realCategory.Pages.Add(realPage); regionTarget.SelectedPage = realPage; } else { realCategory.Pages.Add(page); regionTarget.SelectedPage = page; } } else { regionTarget.Items.Add(category); regionTarget.SelectedPage = category.Pages.First(); } } else if (element is BarButtonItem) { RibbonDefaultPageCategory realCategory = regionTarget.Items.Where(item => item is RibbonDefaultPageCategory).First() as RibbonDefaultPageCategory; RibbonPage realPage = realCategory.Pages.Where(item => { if (item.Caption.ToString() == UIConstants.MainCommandPageName) { return(true); } return(false); }).FirstOrDefault() as RibbonPage; RibbonPageGroup realGroup = realPage.Groups.Where(item => { if (item.Caption.ToString() == UIConstants.MainCommandGroupName) { return(true); } return(false); }).FirstOrDefault() as RibbonPageGroup; if (realGroup != null) { int index = realPage.Groups.IndexOf(realGroup); realPage.Groups.RemoveAt(index); realGroup.ItemLinks.Add((BarButtonItem)element); realPage.Groups.Insert(index, realGroup); } else { RibbonPageGroup group = new RibbonPageGroup(); group.Caption = UIConstants.MainCommandGroupName; group.ItemLinks.Add((BarButtonItem)element); realPage.Groups.Add(group); } } else if (element is RibbonDefaultPageCategory) { RibbonDefaultPageCategory category = (RibbonDefaultPageCategory)element; RibbonDefaultPageCategory realCategory = regionTarget.Items.Where(item => item is RibbonDefaultPageCategory).First() as RibbonDefaultPageCategory; RibbonPage page = category.Pages.First(); if (page.Groups.Count == 0) { return; } RibbonPage realPage = realCategory.Pages.Where(item => { if (item.Caption.ToString() == page.Caption.ToString()) { return(true); } return(false); }).FirstOrDefault() as RibbonPage; RibbonPageGroup group = page.Groups.First(); if (group.ItemLinks.Count == 0) { return; } RibbonPageGroup realGroup = realPage.Groups.Where(item => { if (item.Caption.ToString() == page.Caption.ToString()) { return(true); } return(false); }).FirstOrDefault() as RibbonPageGroup; if (realGroup != null) { int index = realPage.Groups.IndexOf(realGroup); realPage.Groups.RemoveAt(index); realGroup.ItemLinks.Add(group.ItemLinks.First()); realPage.Groups.Insert(index, realGroup); } else { realPage.Groups.Add(group); } } } } else if (e.Action == NotifyCollectionChangedAction.Remove) { foreach (object element in e.OldItems) { if (element is RibbonPageCategory) { RibbonPageCategory category = (RibbonPageCategory)element; if (category.Pages.Count == 0) { return; } RibbonPageCategory realCategory = regionTarget.Items.Where(item => { if (item is RibbonPageCategory && ((RibbonPageCategory)item).Caption == category.Caption) { return(true); } return(false); }).FirstOrDefault() as RibbonPageCategory; if (realCategory != null) { regionTarget.Items.Remove(realCategory); } } else if (element is BarButtonItem) { BarButtonItem button = (BarButtonItem)element; RibbonDefaultPageCategory realCategory = regionTarget.Items.Where(item => item is RibbonDefaultPageCategory).First() as RibbonDefaultPageCategory; RibbonPage realPage = realCategory.Pages.Where(item => { if (item.Caption.ToString() == UIConstants.MainCommandPageName) { return(true); } return(false); }).FirstOrDefault() as RibbonPage; RibbonPageGroup realGroup = realPage.Groups.Where(item => { if (item.Caption.ToString() == UIConstants.MainCommandGroupName) { return(true); } return(false); }).FirstOrDefault() as RibbonPageGroup; int index = realPage.Groups.IndexOf(realGroup); realPage.Groups.RemoveAt(index); for (int i = 0; i < realGroup.ItemLinks.Count; i++) { if (realGroup.ItemLinks[i].ActualContent == button.Content) { realGroup.ItemLinks.RemoveAt(i); break; } } realPage.Groups.Insert(index, realGroup); } } } }; }
private void setButtonLocks(bool locked, RibbonPageCategory category) { var groups = _buttonGroupCache[identifierForCategory(category)]; groups.Each(group => group.WithLock(locked)); }
private static string identifierForCategory(RibbonPageCategory category) { return(category.Text); }