public void InitDisplayToolbar() { STToolbarsController objToolbarsController = new STToolbarsController(); List <STToolbarsInfo> toolbarList = objToolbarsController.GetAllToolbarByModuleID(Module.CurrentModuleID, VinaApp.CurrentUserInfo.FK_ADUserGroupID); InitDisplayToolbarGroup(toolbarList.Where(o => o.STToolbarGroup == BaseToolbar.ToolbarAction).ToList() , BaseToolbar.ToolbarAction); InitDisplayToolbarGroup(toolbarList.Where(o => o.STToolbarGroup == BaseToolbar.ToolbarExtra).ToList() , BaseToolbar.ToolbarExtra); InitDisplayToolbarGroup(toolbarList.Where(o => o.STToolbarGroup == BaseToolbar.ToolbarUtility).ToList() , BaseToolbar.ToolbarUtility); InitDisplayToolbarGroup(toolbarList.Where(o => o.STToolbarGroup == BaseToolbar.ToolbarInfo).ToList() , BaseToolbar.ToolbarInfo); ToolbarManager.AllowCustomization = false; ToolbarManager.AllowMoveBarOnToolbar = false; ToolbarManager.AllowShowToolbarsPopup = true; }
public virtual DevExpress.XtraBars.BarItem[] InitToolbarButtonsForToolbar(List <STToolbarsInfo> toolbarList, string strToolbarGroup) { Dictionary <int, DevExpress.XtraBars.BarItem> lstParentToolbar = new Dictionary <int, DevExpress.XtraBars.BarItem>(); List <DevExpress.XtraBars.BarItem> btnToolbarList = new List <DevExpress.XtraBars.BarItem>(); STToolbarsController objSTToolbarsController = new STToolbarsController(); if (toolbarList.Count() == 0) { return(btnToolbarList.ToArray()); } DevExpress.XtraBars.BarItem objBarItem = null; toolbarList.ForEach(o => { objBarItem = null; if (toolbarList.Any(o1 => o1.STToolbarParentID == o.STToolbarID)) { objBarItem = new DevExpress.XtraBars.BarSubItem(); lstParentToolbar.Add(o.STToolbarID, objBarItem); } else { objBarItem = new DevExpress.XtraBars.BarButtonItem(); } objBarItem.Id = ToolbarManager.GetNewItemId(); objBarItem.Name = o.STToolbarName; objBarItem.Tag = o.STToolbarTag; objBarItem.Caption = o.STToolbarCaption; objBarItem.Description = o.STToolbarDesc; objBarItem.Hint = strToolbarGroup; objBarItem.PaintStyle = DevExpress.XtraBars.BarItemPaintStyle.CaptionGlyph; if (o.STToolbarParentID == 0) { btnToolbarList.Add(objBarItem); } if (VinaApp.ToolbarImageList.Images.IndexOfKey(objBarItem.Tag.ToString()) >= 0) { objBarItem.LargeImageIndex = VinaApp.ToolbarImageList.Images.IndexOfKey(objBarItem.Tag.ToString()); objBarItem.ImageIndex = VinaApp.ToolbarImageList.Images.IndexOfKey(objBarItem.Tag.ToString()); objBarItem.Glyph = VinaApp.ToolbarImageList.Images[objBarItem.Tag.ToString()]; } if (objBarItem is DevExpress.XtraBars.BarButtonItem) { objBarItem.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(ToolbarButton_ItemClick); //InitHotKeyForToolbarButton(barButton); } if (lstParentToolbar.ContainsKey(o.STToolbarParentID)) { (lstParentToolbar[o.STToolbarParentID] as DevExpress.XtraBars.BarSubItem).AddItem(objBarItem); } ToolbarManager.Items.Add(objBarItem); }); return(btnToolbarList.ToArray()); }