public ContextMenuMultiInstance() { InitializeComponent(); DataContext = this; Postits = new PostitCollection(); MenuItems = new MenuItemCollection(); MenuItems.Add(new UbiMenuItem() { Caption = "Add Yellow Postit", Command = Postits.CreatePostitCommand, Converter = new HoldConverter() { VisualReference = this, Color = Brushes.LemonChiffon } }); MenuItems.Add(new UbiMenuItem() { Caption = "Add Pink Postit", Command = Postits.CreatePostitCommand, Converter = new HoldConverter() { VisualReference = this, Color = Brushes.LightPink } }); MenuItems.Add(new UbiMenuItem() { Caption = "Add Green Postit", Command = Postits.CreatePostitCommand, Converter = new HoldConverter() { VisualReference = this, Color = Brushes.GreenYellow } }); }
private ButtonMenuItem GetSubmenu(MenuItemCollection items, string submenuText, bool create = true) { var submenu = items.OfType<ButtonMenuItem>().FirstOrDefault(r => r.ID == submenuText); if (submenu == null && create) { submenu = new ButtonMenuItem { ID = submenuText, Text = submenuText, Order = 10 }; items.Add(submenu); } return submenu; }
public void Generate(MenuItemCollection menu) { var list = new List<IActionItem>(this); list.Sort(Compare); var lastSeparator = false; for (int i = 0; i < list.Count; i++) { var ai = list[i]; var isSeparator = (ai is ActionItemSeparator); if ((lastSeparator && isSeparator) || (isSeparator && (i == 0 || i == list.Count - 1))) continue; var mi = ai.Generate(menu.parent.Generator); if (mi != null) menu.Add(mi); lastSeparator = isSeparator; } }
private void PrepareSfBMenuRoot(MenuItemCollection items) { if (ShortMenu) { PrepareSfBMenu(items); } else { MenuItem item = new MenuItem(GetLocalizedString("Text.SfBGroup"), "", "", null); item.Selectable = false; PrepareSfBMenu(item.ChildItems); if (item.ChildItems.Count > 0) { items.Add(item); } } }
/// <summary> /// AddItems /// </summary> /// <param name="items"></param> /// <param name="level"></param> /// <param name="dt"></param> private void AddItems(MenuItemCollection items, int level, System.Data.DataTable dt) { try { string filterExp = string.Format("ParentID='{0}'", level); foreach (System.Data.DataRow r in dt.Select(filterExp)) { MenuItem item = new MenuItem() { Text = r[2].ToString(), NavigateUrl = r[3].ToString() }; this.AddItems(item.ChildItems, int.Parse(r[0].ToString()), dt); items.Add(item); } } catch (Exception ex) { ErrorLog.LogErrorMessageToDB("Menu.ascx", "", "AddItems", ex.Message.ToString(), new ACEConnection()); } }
public MenuItemCollection GetIconsDataSource(int packageId) { // load package context PackageContext cntx = PackagesHelper.GetCachedPackageContext(packageId); // init collection MenuItemCollection items = new MenuItemCollection(); // get icons list foreach (XmlNode xmlNode in xmlIcons) { // create icon item MenuItem iconItem = CreateMenuItem(cntx, xmlNode); if (iconItem == null) { continue; } // add into list items.Add(iconItem); } return(items); }
public void Add(IMenuItem item) { _menuItemCollection.Add((item as FormsMenuItem).SourceMenuItem); }
private void PrepareEnterpriseStorageMenu(MenuItemCollection enterpriseStorageItems) { enterpriseStorageItems.Add(CreateMenuItem("EnterpriseStorageFolders", "enterprisestorage_folders", @"Icons/enterprisestorage_folders_48.png")); }
private void BindMenu(MenuItemCollection items, XmlNodeList nodes) { foreach (XmlNode node in nodes) { string pageId = null; if (node.Attributes["pageID"] != null) { pageId = node.Attributes["pageID"].Value; } if (!PortalUtils.PageExists(pageId)) { continue; } string url = null; if (node.Attributes["url"] != null) { url = node.Attributes["url"].Value; } string title = null; if (node.Attributes["title"] != null) { title = node.Attributes["title"].Value; } string target = null; if (node.Attributes["target"] != null) { target = node.Attributes["target"].Value; } string resourceGroup = null; if (node.Attributes["resourceGroup"] != null) { resourceGroup = node.Attributes["resourceGroup"].Value; } string quota = null; if (node.Attributes["quota"] != null) { quota = node.Attributes["quota"].Value; } bool disabled = false; if (node.Attributes["disabled"] != null) { disabled = Utils.ParseBool(node.Attributes["disabled"].Value, false); } // get custom page parameters XmlNodeList xmlParameters = node.SelectNodes("Parameters/Add"); List <string> parameters = new List <string>(); foreach (XmlNode xmlParameter in xmlParameters) { parameters.Add(xmlParameter.Attributes["name"].Value + "=" + xmlParameter.Attributes["value"].Value); } // add menu item string pageUrl = !String.IsNullOrEmpty(url) ? url : PortalUtils.NavigatePageURL( pageId, PortalUtils.SPACE_ID_PARAM, currentPackage.ToString(), parameters.ToArray()); string pageName = !String.IsNullOrEmpty(title) ? title : PortalUtils.GetLocalizedPageName(pageId); MenuItem item = new MenuItem(pageName, pageId, "", disabled ? null : pageUrl); if (!String.IsNullOrEmpty(target)) { item.Target = target; } item.Selectable = !disabled; // check groups/quotas bool display = true; String displayValue = String.Empty; if (cntx != null) { display = (String.IsNullOrEmpty(resourceGroup) || cntx.Groups.ContainsKey(resourceGroup)) && (String.IsNullOrEmpty(quota) || (cntx.Quotas.ContainsKey(quota) && cntx.Quotas[quota].QuotaAllocatedValue != 0)); if (!String.IsNullOrEmpty(resourceGroup)) { displayValue = "String.IsNullOrEmpty(resourceGroup): " + String.IsNullOrEmpty(resourceGroup).ToString(); displayValue += "| cntx.Groups.ContainsKey(resourceGroup): " + cntx.Groups.ContainsKey(resourceGroup).ToString(); displayValue += "| resourceGroup: " + resourceGroup; } if (!String.IsNullOrEmpty(quota)) { displayValue += "| String.IsNullOrEmpty(quota): " + String.IsNullOrEmpty(quota).ToString(); displayValue += "| cntx.Quotas.ContainsKey(quota): " + cntx.Quotas.ContainsKey(quota).ToString(); if (cntx.Quotas.ContainsKey(quota)) { displayValue += "| cntx.Quotas[quota].QuotaAllocatedValue: " + cntx.Quotas[quota].QuotaAllocatedValue.ToString(); } displayValue += "| quota: " + quota; } } if (display) { // process nested menu items XmlNodeList xmlNestedNodes = node.SelectNodes("MenuItems/MenuItem"); BindMenu(item.ChildItems, xmlNestedNodes); } //item.Text += displayValue; //Response.Write("DisplayValue :[" + displayValue + "] "); //for Selected == added kuldeep if (Request.QueryString.Get("pid") != null) { string pid = Request.QueryString.Get("pid").ToString(); if (item.NavigateUrl.IndexOf(pid) >= 0) { item.Selected = true; } } if (display && !(disabled && item.ChildItems.Count == 0)) { items.Add(item); } } }
private void PrepareSharePointEnterpriseMenu(MenuItemCollection spItems) { spItems.Add(CreateMenuItem("SiteCollections", "sharepoint_enterprise_sitecollections", @"Icons/sharepoint_sitecollections_48.png")); spItems.Add(CreateMenuItem("StorageUsage", "sharepoint_enterprise_storage_usage", @"Icons/sharepoint_storage_usage_48.png")); spItems.Add(CreateMenuItem("StorageLimits", "sharepoint_enterprise_storage_settings", @"Icons/sharepoint_storage_settings_48.png")); }
private void PrepareExchangeMenu(MenuItemCollection exchangeItems, bool hideItems) { if (Utils.CheckQouta(Quotas.EXCHANGE2007_MAILBOXES, Cntx)) { exchangeItems.Add(CreateMenuItem("Mailboxes", "mailboxes", @"Icons/exchange_mailboxes_48.png")); } if (Utils.CheckQouta(Quotas.EXCHANGE2007_CONTACTS, Cntx)) { exchangeItems.Add(CreateMenuItem("Contacts", "contacts", @"Icons/exchange_contacts_48.png")); } if (Utils.CheckQouta(Quotas.EXCHANGE2007_DISTRIBUTIONLISTS, Cntx)) { exchangeItems.Add(CreateMenuItem("DistributionLists", "dlists", @"Icons/exchange_dlists_48.png")); } //if (ShortMenu) return; if (Utils.CheckQouta(Quotas.EXCHANGE2007_PUBLICFOLDERS, Cntx)) { exchangeItems.Add(CreateMenuItem("PublicFolders", "public_folders", @"Icons/exchange_public_folders_48.png")); } if (Utils.CheckQouta(Quotas.EXCHANGE2013_JOURNALINGMAILBOXES, Cntx)) { exchangeItems.Add(CreateMenuItem("JournalingMailboxes", "journaling_mailboxes", @"Icons/exchange_journaling_mailboxes_48.png")); } if (!hideItems) { if (Utils.CheckQouta(Quotas.EXCHANGE2007_ACTIVESYNCALLOWED, Cntx)) { exchangeItems.Add(CreateMenuItem("ActiveSyncPolicy", "activesync_policy", @"Icons/exchange_activesync_policy_48.png")); } } if (!hideItems) { if (Utils.CheckQouta(Quotas.EXCHANGE2007_MAILBOXES, Cntx)) { exchangeItems.Add(CreateMenuItem("MailboxPlans", "mailboxplans", @"Icons/exchange_mailboxplans_48.png")); } } if (!hideItems) { if (Utils.CheckQouta(Quotas.EXCHANGE2013_ALLOWRETENTIONPOLICY, Cntx)) { exchangeItems.Add(CreateMenuItem("RetentionPolicy", "retentionpolicy", @"Icons/exchange_retentionpolicy_48.png")); } } if (!hideItems) { if (Utils.CheckQouta(Quotas.EXCHANGE2013_ALLOWRETENTIONPOLICY, Cntx)) { exchangeItems.Add(CreateMenuItem("RetentionPolicyTag", "retentionpolicytag", @"Icons/exchange_retentionpolicytag_48.png")); } } if (!hideItems) { if (Utils.CheckQouta(Quotas.EXCHANGE2007_MAILBOXES, Cntx)) { exchangeItems.Add(CreateMenuItem("ExchangeDomainNames", "domains", @"Icons/exchange_accepted_domains_48.png")); } } if (!hideItems) { if (Utils.CheckQouta(Quotas.EXCHANGE2007_MAILBOXES, Cntx)) { exchangeItems.Add(CreateMenuItem("StorageUsage", "storage_usage", @"Icons/exchange_storage_usages_48.png")); } } if (!hideItems) { if (Utils.CheckQouta(Quotas.EXCHANGE2007_DISCLAIMERSALLOWED, Cntx)) { exchangeItems.Add(CreateMenuItem("Disclaimers", "disclaimers", @"Icons/exchange_disclaimers_48.png")); } } }
private void BindMenu(MenuItemCollection items, XmlNodeList nodes) { bool ecUserEnabled = false; bool ecAdminEnabled = PanelSecurity.SelectedUser.EcommerceEnabled; // UserInfo parent = UsersHelper.GetUser(PanelSecurity.SelectedUser.OwnerId); // if (parent != null) { ecUserEnabled = parent.EcommerceEnabled; } foreach (XmlNode node in nodes) { string pageId = null; if (node.Attributes["pageID"] != null) { pageId = node.Attributes["pageID"].Value; } if (!PortalUtils.PageExists(pageId)) { continue; } string url = null; if (node.Attributes["url"] != null) { url = node.Attributes["url"].Value; } string title = null; if (node.Attributes["title"] != null) { title = node.Attributes["title"].Value; } string target = null; if (node.Attributes["target"] != null) { target = node.Attributes["target"].Value; } string roles = null; if (node.Attributes["roles"] != null) { roles = node.Attributes["roles"].Value; } // get custom page parameters XmlNodeList xmlParameters = node.SelectNodes("Parameters/Add"); List <string> parameters = new List <string>(); foreach (XmlNode xmlParameter in xmlParameters) { parameters.Add(xmlParameter.Attributes["name"].Value + "=" + xmlParameter.Attributes["value"].Value); } bool display = true; // set user role visibility second if (!String.IsNullOrEmpty(roles)) { display = false; string[] arrRoles = roles.Split(','); string userRole = PanelSecurity.SelectedUser.Role.ToString(); foreach (string role in arrRoles) { if (String.Compare(userRole, role, true) == 0) { display = true; break; } } } // set ecommerce user visibility first if (display && node.Attributes["ecuser"] != null) { display = ecUserEnabled; } // set ecommerce admin visibility third if (display && node.Attributes["ecadmin"] != null) { display = ecAdminEnabled; } //Audit Log functionality is disabled when user is in Demo mode if ((pageId == "AuditLog") && (PanelSecurity.SelectedUser.IsDemo)) { display = false; } // add menu item if (display) { string pageUrl = !String.IsNullOrEmpty(url) ? url : PortalUtils.NavigatePageURL( pageId, PortalUtils.USER_ID_PARAM, PanelSecurity.SelectedUserId.ToString(), parameters.ToArray()); string pageName = !String.IsNullOrEmpty(title) ? title : PortalUtils.GetLocalizedPageName(pageId); MenuItem item = new MenuItem(pageName, "", "", pageUrl); if (!String.IsNullOrEmpty(target)) { item.Target = target; } items.Add(item); // process nested menu items XmlNodeList xmlNestedNodes = node.SelectNodes("MenuItems/MenuItem"); BindMenu(item.ChildItems, xmlNestedNodes); } } }
public void Add(IMenuItem menuItem) { _menuItemCollection.Add((MenuItem)menuItem); }
//I Method set data to gotted to target MenuItem (Recursive) private void procMenuRender(DataTable dt, MenuItemCollection itms, string filter) { string sUlTag = ""; string sUrlMobile = ""; string sTarget = ""; //I Split target DataTable to DataRow by filter string DataRow[] drs = dt.Select(filter, ""); foreach (DataRow dr in drs) { //I New object of MenuItem for binding data to control MenuItem itm = new MenuItem(); //I Assign url in current row sElementOfMobile = (sElementOfMobile + "<li class=\"dropdown\" style=\"list-style:none;\">"); bool bCheckUrlNoneLink = (dr["Url"] == null) ? true : false; if (!bCheckUrlNoneLink) { if (dr["Url"].ToString().Trim().Equals("")) { bCheckUrlNoneLink = true; } if (dr["Url"].ToString().Trim().Equals("-")) { bCheckUrlNoneLink = true; } } if (bCheckUrlNoneLink) { //I itm.NavigateUrl = SharedBusinessRule.GetConfigInterface("HomeDisplay",this.Page); //I itm.Target = "_blank"; itm.NavigateUrl = "javascript:void(0);"; sUrlMobile = "javascript:void(0);"; sTarget = ""; } else { itm.NavigateUrl = Convert.ToString(dr["Url"]); sUrlMobile = itm.NavigateUrl; sTarget = " target=\"_blank\" "; } string[] ArrTitle = dr["Title"].ToString().Split('|'); string sLng = sDefaultLang; string sTitleByLang = ""; if (ArrTitle.Length > 1) { if (sLng == "EN") { sTitleByLang = ArrTitle[0]; } else { sTitleByLang = ArrTitle[1]; } } else { sTitleByLang = ArrTitle[0]; } #region " Test link or header " DataRow[] drTest = dt.Select("ParentNodeID = '" + dr["NodeID"] + "' AND ISNULL(ParentNodeID,'') <> ''", ""); if (drTest != null) { if (drTest.Length > 0) { //I Header sElementOfMobile = (sElementOfMobile + "<a class=\"dropdown\" href=\"javascript:void(0);\"" + "onclick=\"ftToggleMenu(this);\">" + ((sTitleByLang == "") ? "None" : sTitleByLang) + " <span class=\"dropdown\">" + "<span class=\"caret\"></span></span></a><ul class=\"dropdown\" style=\"display:none;\">"); sUlTag = "</ul>"; } else { //I None head sElementOfMobile = (sElementOfMobile + "<a class=\"dropdown\" href=\"" + sUrlMobile + "\"" + sTarget + ">" + ((sTitleByLang == "") ? "None" : sTitleByLang) + "</a>"); sUlTag = ""; } } else { //I None head sElementOfMobile = (sElementOfMobile + "<a class=\"dropdown\" href=\"" + sUrlMobile + "\"" + sTarget + ">" + sTitleByLang + "</a>"); sUlTag = ""; } #endregion Test link or header --- End //I Assign text by title in current row itm.Text = sTitleByLang; //I Assign value by NodeID in current row itm.Value = dr["NodeID"].ToString(); //I Add dummy data of MenuItem to target MenuItem control itms.Add(itm); //I Get number of level by field Level int Level = int.Parse(dr["Level"].ToString()) + 1; //I Set string filter by "Level" and "ParentNodeID" for Recursive filter = "Level = '" + Level + "' AND ParentNodeID = '" + dr["NodeID"] + "'"; //I Recursive call procMenuRender(dt, itm.ChildItems, filter); sElementOfMobile = (sElementOfMobile + sUlTag + "</li>"); } }
public static void Menu_Start() { menuItems = new MenuItemCollection(); // First LI Main Page menuItems.Add(new MenuItem() { NavigateUrl = "../Views/Default.aspx", Text = "الشاشه الرئيسيه", Value = "1001" }); // 2nd LI is Ul الادخلات int counter = 1; menuItems.Add(new MenuItem() { Text = "الأدخــلات", Value = "100" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Entries/LookUpsViews", Text = "مــلــحـقات الـمـدخلات", Value = "1" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Entries/ChartOfAccountsView", Text = "دليل الحسابات", Value = "2" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Entries/AddDriver", Text = "أضافه سائق", Value = "3" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Entries/AddCars", Text = "أضافه سيارة", Value = "4" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Entries/AddCarMaintenance", Text = "مـتابعة الـصـيـانـة", Value = "5" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Entries/AddProduct", Text = "أضافة صنف", Value = "6" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Entries/AddClient", Text = "أضافة عميل", Value = "7" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Entries/AddSupplier", Text = "أضافة مورد", Value = "8" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Entries/Region", Text = "أضافة منطقه", Value = "9" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Entries/AddListPrice", Text = "قائمه اسعار", Value = "10" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "#", Text = "أضافه مصروفات نثريه", Value = "11" }); // 3th LI is Ul الحركة اليوميه counter++; menuItems.Add(new MenuItem() { Text = "الحركة اليوميه", Value = "101" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/DailyMovements/MonyIn", Text = "سند قبض:نقدي/شيك", Value = "12" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/DailyMovements/MonyOut", Text = "سند صرف:نقدي/شيك", Value = "13" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/DailyMovements/AddTransportCommand", Text = "أمر نقل", Value = "14" }); // 4th LI is Ul الـــصـيـانـة counter++; menuItems.Add(new MenuItem() { Text = "الـــصـيـانـة", Value = "102" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Maintenance/ListingPurchaseInvoice", Text = "أذن اسـتـلام بــضـاعـة", Value = "15" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Maintenance/ListingSalesInvoice", Text = "أذن صــرف بــضـاعـة", Value = "16" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "#", Text = "حــركـة الـصـيـانـة", Value = "17" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Maintenance/AddCarChangeRateOnDis", Text = "معدل التغيير والمسافة المقطوعه", Value = "41" }); // 5th LI is Ul لوحه التحكم counter++; menuItems.Add(new MenuItem() { Text = "لوحه التحكم", Value = "103" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/DashBoard/AddUser", Text = "أضافة مستخدم", Value = "18" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/DashBoard/AddRolePrivilege", Text = "الصلاحيات", Value = "19" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "#", Text = "مراقبه المستخدم", Value = "20" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "#", Text = "ترحيل سنوي", Value = "21" }); // 6th LI is Ul حسابات عامة counter++; menuItems.Add(new MenuItem() { Text = "حسابات عامة", Value = "104" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/GeneralAccounts/IncomsEntry", Text = "قيد مقبوضات", Value = "22" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/GeneralAccounts/OutcomsEntry", Text = "قيد مدفوعات", Value = "23" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/GeneralAccounts/PurshasesEntry", Text = "قيد المشتريات", Value = "24" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/GeneralAccounts/DiaryEntryView", Text = "قيد يوميه", Value = "25" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/GeneralAccounts/OstazAccount", Text = "حساب استاذ", Value = "26" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/GeneralAccounts/AssistantOstazAccount", Text = "حساب استاذ مساعد", Value = "27" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/GeneralAccounts/BalanceReview", Text = "ميزان مراجعه", Value = "28" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "#", Text = "حساب مركز مالي", Value = "29" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "#", Text = "حساب دخل", Value = "30" }); // 7th LI is Ul حسابات عامة counter++; menuItems.Add(new MenuItem() { Text = "تقارير", Value = "105" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Reports/ItemsCard", Text = "كارتة صنف", Value = "31" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Reports/ClientOperationsView", Text = "كشف حساب عميل", Value = "32" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Reports/SupplierOperationsView", Text = "كشف حساب مورد", Value = "33" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "#", Text = "ارصده عملاء", Value = "34" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "#", Text = "ارصده موردين", Value = "35" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Reports/TrasnportOrderReport", Text = "تقارير بأوامر النقل", Value = "36" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Reports/CarMaintenanceCost", Text = "تقارير صيانه السيارت", Value = "37" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "#", Text = "حسابات يوميه", Value = "38" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "#", Text = "تقارير صيانه سيارة مفصل", Value = "39" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Reports/TreasuryReportView", Text = "تقرير خزينه", Value = "40" }); menuItems[counter].ChildItems.Add(new MenuItem() { NavigateUrl = "../../Views/Reports/SolarOrPanzenReport", Text = "تقرير اسـتـعـاضـة السولار", Value = "42" }); Rol_PrivFT RolePriv = new Rol_PrivFT(); List <Rol_PrivFT> Role_PrivList = new List <Rol_PrivFT>(); ///////////////////// get Current user name and its Role and all related Role privilege var LoginUsername = HttpContext.Current.User.Identity.Name; var LogUserRoleID = db.AspUser.Where(user => user.Username == LoginUsername).FirstOrDefault().RoleID; Role_PrivList = db.Rol_PrivFT.Where(item => item.Rol_id == LogUserRoleID).ToList(); /////////////////////////////////////////////////////////////////////////// for (int i = 0; i < menuItems.Count; i++) { try { RolePriv = new Rol_PrivFT(); RolePriv = Role_PrivList.Where(o => o.Priv_id == int.Parse(menuItems[i].Value)).FirstOrDefault(); if (RolePriv != null) { if (RolePriv.AddFlag == true || RolePriv.EditFlag == true || RolePriv.DeleteFlag == true || RolePriv.SearchFlag == true || RolePriv.AllFlag == true) { for (int j = 0; j < menuItems[i].ChildItems.Count; j++) { RolePriv = new Rol_PrivFT(); RolePriv = Role_PrivList.Where(o => o.Priv_id == int.Parse(menuItems[i].ChildItems[j].Value)).FirstOrDefault(); if (RolePriv == null) { menuItems[i].ChildItems.Remove(menuItems[i].ChildItems[j]); j = -1; } else if (RolePriv.AddFlag != true && RolePriv.EditFlag != true && RolePriv.DeleteFlag != true && RolePriv.SearchFlag != true && RolePriv.AllFlag != true) { menuItems[i].ChildItems.Remove(menuItems[i].ChildItems[j]); j = -1; } } } else { menuItems.Remove(menuItems[i]); i = -1; } } else { menuItems.Clear(); } } catch (Exception ex) { continue; } } AddRolePrivilege.UpdateMenu = false; }
void AddToMenu(XmlNode node, MenuItemCollection menuItems, int level) { string funcstr = GetAttrValue(node, "Roles"); if (!string.IsNullOrEmpty(funcstr)) { string[] funcs = funcstr.Split(',');//菜单栏的权限,用逗号分隔 if (!IsInRoles(funcs)) { return; } } MenuItem menuItem = new MenuItem(); menuItem.Text = GetAttrValue(node, "DisplayName"); menuItem.NavigateUrl = GetAttrValue(node, "Url"); menuItem.ImageUrl = GetAttrValue(node, "ImageUrl"); menuItem.Target = GetAttrValue(node, "Target"); if (string.IsNullOrEmpty(menuItem.Target)) { menuItem.Target = "contentFrame"; } menuItem.ToolTip = GetAttrValue(node, "Title"); string visibleStr = GetAttrValue(node, "Visible"); bool visible = true; if (!string.IsNullOrEmpty(visibleStr)) { bool.TryParse(visibleStr, out visible); } if (!visible) { return; } //加载菜单图片 if (!string.IsNullOrEmpty(menuItem.ImageUrl)) { if (level == 0) { menuItem.ImageUrl = ""; menuItem.Text = "------" + menuItem.Text.ToString(); } } else { menuItem.Text = "------" + menuItem.Text.ToString(); } menuItems.Add(menuItem); if (menuItem.NavigateUrl == "#" || string.IsNullOrEmpty(menuItem.NavigateUrl)) { menuItem.NavigateUrl = ""; menuItem.Selectable = false; } else { if (menuItem.Target != "_blank") { if (menuItem.NavigateUrl.IndexOf('?') > 0)//有带querystring的url { menuItem.NavigateUrl += string.Format("&ValuePath={0}&MenuTitle={1}", Server.UrlEncode(menuItem.ValuePath), Server.UrlEncode(menuItem.ToolTip)); } else { menuItem.NavigateUrl += string.Format("?ValuePath={0}&MenuTitle={1}", Server.UrlEncode(menuItem.ValuePath), Server.UrlEncode(menuItem.ToolTip)); } } } foreach (XmlNode mainMenuNode in node.SelectNodes(string.Format("./MenuItems/MenuItem"))) { AddToMenu(mainMenuNode, menuItem.ChildItems, ++level); } }
private static void AddMenuItems(DS_Menu.MenuItemDataTable menuTable, MenuItemCollection pnode, int nodeId) { if(menuTable==null || pnode==null || menuItemCount>500) return; DataRow[] rows = menuTable.Select("status=1 and parentId=" + nodeId.ToString(), "parentID, menuOrder"); foreach (DS_Menu.MenuItemRow row in rows) { MenuItem item = new MenuItem(); item.Text = row.title; item.Value = row.menuID.ToString(); item.NavigateUrl = row.navigateUrl; pnode.Add(item); menuItemCount++; AddMenuItems(menuTable, item.ChildItems, row.menuID); } }
private void BindMenu(MenuItemCollection items, XmlNodeList nodes) { foreach (XmlNode node in nodes) { string pageId = null; if (node.Attributes["pageID"] != null) { pageId = node.Attributes["pageID"].Value; } if (!PortalUtils.PageExists(pageId)) { continue; } string url = null; if (node.Attributes["url"] != null) { url = node.Attributes["url"].Value; } string title = null; if (node.Attributes["title"] != null) { title = node.Attributes["title"].Value; } string target = null; if (node.Attributes["target"] != null) { target = node.Attributes["target"].Value; } string resourceGroup = null; if (node.Attributes["resourceGroup"] != null) { resourceGroup = node.Attributes["resourceGroup"].Value; } string quota = null; if (node.Attributes["quota"] != null) { quota = node.Attributes["quota"].Value; } bool disabled = false; if (node.Attributes["disabled"] != null) { disabled = Utils.ParseBool(node.Attributes["disabled"].Value, false); } // get custom page parameters XmlNodeList xmlParameters = node.SelectNodes("Parameters/Add"); List <string> parameters = new List <string>(); foreach (XmlNode xmlParameter in xmlParameters) { parameters.Add(xmlParameter.Attributes["name"].Value + "=" + xmlParameter.Attributes["value"].Value); } // add menu item string pageUrl = !String.IsNullOrEmpty(url) ? url : PortalUtils.NavigatePageURL( pageId, PortalUtils.SPACE_ID_PARAM, PanelSecurity.PackageId.ToString(), parameters.ToArray()); string pageName = !String.IsNullOrEmpty(title) ? title : PortalUtils.GetLocalizedPageName(pageId); MenuItem item = new MenuItem(pageName, "", "", disabled ? null : pageUrl); if (!String.IsNullOrEmpty(target)) { item.Target = target; } item.Selectable = !disabled; // check groups/quotas bool display = true; if (cntx != null) { display = (String.IsNullOrEmpty(resourceGroup) || cntx.Groups.ContainsKey(resourceGroup)) && (String.IsNullOrEmpty(quota) || (cntx.Quotas.ContainsKey(quota) && cntx.Quotas[quota].QuotaAllocatedValue != 0)); } if (display) { // process nested menu items XmlNodeList xmlNestedNodes = node.SelectNodes("MenuItems/MenuItem"); BindMenu(item.ChildItems, xmlNestedNodes); } if (display && !(disabled && item.ChildItems.Count == 0)) { items.Add(item); } } }
protected void CloneMenu (Menu menuSrc) { Dispose (true); menu_items = new MenuItemCollection (this); for (int i = 0; i < menuSrc.MenuItems.Count ; i++) menu_items.Add (menuSrc.MenuItems [i].CloneMenu ()); }
private void BindMenu(MenuItemCollection items, XmlNodeList nodes) { foreach (XmlNode node in nodes) { string pageId = null; if (node.Attributes["pageID"] != null) { pageId = node.Attributes["pageID"].Value; } if (!PortalUtils.PageExists(pageId)) { continue; } string url = null; if (node.Attributes["url"] != null) { url = node.Attributes["url"].Value; } string title = null; if (node.Attributes["title"] != null) { title = node.Attributes["title"].Value; } string target = null; if (node.Attributes["target"] != null) { target = node.Attributes["target"].Value; } string roles = null; if (node.Attributes["roles"] != null) { roles = node.Attributes["roles"].Value; } string selectedUserContext = null; if (node.Attributes["selectedUserContext"] != null) { selectedUserContext = node.Attributes["selectedUserContext"].Value; } // get custom page parameters XmlNodeList xmlParameters = node.SelectNodes("Parameters/Add"); List <string> parameters = new List <string>(); foreach (XmlNode xmlParameter in xmlParameters) { parameters.Add(xmlParameter.Attributes["name"].Value + "=" + xmlParameter.Attributes["value"].Value); } bool display = true; // set user role visibility second if (!String.IsNullOrEmpty(selectedUserContext)) { display = false; string[] arrRoles = selectedUserContext.Split(','); string userRole = PanelSecurity.SelectedUser.Role.ToString(); foreach (string role in arrRoles) { if (String.Compare(userRole, role, true) == 0) { display = true; break; } } } if ((!String.IsNullOrEmpty(roles)) & display) { display = false; string[] arrRoles = roles.Split(','); string userRole = PanelSecurity.LoggedUser.Role.ToString(); foreach (string role in arrRoles) { if (String.Compare(userRole, role, true) == 0) { display = true; break; } } } //Audit Log functionality is disabled when user is in Demo mode if ((pageId == "AuditLog") && (PanelSecurity.SelectedUser.IsDemo)) { display = false; } // add menu item if (display) { string pageUrl = !String.IsNullOrEmpty(url) ? url : PortalUtils.NavigatePageURL( pageId, PortalUtils.USER_ID_PARAM, PanelSecurity.SelectedUserId.ToString(), parameters.ToArray()); string pageName = !String.IsNullOrEmpty(title) ? title : PortalUtils.GetLocalizedPageName(pageId); MenuItem item = new MenuItem(pageName, "", "", pageUrl); if (!String.IsNullOrEmpty(target)) { item.Target = target; } //for Selected == added kuldeep if (Request.QueryString.Get("pid") != null) { string pid = Request.QueryString.Get("pid").ToString(); //Parent Menu Replacement if (pid.Equals("SpaceHome", StringComparison.CurrentCultureIgnoreCase)) { pid = "UserSpaces"; } if (item.NavigateUrl.IndexOf(pid) >= 0) { item.Selected = true; } } items.Add(item); // process nested menu items XmlNodeList xmlNestedNodes = node.SelectNodes("MenuItems/MenuItem"); BindMenu(item.ChildItems, xmlNestedNodes); } } }
private void PrepareBlackBerryMenu(MenuItemCollection bbItems) { bbItems.Add(CreateMenuItem("BlackBerryUsers", "blackberry_users", @"Icons/blackberry_users_48.png")); }
/// <summary> /// This method is used from the OnDataBinding method; it traverses the XML document, /// building up the object model. /// </summary> /// <param name="itemsNode">The current menuItem XmlNode</param> /// <param name="parentID">The ID of the parent menuItem XmlNode</param> /// <returns>A set of MenuItems for this menu.</returns> protected virtual MenuItemCollection GatherMenuItems(XmlNode itemsNode, string parentID) { // Make sure we have an XmlNode instance - it should never be null, else the // XML document does not have the expected structure if (itemsNode == null) throw new ArgumentException("The XML data for the Menu control is in an invalid format."); MenuItemCollection mymic = new MenuItemCollection(); if (IsTrackingViewState) ((IStateManager) mymic).TrackViewState(); // iterate through each MenuItem XmlNodeList mynl = itemsNode.ChildNodes; for (int i = 0; i < mynl.Count; i++) { XmlNode node = mynl[i]; // Create the menuitem if (node.Name == "menuItem") mymic.Add(BuildMenuItem(node, parentID, i)); if (node.Name == "menuSpacer") mymic.Add(BuildMenuSpacer(node, parentID, i)); } return mymic; }
private void PrepareOCSMenu(MenuItemCollection osItems) { osItems.Add(CreateMenuItem("OCSUsers", "ocs_users")); }
private static void AddMenuItem(MenuItemCollection items, string url, int categotyID, Hashtable catTitles, Hashtable catTitlesEng, bool adminMenu) { string title = ""; string titleEn = "ekran"; if (catTitles[categotyID] != null) { title = catTitles[categotyID].ToString(); if (adminMenu) { items.Add(AddMenuItem(url + "&CategoryID=" + categotyID.ToString(), "", title, categotyID)); } else { if (catTitlesEng[categotyID] != null) { titleEn = catTitlesEng[categotyID].ToString(); } items.Add(AddMenuItem(GenerateFriendlyURL(titleEn, categotyID.ToString()), "", title, categotyID)); } } }