void Page_Init(object sender, EventArgs e) { // create the Parent EasyMenu mainEM = new EasyMenu(); // set the ID (must be unique) mainEM.ID = "MainEM"; // Create the submenus em_1 = new EasyMenu(); em_1.ID = "Easymenu1"; em_2 = new EasyMenu(); em_2.ID = "Easymenu2"; em_4 = new EasyMenu(); em_4.ID = "Easymenu4"; em_5 = new EasyMenu(); em_5.ID = "Easymenu5"; em_6 = new EasyMenu(); em_6.ID = "Easymenu6"; // add the submenus to the page placeHolder1.Controls.Add(em_1); placeHolder1.Controls.Add(em_2); placeHolder1.Controls.Add(em_4); placeHolder1.Controls.Add(em_5); placeHolder1.Controls.Add(em_6); // add the menu to the placeholder on the page placeHolder1.Controls.Add(mainEM); }
protected void dgProducts_ItemCreated(object sender, DataGridItemEventArgs e) { if (e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Footer) { PlaceHolder PlaceHolder1 = (PlaceHolder)e.Item.FindControl("PlaceHolder1"); EasyMenu EasyMenu1 = new EasyMenu(); EasyMenu1.ID = "EasyMenu1_" + e.Item.ItemIndex.ToString(); EasyMenu1.ShowEvent = MenuShowEvent.Always; EasyMenu1.Position = MenuPosition.Horizontal; EasyMenu1.StyleFolder = "styles/horizontal1"; EasyMenu1.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu1.ID + "_item1", "Buy for...", "", "", "", "")); EasyMenu1.AddItem(new OboutInc.EasyMenu_Pro.MenuSeparator(EasyMenu1.ID + "_separator1", "|")); EasyMenu1.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu1.ID + "_item2", "Rent for...", "", "", "", "")); EasyMenu1.Width = "100%"; EasyMenu EasyMenu2 = new EasyMenu(); EasyMenu2.ID = "EasyMenu2_" + e.Item.ItemIndex.ToString(); EasyMenu2.ShowEvent = MenuShowEvent.MouseOver; EasyMenu2.Position = MenuPosition.Vertical; EasyMenu2.StyleFolder = "styles/horizontal1"; EasyMenu2.AttachTo = EasyMenu1.ID + "_item1"; EasyMenu2.Align = MenuAlign.Right; switch(e.Item.ItemIndex) { case 0: EasyMenu2.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu2.ID + "_item1", "49.99$ for a piece", "", "", "", "")); EasyMenu2.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu2.ID + "_item2", "89.99$ for two pieces", "", "", "", "")); break; case 1: EasyMenu2.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu2.ID + "_item1", "29.99$ for a piece", "", "", "", "")); EasyMenu2.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu2.ID + "_item2", "54.99$ for two pieces", "", "", "", "")); EasyMenu2.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu2.ID + "_item3", "99.99$ for four pieces", "", "", "", "")); break; } EasyMenu EasyMenu3 = new EasyMenu(); EasyMenu3.ID = "EasyMenu3_" + e.Item.ItemIndex.ToString(); EasyMenu3.ShowEvent = MenuShowEvent.MouseOver; EasyMenu3.Position = MenuPosition.Vertical; EasyMenu3.StyleFolder = "styles/horizontal1"; EasyMenu3.AttachTo = EasyMenu1.ID + "_item2"; EasyMenu3.Align = MenuAlign.Right; switch(e.Item.ItemIndex) { case 0: EasyMenu3.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu3.ID + "_item1", "2.99$ for a day", "", "", "", "")); EasyMenu3.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu3.ID + "_item2", "4.99$ for two days", "", "", "", "")); EasyMenu3.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu3.ID + "_item3", "9.99$ for a week", "", "", "", "")); break; case 1: EasyMenu3.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu3.ID + "_item1", "Not Available", "", "", "", "")); break; } PlaceHolder1.Controls.Add(EasyMenu1); PlaceHolder1.Controls.Add(EasyMenu2); PlaceHolder1.Controls.Add(EasyMenu3); } }
public Example(IMyGridTerminalSystem grid, IMyProgrammableBlock me, Action <string> echo, TimeSpan elapsedTime) : base(grid, me, echo, elapsedTime) { var children = new List <EasyMenuItem>(); children.Clear(); foreach (var title in menuItems.Keys) { children.Add(new EasyMenuItem(title, delegate(EasyMenuItem menuItem) { menuItem.children.Clear(); menuItem.children.Add(new EasyMenuItem("hidden")); this.inCAL = true; this.calCommand = menuItems[menuItem.GetText()]; return(true); })); } // Create menu this.menu = new EasyMenu(menuTitle, children.ToArray()); this.lcd = Blocks.Named(lcdBlockName).FindOrFail("Menu LCD not found!").GetBlock(0); this.cal = Blocks.Named(calBlockName).FindOrFail("CAL Programmable block not found!").GetBlock(0); lcd.WritePublicTitle(""); // Handle Arguments On("Up", delegate() { this.menu.Up(); doUpdates(); }); On("Down", delegate() { this.menu.Down(); doUpdates(); }); On("Choose", delegate() { this.menu.Choose(); doUpdates(); }); On("Back", delegate() { this.menu.Back(); this.inCAL = false; doUpdates(); }); Every(100 * EasyAPI.Milliseconds, delegate() { doUpdates(); }); }
void Page_Init(object sender, EventArgs e) { // EasymenuMain1 EasymenuMain1 = new EasyMenu(); EasymenuMain1.ID = "EasymenuMain1"; placeHolder1.Controls.Add(EasymenuMain1); // EasymenuMain2 EasymenuMain2 = new EasyMenu(); EasymenuMain2.ID = "EasymenuMain2"; placeHolder2.Controls.Add(EasymenuMain2); // Easymenu11 Easymenu11 = new EasyMenu(); Easymenu11.ID = "Easymenu11"; placeHolder1.Controls.Add(Easymenu11); // Easymenu12 Easymenu12 = new EasyMenu(); Easymenu12.ID = "Easymenu12"; placeHolder1.Controls.Add(Easymenu12); // Easymenu13 Easymenu13 = new EasyMenu(); Easymenu13.ID = "Easymenu13"; placeHolder1.Controls.Add(Easymenu13); // Easymenu14 Easymenu14 = new EasyMenu(); Easymenu14.ID = "Easymenu14"; placeHolder1.Controls.Add(Easymenu14); // Easymenu21 Easymenu21 = new EasyMenu(); Easymenu21.ID = "Easymenu21"; placeHolder2.Controls.Add(Easymenu21); // Easymenu22 Easymenu22 = new EasyMenu(); Easymenu22.ID = "Easymenu22"; placeHolder2.Controls.Add(Easymenu22); // Easymenu23 Easymenu23 = new EasyMenu(); Easymenu23.ID = "Easymenu23"; placeHolder2.Controls.Add(Easymenu23); // Easymenu24 Easymenu24 = new EasyMenu(); Easymenu24.ID = "Easymenu24"; placeHolder2.Controls.Add(Easymenu24); }
public void InstantiateIn(Control container) { PlaceHolder templatePlaceHolder = new PlaceHolder(); container.Controls.Add(templatePlaceHolder); Literal div1 = new Literal(); div1.Text = "<div style=\"position: relative;\">"; EasyMenu tabStrip = new EasyMenu(); tabStrip.SelectedItemId = "Item_3_2"; tabStrip.ID = "EasymenuTabStrip2"; tabStrip.ShowEvent = MenuShowEvent.Always; tabStrip.StyleFolder = "../EasyMenu/styles/TabStrip2"; tabStrip.Position = MenuPosition.Horizontal; tabStrip.Width = "430"; OboutInc.EasyMenu_Pro.MenuItem item1 = new OboutInc.EasyMenu_Pro.MenuItem(); item1.InnerHtml = "<span style='cursor:default'>Personal Information</span>"; item1.OnClientClick = "SelectTab(3, 2)"; item1.ID = "Item_3_2"; OboutInc.EasyMenu_Pro.MenuItem item2 = new OboutInc.EasyMenu_Pro.MenuItem(); item2.InnerHtml = "<span style='cursor:default'>Contact Information</span>"; item2.OnClientClick = "SelectTab(4, 2)"; item2.ID = "Item_4_2"; OboutInc.EasyMenu_Pro.MenuItem item3 = new OboutInc.EasyMenu_Pro.MenuItem(); item3.InnerHtml = "<span style='cursor:default'>Notes</span>"; item3.OnClientClick = "SelectTab(5, 3)"; item3.ID = "Item_5_3"; tabStrip.Components.Add(item1); tabStrip.Components.Add(item2); tabStrip.Components.Add(item3); Literal div2 = new Literal(); div2.Text = "<div class=\"tabs-border\"> </div>"; Literal enddiv1 = new Literal(); enddiv1.Text = "</div>"; templatePlaceHolder.Controls.Add(div1); templatePlaceHolder.Controls.Add(tabStrip); templatePlaceHolder.Controls.Add(div2); templatePlaceHolder.Controls.Add(enddiv1); }
private void Page_Init(object sender, System.EventArgs e) { string sConnectionString; OleDbDataReader oReader; sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Page.Server.MapPath("../App_Data/DBDEMO_horizontal.mdb"); OleDbConnection Cn = new OleDbConnection(sConnectionString); string SQL = "SELECT * FROM Menus a Inner Join MenuItems b ON (a.ID = b.MENUID) ORDER BY a.ATTACHTO, a.ID, b.ORDER"; OleDbCommand Com = new OleDbCommand(SQL, Cn); Cn.Open(); oReader = Com.ExecuteReader(); string lastMenuId = ""; EasyMenu oem = null; // Populate EM in one loop. while (oReader.Read()) { // Initialising a new EM if (oReader.GetString(oReader.GetOrdinal("menuID")) != lastMenuId) { oem = new EasyMenu(); oem.ID = oReader.GetString(oReader.GetOrdinal("menuid")); // if an attachto property is set, this is not the main menu if (!oReader.IsDBNull(oReader.GetOrdinal("attachto"))) { oem.AttachTo = oReader.GetString(oReader.GetOrdinal("attachto")); // we add the menus to the page controls placeHolder1.Controls.Add(oem); } // otherwise this is the main menu else { // we add the menu to the placeholder (to display it where we need in the page) placeHolder1.Controls.Add(oem); } Page.Session["EasyMenu_" + oem.ID] = oem; lastMenuId = oReader.GetString(oReader.GetOrdinal("menuID")); } } oReader.Close(); Cn.Close(); }
private void Page_Init(object sender, System.EventArgs e) { string sConnectionString; OleDbDataReader oReader; sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../App_Data/DBDEMO_horizontal.mdb"); OleDbConnection Cn = new OleDbConnection(sConnectionString); string SQL = "SELECT * FROM Menus a Inner Join MenuItems b ON (a.ID = b.MENUID) ORDER BY a.ATTACHTO, a.ID, b.ORDER"; OleDbCommand Com = new OleDbCommand(SQL,Cn); Cn.Open(); oReader = Com.ExecuteReader(); string lastMenuId = ""; EasyMenu oem = null; // Populate EM in one loop. while (oReader.Read()) { // Initialising a new EM if (oReader.GetString(oReader.GetOrdinal("menuID")) != lastMenuId) { oem = new EasyMenu(); oem.ID = oReader.GetString(oReader.GetOrdinal("menuid")); // if an attachto property is set, this is not the main menu if (!oReader.IsDBNull(oReader.GetOrdinal("attachto"))) { oem.AttachTo = oReader.GetString(oReader.GetOrdinal("attachto")); // we add the menus to the page controls placeHolder1.Controls.Add(oem); } // otherwise this is the main menu else { // we add the menu to the placeholder (to display it where we need in the page) placeHolder1.Controls.Add(oem); } Session["EasyMenu_" + oem.ID] = oem; lastMenuId = oReader.GetString(oReader.GetOrdinal("menuID")); } } oReader.Close(); Cn.Close(); }
public Example(IMyGridTerminalSystem grid, IMyProgrammableBlock me, Action <string> echo, TimeSpan elapsedTime) : base(grid, me, echo, elapsedTime) { // Create menu this.menu = new EasyMenu("Test Menu", new [] { new EasyMenuItem("Play Sound", playSound), new EasyMenuItem("Door Status", new[] { new EasyMenuItem("Door 1", toggleDoor, doorStatus), new EasyMenuItem("Door 2", toggleDoor, doorStatus), new EasyMenuItem("Door 3", toggleDoor, doorStatus), new EasyMenuItem("Door 4", toggleDoor, doorStatus) }), new EasyMenuItem("Do Nothing") }); // Get blocks this.speaker = Blocks.Named("MenuSpeaker").FindOrFail("MenuSpeaker not found!"); this.lcd = new EasyLCD(Blocks.Named("MenuLCD").FindOrFail("MenuLCD not found!")); // Handle Arguments On("Up", delegate() { this.menu.Up(); doUpdates(); }); On("Down", delegate() { this.menu.Down(); doUpdates(); }); On("Choose", delegate() { this.menu.Choose(); doUpdates(); }); On("Back", delegate() { this.menu.Back(); doUpdates(); }); On("Update", delegate() { doUpdates(); }); }
private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { EasyMenu1 = new EasyMenu(); EasyMenu1.ID = "EasyMenu1"; EasyMenu1.StyleFolder = "styles/windowsxp"; EasyMenu1.IconsFolder = "icons"; EasyMenu1.UseIcons = true; EasyMenu1.Width = "140"; EasyMenu1.AttachTo = "div1"; EasyMenu1.ShowEvent = MenuShowEvent.ContextMenu; EasyMenu1.Align = MenuAlign.Under; // add the items for the menu EasyMenu1.AddMenuItem("menuItem1", "<span style='color:#666666; font:bold; cursor:pointer;'>obout.com<b style='color:crimson; text-decoration:none;'> Home</b></span>", null, "http://www.obout.com", "_blank", null); EasyMenu1.AddMenuItem("menuItem2", "Alert", null, null, null, "alert('you just clicked Alert')"); EasyMenu1.AddMenuItem("menuItem3", "<input type='checkbox' style='height:14px; width:14px;' checked='1'> Any <span style='background-color:gold; padding-left:2px; padding-right:2px;'>HTML</span>", null, null, null, null); EasyMenu1.AddSeparator("menuSeparator1", ""); EasyMenu1.AddMenuItem("menuItem4", "Browser Operation", null, null, null, null); EasyMenu1.AddSeparator("menuSeparator2", ""); EasyMenu1.AddMenuItem("menuItem5", "Recycle", "xpRecycle.gif", null, null, null); // add the menu to the placeholder on the page placeHolder1.Controls.Add(EasyMenu1); EasyMenu2 = new EasyMenu(); EasyMenu2.ID = "EasyMenu2"; EasyMenu2.StyleFolder = "styles/windowsxp"; EasyMenu2.IconsFolder = "icons"; EasyMenu2.UseIcons = true; EasyMenu2.Width = "140"; EasyMenu2.AttachTo = "menuItem4"; EasyMenu2.ShowEvent = MenuShowEvent.MouseOver; EasyMenu2.Align = MenuAlign.Right; // add the items for the menu EasyMenu2.AddMenuItem("menuItem11", "Open New Page", "new.gif", "about:blank", "_blank", null); EasyMenu2.AddMenuItem("menuItem12", "Close This Page", "delete.gif", null, null, "try {window.opener.focus(); window.opener = this; window.close();} catch (e) {};"); placeHolder1.Controls.Add(EasyMenu2); } }
public Example(IMyGridTerminalSystem grid, IMyProgrammableBlock me, Action<string> echo, TimeSpan elapsedTime) : base(grid, me, echo, elapsedTime) { // Create menu this.menu = new EasyMenu("Test Menu", new [] { new EasyMenuItem("Play Sound", playSound), new EasyMenuItem("Door Status", new[] { new EasyMenuItem("Door 1", toggleDoor, doorStatus), new EasyMenuItem("Door 2", toggleDoor, doorStatus), new EasyMenuItem("Door 3", toggleDoor, doorStatus), new EasyMenuItem("Door 4", toggleDoor, doorStatus) }), new EasyMenuItem("Do Nothing") }); // Get blocks this.speaker = Blocks.Named("MenuSpeaker").FindOrFail("MenuSpeaker not found!"); this.lcd = new EasyLCD(Blocks.Named("MenuLCD").FindOrFail("MenuLCD not found!")); // Handle Arguments On("Up", delegate() { this.menu.Up(); doUpdates(); }); On("Down", delegate() { this.menu.Down(); doUpdates(); }); On("Choose", delegate() { this.menu.Choose(); doUpdates(); }); On("Back", delegate() { this.menu.Back(); doUpdates(); }); }
public Example(IMyGridTerminalSystem grid, IMyProgrammableBlock me, Action <string> echo, TimeSpan elapsedTime) : base(grid, me, echo, elapsedTime) { // Create menu this.menu = new EasyMenu("Test Menu", new [] { new EasyMenuItem("Play Sound", playSound), new EasyMenuItem("Door Status", new[] { new EasyMenuItem("Door 1", toggleDoor, doorStatus), new EasyMenuItem("Door 2", toggleDoor, doorStatus), new EasyMenuItem("Door 3", toggleDoor, doorStatus), new EasyMenuItem("Door 4", toggleDoor, doorStatus) }), new EasyMenuItem("Do Nothing") }); // Get blocks this.timer = Blocks.Named("MenuTimer").FindOrFail("MenuTimer not found!"); this.screen = Blocks.Named("MenuLCD").FindOrFail("MenuLCD not found!"); this.speaker = Blocks.Named("MenuSpeaker").FindOrFail("MenuSpeaker not found!"); this.lcd = new EasyLCD(this.screen); Every(100 * Milliseconds, doUpdates); }
private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { string sConnectionString; OleDbDataReader oReader; // The database has 2 tables, Menus for the principal menus and MenuItems for the items // Each Menu has an ID, and each item of that menu must have the same MENUID so they can be related // The Menu that has no ATTACHTO property set in the database is the main menu (parent) // and is the one that has ShowEvent set to Always. This has to be the first menu to add on the page // hence we order by ATTACHTO field first. sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Page.Server.MapPath("../App_Data/DBDEMO_horizontal.mdb"); OleDbConnection Cn = new OleDbConnection(sConnectionString); string SQL = "SELECT * FROM Menus a Inner Join MenuItems b ON (a.ID = b.MENUID) ORDER BY a.ATTACHTO, a.ID, b.ORDER"; OleDbCommand Com = new OleDbCommand(SQL, Cn); Cn.Open(); oReader = Com.ExecuteReader(); string lastMenuId = ""; EasyMenu oem = null; // Populate EM in one loop. while (oReader.Read()) { // Initialising a new EM if (oReader.GetString(oReader.GetOrdinal("menuID")) != lastMenuId) { oem = (EasyMenu)Page.Session["EasyMenu_" + oReader.GetString(oReader.GetOrdinal("menuid"))]; oem.Position = MenuPosition.Horizontal; oem.Width = "140"; oem.IconsFolder = "Icons"; oem.StyleFolder = oReader.GetString(oReader.GetOrdinal("style")); // if an attachto property is set, this is not the main menu if (!oReader.IsDBNull(oReader.GetOrdinal("attachto"))) { oem.ShowEvent = MenuShowEvent.MouseOver; if (oem.AttachTo != "item1" && oem.AttachTo != "item2" && oem.AttachTo != "item3") { oem.Align = MenuAlign.Right; } else { oem.Align = MenuAlign.Under; } oem.Position = MenuPosition.Vertical; } // otherwise this is the main menu else { oem.ShowEvent = MenuShowEvent.Always; oem.Width = "400px"; } } // Adding either a Separator or an Item if (oReader.GetString(oReader.GetOrdinal("ITEMTYPE")) == "S") { oem.AddSeparator(oReader.GetString(oReader.GetOrdinal("b.ID")), oReader.IsDBNull(oReader.GetOrdinal("HTML")) ? "" : oReader.GetString(oReader.GetOrdinal("HTML"))); } else if (oReader.GetString(oReader.GetOrdinal("ITEMTYPE")) == "I") { oem.AddMenuItem(oReader.GetString(oReader.GetOrdinal("b.ID")), oReader.IsDBNull(oReader.GetOrdinal("HTML")) ? "" : oReader.GetString(oReader.GetOrdinal("HTML")), oReader.IsDBNull(oReader.GetOrdinal("ICON")) ? "" : oReader.GetString(oReader.GetOrdinal("ICON")), oReader.IsDBNull(oReader.GetOrdinal("URL")) ? "" : oReader.GetString(oReader.GetOrdinal("URL")), oReader.IsDBNull(oReader.GetOrdinal("URLTARGET")) ? "" : oReader.GetString(oReader.GetOrdinal("URLTARGET")), oReader.IsDBNull(oReader.GetOrdinal("ONCLIENTCLICK")) ? "" : oReader.GetString(oReader.GetOrdinal("ONCLIENTCLICK"))); } lastMenuId = oReader.GetString(oReader.GetOrdinal("menuID")); } oReader.Close(); Cn.Close(); } }
private void BuildMenu2(OleDbDataReader oReader) { /*** main menu - records with ParentId = 0 ***/ EasyMenu mainEM = null; /*** ***/ /*** list with child menus ***/ Hashtable childMenus = null; while (oReader.Read()) { int parentId = oReader.GetInt32(1); if (parentId == 0) { if (mainEM == null) { mainEM = new EasyMenu(); mainEM.ID = "VmainEM"; mainEM.StyleFolder = "styles/horizontal1"; mainEM.Width = "400"; mainEM.ShowEvent = MenuShowEvent.Always; mainEM.Position = MenuPosition.Horizontal; } mainEM.AddItem(new OboutInc.EasyMenu_Pro.MenuItem("Vitem_" + oReader.GetInt32(0).ToString(), oReader.GetString(2), "", "", "", "")); placeHolder2.Controls.Add(mainEM); } else { if (childMenus == null) childMenus = new Hashtable(); /* first time the menu is ceated */ if (!childMenus.ContainsKey(parentId)) { EasyMenu childEM = new EasyMenu(); childEM.ID = "VchildEM_" + parentId; childEM.StyleFolder = "styles/horizontal1"; childEM.ShowEvent = MenuShowEvent.MouseOver; childEM.AttachTo = "Vitem_" + parentId; childEM.Width = "150"; int menuLevel = oReader.GetInt32(3); if (menuLevel == 1) childEM.Align = MenuAlign.Under; else childEM.Align = MenuAlign.Left; childEM.AddItem(new OboutInc.EasyMenu_Pro.MenuItem("Vitem_" + oReader.GetInt32(0).ToString(), oReader.GetString(2), "", "", "", "")); childMenus.Add(parentId, childEM); placeHolder1.Controls.Add(childEM); } /* items are added to the already created menu */ else { EasyMenu childEM = (EasyMenu)childMenus[parentId]; childEM.AddItem(new OboutInc.EasyMenu_Pro.MenuItem("Vitem_" + oReader.GetInt32(0).ToString(), oReader.GetString(2), "", "", "", "")); } } } }
private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { // create the Parent EasyMenu mainEM = new EasyMenu(); // set the ID (must be unique) mainEM.ID = "MainEM"; // set the style for this menu mainEM.StyleFolder = "styles/horizontal7"; mainEM.Width = "330"; // show event is always so the menu is always visible // this menu doesn't require any AttachTo or Align properties set mainEM.ShowEvent = MenuShowEvent.Always; // display the menu horizontally mainEM.Position = MenuPosition.Horizontal; // the parent menu looks different so we need to set different // CSS classes names for its items and the menu itself // css classes names for the menu and the item container mainEM.CSSMenu = "ParentMenu"; mainEM.CSSMenuItemContainer = "ParentItemContainer"; // css classes names for MenuItems CSSClasses MenuItemCssClasses = mainEM.CSSClassesCollection[mainEM.CSSClassesCollection.Add(new CSSClasses(typeof(MenuItem)))]; MenuItemCssClasses.ComponentSubMenuCellOver = "ParentItemSubMenuCellOver"; MenuItemCssClasses.ComponentContentCell = "ParentItemContentCell"; MenuItemCssClasses.Component = "ParentItem"; MenuItemCssClasses.ComponentSubMenuCell = "ParentItemSubMenuCell"; MenuItemCssClasses.ComponentIconCellOver = "ParentItemIconCellOver"; MenuItemCssClasses.ComponentIconCell = "ParentItemIconCell"; MenuItemCssClasses.ComponentOver = "ParentItemOver"; MenuItemCssClasses.ComponentContentCellOver = "ParentItemContentCellOver"; // add the classes names to the collection mainEM.CSSClassesCollection.Add(MenuItemCssClasses); // css classes names for MenuSeparators CSSClasses MenuSeparatorCssClasses = mainEM.CSSClassesCollection[mainEM.CSSClassesCollection.Add(new CSSClasses(typeof(MenuSeparator)))]; MenuSeparatorCssClasses.ComponentSubMenuCellOver = "ParentSeparatorSubMenuCellOver"; MenuSeparatorCssClasses.ComponentContentCell = "ParentSeparatorContentCell"; MenuSeparatorCssClasses.Component = "ParentSeparator"; MenuSeparatorCssClasses.ComponentSubMenuCell = "ParentSeparatorSubMenuCell"; MenuSeparatorCssClasses.ComponentIconCellOver = "ParentSeparatorIconCellOver"; MenuSeparatorCssClasses.ComponentIconCell = "ParentSeparatorIconCell"; MenuSeparatorCssClasses.ComponentOver = "ParentSeparatorOver"; MenuSeparatorCssClasses.ComponentContentCellOver = "ParentSeparatorContentCellOver"; // add the classes names to the collection mainEM.CSSClassesCollection.Add(MenuSeparatorCssClasses); // add the items for the menu mainEM.AddItem(new MenuItem("item1", "Item 1", "", "", "", "")); mainEM.AddSeparator("mainMenuSeparator1", " "); mainEM.AddItem(new MenuItem("item2", "Item 2", "", "", "", "")); mainEM.AddSeparator("mainMenuSeparator2", " "); mainEM.AddItem(new MenuItem("item3", "Item 3", "", "", "", "")); mainEM.AddSeparator("mainMenuSeparator3", " "); mainEM.AddItem(new MenuItem("item4", "Item 4", "", "", "", "")); mainEM.AddSeparator("mainMenuSeparator4", " "); mainEM.AddItem(new MenuItem("item5", "Item 5", "", "", "", "")); // add the menu to the placeholder on the page placeHolder1.Controls.Add(mainEM); // Create the submenus em_1 = new EasyMenu(); em_1.ID = "Easymenu1"; // this will attach to the first item of the parent menu (id=item1) em_1.AttachTo = "item1"; em_1.StyleFolder = "styles/horizontal7"; em_1.Width = "140"; // it will show on mouse over em_1.ShowEvent = MenuShowEvent.MouseOver; // and will align under the item to which it is attached em_1.Align = MenuAlign.Under; em_1.OffsetVertical = -2; // here are this menu's items em_1.AddItem(new MenuItem("menuItem1", "SubItem 1", "", "", "", "alert('Item 1 - SubItem 1')")); em_1.AddItem(new MenuItem("menuItem2", "SubItem 2", "", "", "", "alert('Item 1 - SubItem 2')")); em_1.AddItem(new MenuItem("menuItem3", "SubItem 3", "", "", "", "alert('Item 1 - SubItem 3')")); em_1.AddItem(new MenuItem("menuItem4", "SubItem 4", "", "", "", "alert('Item 1 - SubItem 4')")); em_1.AddItem(new MenuItem("menuItem5", "SubItem 5", "", "", "", "alert('Item 1 - SubItem 5')")); // and so on for every submenu em_2 = new EasyMenu(); em_2.ID = "Easymenu2"; em_2.AttachTo = "item2"; em_2.StyleFolder = "styles/horizontal7"; em_2.Width = "140"; em_2.ShowEvent = MenuShowEvent.MouseOver; em_2.Align = MenuAlign.Under; em_2.OffsetVertical = -2; em_2.AddItem(new MenuItem("menuItem6", "SubItem 1", "", "", "", "alert('Item 2 - SubItem 1')")); em_2.AddItem(new MenuItem("menuItem7", "SubItem 2", "", "", "", "alert('Item 2 - SubItem 2')")); em_2.AddItem(new MenuItem("menuItem8", "SubItem 3", "", "", "", "alert('Item 2 - SubItem 3')")); em_4 = new EasyMenu(); em_4.ID = "Easymenu4"; em_4.AttachTo = "item4"; em_4.StyleFolder = "styles/horizontal7"; em_4.Width = "140"; em_4.OffsetVertical = -2; em_4.ShowEvent = MenuShowEvent.MouseOver; em_4.Align = MenuAlign.Under; em_4.AddItem(new MenuItem("menuItem9", "SubItem 1", "", "", "", "alert('Item 4 - SubItem 1')")); em_4.AddItem(new MenuItem("menuItem10", "SubItem 2", "", "", "", "alert('Item 4 - SubItem 2')")); em_5 = new EasyMenu(); em_5.ID = "Easymenu5"; em_5.AttachTo = "item5"; em_5.StyleFolder = "styles/horizontal7"; em_5.Width = "140"; em_5.OffsetVertical = -2; em_5.ShowEvent = MenuShowEvent.MouseOver; em_5.Align = MenuAlign.Under; em_5.AddItem(new MenuItem("menuItem11", "SubItem 1", "", "", "", "alert('Item 5 - SubItem 1')")); em_5.AddItem(new MenuItem("menuItem12", "SubItem 2", "", "", "", "alert('Item 5 - SubItem 2')")); em_5.AddItem(new MenuItem("menuItem13", "SubItem 3", "", "", "", "alert('Item 5 - SubItem 3')")); em_5.AddItem(new MenuItem("menuItem14", "SubItem 4", "", "", "", "alert('Item 5 - SubItem 4')")); em_5.AddItem(new MenuItem("menuItem15", "SubItem 5", "", "", "", "alert('Item 5 - SubItem 5')")); em_6 = new EasyMenu(); em_6.ID = "Easymenu6"; em_6.AttachTo = "menuItem3"; em_6.StyleFolder = "styles/horizontal7"; em_6.Width = "140"; em_6.ShowEvent = MenuShowEvent.MouseOver; em_6.Align = MenuAlign.Right; em_6.OffsetVertical = 0; em_6.OffsetHorizontal = -4; em_6.AddItem(new MenuItem("menuItem31", "SubItem 1", "", "", "", "alert('Item 1 - SubItem 3 - SubItem 1')")); em_6.AddItem(new MenuItem("menuItem32", "SubItem 2", "", "", "", "alert('Item 1 - SubItem 3 - SubItem 2')")); em_6.AddItem(new MenuItem("menuItem33", "SubItem 3", "", "", "", "alert('Item 1 - SubItem 3 - SubItem 3')")); // add the submenus to the page placeHolder1.Controls.Add(em_1); placeHolder1.Controls.Add(em_2); placeHolder1.Controls.Add(em_4); placeHolder1.Controls.Add(em_5); placeHolder1.Controls.Add(em_6); } }
private void RecursivelyPopulateMenuBrands(EasyMenu parentMenuItem, int rows, int columns) { //check if the product already exists in the cache System.Data.DataSet ds = (System.Data.DataSet)HttpContext.Current.Cache["MenuBrands"]; if (ds == null) { GoOpticCategoryHelper categoryHelper = new GoOpticCategoryHelper(); ds = categoryHelper.GetBrandNavigationItems(ZNodeConfigManager.SiteConfig.PortalID); HttpContext.Current.Cache["MenuBrands"] = ds; } parentMenuItem.Align = MenuAlign.Under; parentMenuItem.Position = MenuPosition.Horizontal; parentMenuItem.ShowEvent = MenuShowEvent.MouseOver; if (columns >= 2) parentMenuItem.RepeatColumns = 2*columns-1; parentMenuItem.Width = (100 * columns).ToString(); parentMenuItem.UseIcons = true; parentMenuItem.ZIndex = 400; parentMenuItem.ExpandStyle = ExpandStyle.Slide; string iconPath = "~/Images/home/"; iconPath = iconPath.Replace("~", ""); parentMenuItem.IconsFolder = iconPath; int alphabetLetters = 0; string alphabet =String.Empty; foreach (DataRow dbRow in ds.Tables[0].Rows) { string brandName = dbRow["Name"].ToString(); string firstLetter = brandName.Substring(0, 1); if (alphabet != firstLetter) { alphabet = firstLetter; alphabetLetters++; } } int BrandsPerCol=(int)Math.Ceiling((double)(ds.Tables[0].Rows.Count+alphabetLetters)/columns); int brandNo = 0; int currentCol = 0; alphabet = String.Empty; OboutInc.EasyMenu_Pro.MenuItem miBrand; foreach (DataRow dbRow in ds.Tables[0].Rows) { string brandName = dbRow["Name"].ToString(); string firstLetter= brandName.Substring(0, 1); string itemBrandName = brandName.Replace(" ",""); if (alphabet != firstLetter) { alphabet = firstLetter; miBrand = new OboutInc.EasyMenu_Pro.MenuItem(alphabet, "<span id=\"alphabet\">" + alphabet.ToUpper() + "</span>", "", "", "", ""); miBrand.Disabled = true; if (currentCol == 0) { parentMenuItem.AddItemAt(brandNo,miBrand); }else{ parentMenuItem.AddItemAt((brandNo+1) *(currentCol+1)-1, miBrand); } brandNo++; if (brandNo+1 == BrandsPerCol) { currentCol++; brandNo = 0; } } string seoURL = " ";// = childRow["SEOURL"].ToString(); // seoURL = ZNodeSEOUrl.MakeURL(categoryId, SEOUrlType.Category, seoURL); miBrand = new OboutInc.EasyMenu_Pro.MenuItem(itemBrandName, "<span >" + brandName + "</span>", "",seoURL, "", "");//id=\"menu_item\" if (currentCol == 0) { parentMenuItem.AddItemAt(brandNo, miBrand); } else { parentMenuItem.AddItemAt((brandNo + 1) * (currentCol + 1) - 1, miBrand); } brandNo++; if (brandNo+1 == BrandsPerCol) { currentCol++; brandNo = 0; } } int sepCount=1; int colSepCount = 1; string sepPath = "<img src=\"~/Images/home/split_brand.jpg\"/>"; sepPath = sepPath.Replace("~", ""); for (int i = 0; i < (columns-1) * BrandsPerCol;i++ ) { parentMenuItem.AddSeparatorAt(sepCount, "sep" + sepCount.ToString(), sepPath); sepCount+=2*columns-1; if ((i + 1)%BrandsPerCol==0) { colSepCount += 2; sepCount = colSepCount; } } }
private void BuildMenu1(OleDbDataReader oReader) { /*** main menu - records with ParentId = 0 ***/ EasyMenu mainEM = null; /*** ***/ /*** list with child menus ***/ Hashtable childMenus = null; while (oReader.Read()) { int parentId = oReader.GetInt32(1); if (parentId == 0) { if (mainEM == null) { mainEM = new EasyMenu(); mainEM.ID = "mainEM"; mainEM.StyleFolder = "styles/horizontal1"; mainEM.Width = "400"; mainEM.ShowEvent = MenuShowEvent.Always; mainEM.Position = MenuPosition.Horizontal; // css classes names for the menu and the item container mainEM.CSSMenu = "ParentMenu"; mainEM.CSSMenuItemContainer = "ParentItemContainer"; // css classes names for MenuItems CSSClasses MenuItemCssClasses = mainEM.CSSClassesCollection[mainEM.CSSClassesCollection.Add(new CSSClasses(typeof(OboutInc.EasyMenu_Pro.MenuItem)))]; MenuItemCssClasses.ComponentSubMenuCellOver="ParentItemSubMenuCellOver"; MenuItemCssClasses.ComponentContentCell="ParentItemContentCell"; MenuItemCssClasses.Component="ParentItem"; MenuItemCssClasses.ComponentSubMenuCell="ParentItemSubMenuCell"; MenuItemCssClasses.ComponentIconCellOver="ParentItemIconCellOver"; MenuItemCssClasses.ComponentIconCell="ParentItemIconCell"; MenuItemCssClasses.ComponentOver="ParentItemOver"; MenuItemCssClasses.ComponentContentCellOver="ParentItemContentCellOver"; // add the classes names to the collection mainEM.CSSClassesCollection.Add(MenuItemCssClasses); // css classes names for MenuSeparators CSSClasses MenuSeparatorCssClasses = mainEM.CSSClassesCollection[mainEM.CSSClassesCollection.Add(new CSSClasses(typeof(MenuSeparator)))]; MenuSeparatorCssClasses.ComponentSubMenuCellOver="ParentSeparatorSubMenuCellOver"; MenuSeparatorCssClasses.ComponentContentCell="ParentSeparatorContentCell"; MenuSeparatorCssClasses.Component="ParentSeparator"; MenuSeparatorCssClasses.ComponentSubMenuCell="ParentSeparatorSubMenuCell"; MenuSeparatorCssClasses.ComponentIconCellOver="ParentSeparatorIconCellOver"; MenuSeparatorCssClasses.ComponentIconCell="ParentSeparatorIconCell"; MenuSeparatorCssClasses.ComponentOver="ParentSeparatorOver"; MenuSeparatorCssClasses.ComponentContentCellOver="ParentSeparatorContentCellOver"; // add the classes names to the collection mainEM.CSSClassesCollection.Add(MenuSeparatorCssClasses); } mainEM.AddItem(new OboutInc.EasyMenu_Pro.MenuItem("item_" + oReader.GetInt32(0).ToString(), oReader.GetString(2), "", "", "", "")); placeHolder1.Controls.Add(mainEM); } else { if (childMenus == null) childMenus = new Hashtable(); /* first time the menu is ceated */ if (!childMenus.ContainsKey(parentId)) { EasyMenu childEM = new EasyMenu(); childEM.ID = "childEM_" + parentId; childEM.StyleFolder = "styles/horizontal1"; childEM.ShowEvent = MenuShowEvent.MouseOver; childEM.AttachTo = "item_" + parentId; childEM.Width = "150"; int menuLevel = oReader.GetInt32(3); if (menuLevel == 1) childEM.Align = MenuAlign.Under; else childEM.Align = MenuAlign.Left; childEM.AddItem(new OboutInc.EasyMenu_Pro.MenuItem("item_" + oReader.GetInt32(0).ToString(), oReader.GetString(2), "", "", "", "")); childMenus.Add(parentId, childEM); placeHolder1.Controls.Add(childEM); } /* items are added to the already created menu */ else { EasyMenu childEM = (EasyMenu)childMenus[parentId]; childEM.AddItem(new OboutInc.EasyMenu_Pro.MenuItem("item_" + oReader.GetInt32(0).ToString(), oReader.GetString(2), "", "", "", "")); } } } }
/* * private void Page_Init(object sender, System.EventArgs e) * { * * BuxFrmKod = (string)Session["BuxFrmKod"]; * BuxSid = (string)Session["BuxSid"]; * * localhost.Service1Soap ws = new localhost.Service1SoapClient(); * DataSet ds = new DataSet("Menu"); * * ds.Merge(ws.ComRedUsrMnu(MdbNam, BuxFrmKod, BuxSid)); * //------------------------------------------------------------------------------------- * string lastMenuId = ""; * string CurMenuId = ""; * EasyMenu oem = null; * // Заполнить EM в цикле * foreach (DataRow row in ds.Tables["ComRedUsrMnu"].Rows) * { * // Initialising a new EM * CurMenuId = row["MnuBarApp"].ToString(); * if (CurMenuId != lastMenuId) * { * oem = new EasyMenu(); * oem.ID = row["MnuBarApp"].ToString(); * // if an attachto property is set, this is not the main menu * // if (row["MnuBarAtt"].ToString() != null) * if (!row["MnuBarAtt"].Equals(System.DBNull.Value)) * { * oem.AttachTo = row["MnuBarAtt"].ToString(); * // we add the menus to the page controls * PlaceHolderMenu.Controls.Add(oem); * } * // otherwise this is the main menu * else * { * // we add the menu to the placeholder (to display it where we need in the page) * PlaceHolderMenu.Controls.Add(oem); * } * Session["EasyMenu_" + oem.ID] = oem; * * lastMenuId = row["MnuBarApp"].ToString(); * } * } * * } */ // --------------------------------------------------------------------------- protected void Page_Load(object sender, EventArgs e) { BuxFrmKod = (string)Session["BuxFrmKod"]; BuxSid = (string)Session["BuxSid"]; // if (!Page.IsPostBack) // { // this.Page.Title = "Лекарства через Интернет"; if (BuxFrmKod == "1") { ImageLog.ImageUrl = "~/Logo/LogoSofi.jpg"; } else { ImageLog.ImageUrl = "~/Logo/LogoDauaBig.jpg"; } // =================== Подобрать ЛОГОТИП ================================================== switch (BuxFrmKod) { case "1": ImageLog.ImageUrl = "~/Logo/LogoSofi.jpg"; break; case "2": ImageLog.ImageUrl = "~/Logo/LogoSofi.jpg"; break; default: ImageLog.ImageUrl = "~/Logo/LogoDauaBig.jpg"; break; } // =================== Подобрать ЛОГОТИП ================================================== // ===================Page_Init================================================== localhost.Service1Soap ws = new localhost.Service1SoapClient(); DataSet ds = new DataSet("Menu"); ds.Merge(ws.ComRedUsrMnu(MdbNam, BuxFrmKod, BuxSid)); //------------------------------------------------------------------------------------- string lastMenuId = ""; string CurMenuId = ""; EasyMenu oem = null; // Заполнить EM в цикле foreach (DataRow row in ds.Tables["ComRedUsrMnu"].Rows) { // Initialising a new EM CurMenuId = row["MnuBarApp"].ToString(); if (CurMenuId != lastMenuId) { oem = new EasyMenu(); oem.ID = row["MnuBarApp"].ToString(); // if an attachto property is set, this is not the main menu // if (row["MnuBarAtt"].ToString() != null) if (!row["MnuBarAtt"].Equals(System.DBNull.Value)) { oem.AttachTo = row["MnuBarAtt"].ToString(); // we add the menus to the page controls PlaceHolderMenu.Controls.Add(oem); } // otherwise this is the main menu else { // we add the menu to the placeholder (to display it where we need in the page) PlaceHolderMenu.Controls.Add(oem); } Session["EasyMenu_" + oem.ID] = oem; lastMenuId = row["MnuBarApp"].ToString(); } } // ========================Page_Init============================================= // ========================================================================================================================================== // if (!Page.IsPostBack) // { ds.Merge(ws.ComRedUsrMnu(MdbNam, BuxFrmKod, BuxSid)); //------------------------------------------------------------------------------------- // Заполнить EM в цикле foreach (DataRow row in ds.Tables["ComRedUsrMnu"].Rows) { // Initialising a new EM CurMenuId = row["MnuBarApp"].ToString(); if (CurMenuId != lastMenuId) { oem = (EasyMenu)Session["EasyMenu_" + CurMenuId]; oem.Position = MenuPosition.Horizontal; oem.Width = "20%"; // oem.IconsFolder = "Icons"; // oem.StyleFolder = oReader.GetString(oReader.GetOrdinal("style")); oem.StyleFolder = "~/Styles/Menu"; // если свойствао AttachTo установлен, это не главное меню if (!row["MnuBarAtt"].Equals(System.DBNull.Value)) // if (row["MnuBarAtt"].ToString() != null) { oem.ShowEvent = MenuShowEvent.MouseClick; //показывает при шелчке правой кнопки // oem.ShowEvent = MenuShowEvent.ContextMenu; // показывает при шелчке правой кнопки // oem.ShowEvent = MenuShowEvent.MouseOver; // показывает при наведении курсора (работает неустоичиво) if (oem.AttachTo != "item01" && oem.AttachTo != "item02" && oem.AttachTo != "item03" && oem.AttachTo != "item04" && oem.AttachTo != "item05" && oem.AttachTo != "item06" && oem.AttachTo != "item07" && oem.AttachTo != "item08" && oem.AttachTo != "item09") { oem.Align = MenuAlign.Right; } else { oem.Align = MenuAlign.Under; } oem.Position = MenuPosition.Vertical; } // иначе это главное меню else { oem.ShowEvent = MenuShowEvent.Always; // oem.ShowEvent = MenuShowEvent.ContextMenu; oem.Width = "100%"; } } // Adding either a Separator or an Item if (row["MnuBarTyp"].ToString() == "S") { oem.AddSeparator(row["ID"].ToString(), (row["HTML"].Equals(System.DBNull.Value)) ? "" : row["HTML"].ToString()); } else if (row["MnuBarTyp"].ToString() == "I") { oem.AddMenuItem(row["MnuBarKod"].ToString(), (row["MnuBarTxt"].Equals(System.DBNull.Value) ? "" : row["MnuBarTxt"].ToString()), (row["MnuBarIcn"].Equals(System.DBNull.Value) ? "" : row["MnuBarIcn"].ToString()), (row["MnuBarUrl"].Equals(System.DBNull.Value) ? "" : row["MnuBarUrl"].ToString()), (row["MnuBarUrlTrg"].Equals(System.DBNull.Value) ? "" : row["MnuBarUrlTrg"].ToString()), (row["MnuBarClk"].Equals(System.DBNull.Value) ? "" : row["MnuBarClk"].ToString())); } lastMenuId = row["MnuBarApp"].ToString(); } // } // ========================================================================================================================================== //System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Open_Window", "EodWindow.Open();", true); }
void Page_Init(object sender, EventArgs e) { // create the Parent EasyMenu mainEM = new EasyMenu(); // set the ID (must be unique) mainEM.ID = "MainEM"; // add the menu to the placeholder on the page placeHolder1.Controls.Add(mainEM); // Create the submenus em_1 = new EasyMenu(); em_1.ID = "Easymenu1"; em_2 = new EasyMenu(); em_2.ID = "Easymenu2"; em_4 = new EasyMenu(); em_4.ID = "Easymenu4"; em_5 = new EasyMenu(); em_5.ID = "Easymenu5"; em_6 = new EasyMenu(); em_6.ID = "Easymenu6"; // add the submenus to the page Page.Controls.Add(em_1); Page.Controls.Add(em_2); Page.Controls.Add(em_4); Page.Controls.Add(em_5); Page.Controls.Add(em_6); }
private void BuildMenu1(OleDbDataReader oReader) { /*** main menu - records with ParentId = 0 ***/ EasyMenu mainEM = null; /*** ***/ /*** list with child menus ***/ Hashtable childMenus = null; while (oReader.Read()) { int parentId = oReader.GetInt32(1); if (parentId == 0) { if (mainEM == null) { mainEM = new EasyMenu(); mainEM.ID = "mainEM"; mainEM.StyleFolder = "styles/horizontal1"; mainEM.Width = "400"; mainEM.ShowEvent = MenuShowEvent.Always; mainEM.Position = MenuPosition.Horizontal; // css classes names for the menu and the item container mainEM.CSSMenu = "ParentMenu"; mainEM.CSSMenuItemContainer = "ParentItemContainer"; // css classes names for MenuItems CSSClasses MenuItemCssClasses = mainEM.CSSClassesCollection[mainEM.CSSClassesCollection.Add(new CSSClasses(typeof(OboutInc.EasyMenu_Pro.MenuItem)))]; MenuItemCssClasses.ComponentSubMenuCellOver = "ParentItemSubMenuCellOver"; MenuItemCssClasses.ComponentContentCell = "ParentItemContentCell"; MenuItemCssClasses.Component = "ParentItem"; MenuItemCssClasses.ComponentSubMenuCell = "ParentItemSubMenuCell"; MenuItemCssClasses.ComponentIconCellOver = "ParentItemIconCellOver"; MenuItemCssClasses.ComponentIconCell = "ParentItemIconCell"; MenuItemCssClasses.ComponentOver = "ParentItemOver"; MenuItemCssClasses.ComponentContentCellOver = "ParentItemContentCellOver"; // add the classes names to the collection mainEM.CSSClassesCollection.Add(MenuItemCssClasses); // css classes names for MenuSeparators CSSClasses MenuSeparatorCssClasses = mainEM.CSSClassesCollection[mainEM.CSSClassesCollection.Add(new CSSClasses(typeof(MenuSeparator)))]; MenuSeparatorCssClasses.ComponentSubMenuCellOver = "ParentSeparatorSubMenuCellOver"; MenuSeparatorCssClasses.ComponentContentCell = "ParentSeparatorContentCell"; MenuSeparatorCssClasses.Component = "ParentSeparator"; MenuSeparatorCssClasses.ComponentSubMenuCell = "ParentSeparatorSubMenuCell"; MenuSeparatorCssClasses.ComponentIconCellOver = "ParentSeparatorIconCellOver"; MenuSeparatorCssClasses.ComponentIconCell = "ParentSeparatorIconCell"; MenuSeparatorCssClasses.ComponentOver = "ParentSeparatorOver"; MenuSeparatorCssClasses.ComponentContentCellOver = "ParentSeparatorContentCellOver"; // add the classes names to the collection mainEM.CSSClassesCollection.Add(MenuSeparatorCssClasses); } mainEM.AddItem(new OboutInc.EasyMenu_Pro.MenuItem("item_" + oReader.GetInt32(0).ToString(), oReader.GetString(2), "", "", "", "")); placeHolder1.Controls.Add(mainEM); } else { if (childMenus == null) { childMenus = new Hashtable(); } /* first time the menu is ceated */ if (!childMenus.ContainsKey(parentId)) { EasyMenu childEM = new EasyMenu(); childEM.ID = "childEM_" + parentId; childEM.StyleFolder = "styles/horizontal1"; childEM.ShowEvent = MenuShowEvent.MouseOver; childEM.AttachTo = "item_" + parentId; childEM.Width = "150"; int menuLevel = oReader.GetInt32(3); if (menuLevel == 1) { childEM.Align = MenuAlign.Under; } else { childEM.Align = MenuAlign.Left; } childEM.AddItem(new OboutInc.EasyMenu_Pro.MenuItem("item_" + oReader.GetInt32(0).ToString(), oReader.GetString(2), "", "", "", "")); childMenus.Add(parentId, childEM); placeHolder1.Controls.Add(childEM); } /* items are added to the already created menu */ else { EasyMenu childEM = (EasyMenu)childMenus[parentId]; childEM.AddItem(new OboutInc.EasyMenu_Pro.MenuItem("item_" + oReader.GetInt32(0).ToString(), oReader.GetString(2), "", "", "", "")); } } } }
private void RecursivelyPopulateMenuSubCategory(DataRow dbRow, EasyMenu parentMenuItem, DataSet ds,int rows,int columns) { string ParentId = dbRow["CategoryId"].ToString(); //if( dbRow["CategoryId"].ToString().ToLower()=="") if (dbRow.GetChildRows("NodeRelation").Length > 0 && columns > 0) { // parentMenuItem.AttachTo = category; // parentMenuItem.Visible = true; parentMenuItem.Align = MenuAlign.Under; parentMenuItem.Position = MenuPosition.Horizontal; parentMenuItem.ShowEvent = MenuShowEvent.MouseOver; parentMenuItem.UseIcons = true; parentMenuItem.OffsetHorizontal = 10; parentMenuItem.ZIndex = 400; parentMenuItem.ExpandStyle = ExpandStyle.Slide; //parentMenuItem.EventList = "OnAfterMenuClose"; //parentMenuItem.ID = "mynewid"; if (columns >= 2) parentMenuItem.RepeatColumns = columns; parentMenuItem.Width = (120 * columns).ToString(); string iconPath = "~/Images/home/"; iconPath = iconPath.Replace("~", ""); parentMenuItem.IconsFolder = iconPath; OboutInc.EasyMenu_Pro.MenuItem miDepart = new OboutInc.EasyMenu_Pro.MenuItem("Departments", "    ", "departments.jpg", "", "", "");//<span id=\"departments\">departments</span> miDepart.Disabled = true; // miDepart.Visible = false; OboutInc.EasyMenu_Pro.MenuItem miSplit = new OboutInc.EasyMenu_Pro.MenuItem("Split", "    ", "split.png", "", "", ""); miSplit.Disabled = true; parentMenuItem.AddItemAt(0, miDepart); parentMenuItem.AddItemAt(1, miSplit); int DepartNo = 0; foreach (DataRow childRow in dbRow.GetChildRows("NodeRelation")) { DepartNo++; if (DepartNo <= rows) { string itemText = childRow["Name"].ToString(); string categoryId = childRow["CategoryId"].ToString(); string seoURL = childRow["SEOURL"].ToString(); seoURL = ZNodeSEOUrl.MakeURL(categoryId, SEOUrlType.Category, seoURL); string categoryText = itemText; categoryText = categoryText.Replace(" ", ""); parentMenuItem.AddMenuItem(categoryText, "<span id=\"menu_item\">" + itemText + "</span>", "arrow.png", seoURL, "", ""); } } if (DepartNo > rows) { string ceva = "Departments"; string callback = "for (i = 0; i < ob_em_mynewid.items.length; i++){alert(ob_em_mynewid.items[i].id)}"; parentMenuItem.AddMenuItem("ViewAll1", "<span id=\"view_all\">View All...</span>", "", "", "", "displaymessage(ob_em_subMenu4," + ceva + ")"); } if (columns > 1) { OboutInc.EasyMenu_Pro.MenuItem miBrand = new OboutInc.EasyMenu_Pro.MenuItem("Brand", "    ", "brands.jpg", "", "", "");//<span id=\"brand\">brands</span> miBrand.Disabled = true; OboutInc.EasyMenu_Pro.MenuItem miSplit2 = new OboutInc.EasyMenu_Pro.MenuItem("Split2", "    ", "split.png", "", "", ""); miSplit2.Disabled = true; parentMenuItem.AddItemAt(1, miBrand); parentMenuItem.AddItemAt(1 + columns, miSplit2); int BrandNo = 0; string newID = ""; foreach (DataRow childRow in ds.Tables[0].Rows) { string itemText = childRow["ManufacturerName"].ToString(); string categoryId = childRow["CategoryId"].ToString(); string seoURL = " ";// = childRow["SEOURL"].ToString(); // seoURL = ZNodeSEOUrl.MakeURL(categoryId, SEOUrlType.Category, seoURL); string categoryText = itemText; categoryText = categoryText.Replace(" ", ""); newID = categoryText+BrandNo.ToString(); //newID = newID.Replace(" ",""); if (categoryId == ParentId && BrandNo + 1 <= rows) { //parentMenuItem.AddMenuItem(categoryText, itemText, "arrow.png", seoURL, "", ""); parentMenuItem.AddMenuItemAt((BrandNo + 1) * 2 - 1, newID, "<span id=\"menu_item\">" + itemText + "</span>", "arrow.png", seoURL, "", ""); BrandNo++; } } if (BrandNo > rows) parentMenuItem.AddMenuItem("ViewAll2", "<b>View All...</b>", "", "", "", ""); } if (columns > 2) { string categoryName=dbRow["Name"].ToString().ToLower(); if (categoryName == "eyeglasses" || categoryName == "sunglasses") { string imagePath = "~/Images/home/"; imagePath = imagePath.Replace("~", ""); string itemText = "<a href=\"ceva\" onmouseover=\"roll_over('" + categoryName + "clip_on" + "', '" + imagePath + "clip_on_over.jpg" + "')\" onmouseout=\"roll_over('" + categoryName + "clip_on" + "', '" + imagePath + "clip_on.jpg" + "')\" ><img border=\"0\" name =\"" + categoryName + "clip_on" + "\" src=\"" + imagePath +"clip_on.jpg"+ "\"/>"; parentMenuItem.AddMenuItemAt(2, categoryName + "clip_on", itemText, "", "", "", ""); itemText = "<a href=\"ceva\" onmouseover=\"roll_over('" + categoryName + "goggles" + "', '" + imagePath + "goggles_over.jpg" + "')\" onmouseout=\"roll_over('" + categoryName + "goggles" + "', '" + imagePath + "goggles.jpg" + "')\" ><img border=\"0\" name =\"" + categoryName + "goggles" + "\" src=\"" + imagePath + "goggles.jpg" + "\"/>"; parentMenuItem.AddMenuItemAt(5, categoryName + "goggles", itemText, "", "", "", ""); itemText = "<a href=\"ceva\" onmouseover=\"roll_over('" + categoryName + "readers" + "', '" + imagePath + "readers_over.jpg" + "')\" onmouseout=\"roll_over('" + categoryName + "readers" + "', '" + imagePath + "readers.jpg" + "')\" ><img border=\"0\" name =\"" + categoryName + "readers" + "\" src=\"" + imagePath + "readers.jpg" + "\"/>"; parentMenuItem.AddMenuItemAt(8, categoryName + "readers", itemText, "", "", "", ""); /*itemText = "<a href=\"ceva\" ><img border=\"0\" name =\"" + categoryName + "build" + "\" src=\"" + imagePath + "build_custom.jpg" + "\"/>"; parentMenuItem.AddMenuItemAt(11, categoryName + "build", itemText, "", "", "", "");*/ itemText = "<a href=\"ceva\" ><img border=\"0\" name =\"" + categoryName + "build1" + "\" src=\"" + imagePath + "build_custom1.jpg" + "\"/>"; parentMenuItem.AddMenuItemAt(11, categoryName + "build1", itemText, "", "", "", ""); itemText = "<a href=\"ceva\" ><img border=\"0\" name =\"" + categoryName + "build2" + "\" src=\"" + imagePath + "build_custom2.jpg" + "\"/>"; parentMenuItem.AddMenuItemAt(14, categoryName + "build2", itemText, "", "", "", ""); itemText = "<a href=\"ceva\" ><img border=\"0\" name =\"" + categoryName + "build3" + "\" src=\"" + imagePath + "build_custom3.jpg" + "\"/>"; parentMenuItem.AddMenuItemAt(17, categoryName + "build3", itemText, "", "", "", ""); } } } }
void bindprofmenu() { try { SqlConnection Cn = new SqlConnection(constsql1); SQL = "SELECT PROFILEMENUITEMS.MENUID, MENUS.ATTACHTO, PROFILEMENUITEMS.ITEMTYPE, PROFILEMENUITEMS.IDS, MENUS.STYLE, MENUS.ID, PROFILEMENUITEMS.HTML, PROFILEMENUITEMS.ICON,PROFILEMENUITEMS.URL, PROFILEMENUITEMS.URLTARGET, PROFILEMENUITEMS.ONCLIENTCLICK FROM PROFILEMENUITEMS INNER JOIN MENUS ON PROFILEMENUITEMS.MENUID = MENUS.ID ORDER BY ID, ATTACHTO, ORDERS"; SqlCommand Com = new SqlCommand(SQL, Cn); Cn.Open(); oReader = Com.ExecuteReader(); string lastMenuId = ""; EasyMenu oem = null; while (oReader.Read()) { if (oReader.GetString(oReader.GetOrdinal("menuID")) != lastMenuId) { oem = new EasyMenu(); oem.ID = oReader.GetString(oReader.GetOrdinal("menuid")); oem.Position = MenuPosition.Horizontal; oem.Width = "60"; oem.UseIcons = true; oem.Align = OboutInc.EasyMenu_Pro.MenuAlign.Under; oem.IconsFolder = "Icons"; oem.CSSMenu = "ParentMenu"; oem.CSSMenuItemContainer = "ParentItemContainer"; CSSClasses MenuItemCssClasses = oem.CSSClassesCollection[oem.CSSClassesCollection.Add(new CSSClasses(typeof(OboutInc.EasyMenu_Pro.MenuItem)))]; MenuItemCssClasses.ComponentSubMenuCellOver = "ParentItemSubMenuCellOver"; MenuItemCssClasses.ComponentContentCell = "ParentItemContentCell"; MenuItemCssClasses.Component = "ParentItem"; MenuItemCssClasses.ComponentSubMenuCell = "ParentItemSubMenuCell"; MenuItemCssClasses.ComponentIconCellOver = "ParentItemIconCellOver"; MenuItemCssClasses.ComponentIconCell = "ParentItemIconCell"; MenuItemCssClasses.ComponentOver = "ParentItemOver"; MenuItemCssClasses.ComponentContentCellOver = "ParentItemContentCellOver"; oem.CSSClassesCollection.Add(MenuItemCssClasses); CSSClasses MenuSeparatorCssClasses = oem.CSSClassesCollection[oem.CSSClassesCollection.Add(new CSSClasses(typeof(MenuSeparator)))]; MenuSeparatorCssClasses.ComponentSubMenuCellOver = "ParentSeparatorSubMenuCellOver"; MenuSeparatorCssClasses.ComponentContentCell = "ParentSeparatorContentCell"; MenuSeparatorCssClasses.Component = "ParentSeparator"; MenuSeparatorCssClasses.ComponentSubMenuCell = "ParentSeparatorSubMenuCell"; MenuSeparatorCssClasses.ComponentIconCellOver = "ParentSeparatorIconCellOver"; MenuSeparatorCssClasses.ComponentIconCell = "ParentSeparatorIconCell"; MenuSeparatorCssClasses.ComponentOver = "ParentSeparatorOver"; MenuSeparatorCssClasses.ComponentContentCellOver = "ParentSeparatorContentCellOver"; oem.CSSClassesCollection.Add(MenuSeparatorCssClasses); oem.StyleFolder = oReader.GetString(oReader.GetOrdinal("style")); if (!oReader.IsDBNull(oReader.GetOrdinal("attachto"))) { oem.AttachTo = oReader.GetString(oReader.GetOrdinal("attachto")); oem.ShowEvent = MenuShowEvent.MouseOver; oem.Align = MenuAlign.Under; oem.UseIcons = true; oem.IconsFolder = "Icons"; placeHolder1.Controls.Add(oem); } else { oem.UseIcons = true; oem.IconsFolder = "Icons"; oem.ShowEvent = MenuShowEvent.Always; oem.Align = MenuAlign.Under; placeHolder1.Controls.Add(oem); } } if (oReader.GetString(oReader.GetOrdinal("ITEMTYPE")) == "S") { oem.AddSeparator(oReader.GetString(oReader.GetOrdinal("b.ID")), oReader.IsDBNull(oReader.GetOrdinal("HTML")) ? "" : oReader.GetString(oReader.GetOrdinal("HTML"))); } else if (oReader.GetString(oReader.GetOrdinal("ITEMTYPE")) == "I") { oem.AddMenuItem(oReader.GetString(oReader.GetOrdinal("IDS")), oReader.IsDBNull(oReader.GetOrdinal("HTML")) ? "" : oReader.GetString(oReader.GetOrdinal("HTML")), oReader.IsDBNull(oReader.GetOrdinal("ICON")) ? "" : oReader.GetString(oReader.GetOrdinal("ICON")), oReader.IsDBNull(oReader.GetOrdinal("URL")) ? "" : oReader.GetString(oReader.GetOrdinal("URL")), oReader.IsDBNull(oReader.GetOrdinal("URLTARGET")) ? "" : oReader.GetString(oReader.GetOrdinal("URLTARGET")), oReader.IsDBNull(oReader.GetOrdinal("ONCLIENTCLICK")) ? "" : oReader.GetString(oReader.GetOrdinal("ONCLIENTCLICK"))); } lastMenuId = oReader.GetString(oReader.GetOrdinal("menuID")); } oReader.Close(); Cn.Close(); } catch (Exception ex) { Utility.insertError(ex.Message); Response.Write("<script>top.location='logout.aspx'</script>"); } }
public Example(IMyGridTerminalSystem grid, IMyProgrammableBlock me, Action <string> echo, TimeSpan elapsedTime) : base(grid, me, echo, elapsedTime) { // Create menu this.menu = new EasyMenu("Explore", new [] { new EasyMenuItem("Actions", delegate(EasyMenuItem actionsItem) { List <string> types = new List <string>(); for (int n = 0; n < Blocks.Count(); n++) { var block = Blocks.GetBlock(n); if (!types.Contains(block.Type())) { types.Add(block.Type()); } } types.Sort(); actionsItem.children.Clear(); for (int n = 0; n < types.Count; n++) { actionsItem.children.Add(new EasyMenuItem(types[n], delegate(EasyMenuItem typeItem) { typeItem.children.Clear(); var blocks = Blocks.OfType(typeItem.Text); for (int o = 0; o < blocks.Count(); o++) { var block = blocks.GetBlock(o); typeItem.children.Add(new EasyMenuItem(block.Name(), delegate(EasyMenuItem blockItem) { blockItem.children.Clear(); var actions = block.GetActions(); for (int p = 0; p < actions.Count; p++) { var action = actions[p]; blockItem.children.Add(new EasyMenuItem(action.Name + "", delegate(EasyMenuItem actionItem) { block.ApplyAction(action.Id); return(false); })); } blockItem.children.Sort(); return(true); })); } typeItem.children.Sort(); return(true); })); } actionsItem.children.Sort(); return(true); }) }); // Get blocks this.screen = Blocks.Named("MenuLCD").FindOrFail("MenuLCD not found!"); this.lcd = new EasyLCD(this.screen); // Handle Arguments On("Up", delegate() { this.menu.Up(); doUpdates(); }); On("Down", delegate() { this.menu.Down(); doUpdates(); }); On("Choose", delegate() { this.menu.Choose(); doUpdates(); }); On("Back", delegate() { this.menu.Back(); doUpdates(); }); On("Update", delegate() { doUpdates(); }); }
// // TODO: Add constructor logic here // public void PopulateStoreMenu2(EasyMenu ctrlMenu, EasyMenu[] ids) { //check if the product already exists in the cache System.Data.DataSet ds = (System.Data.DataSet)HttpContext.Current.Cache["MenuNavigation"]; if (ds == null) { CategoryHelper categoryHelper = new CategoryHelper(); ds = categoryHelper.GetNavigationItems(ZNodeConfigManager.SiteConfig.PortalID); //add the hierarchical relationship to the dataset ds.Relations.Add("NodeRelation", ds.Tables[0].Columns["CategoryId"], ds.Tables[0].Columns["ParentCategoryId"]); HttpContext.Current.Cache["MenuNavigation"] = ds; } System.Data.DataSet dsBrands = (System.Data.DataSet)HttpContext.Current.Cache["SubMenuBrands"]; if (dsBrands == null) { GoOpticCategoryHelper gocategoryHelper = new GoOpticCategoryHelper(); dsBrands = gocategoryHelper.GetBrands(ZNodeConfigManager.SiteConfig.PortalID); //add the hierarchical relationship to the dataset //dsBrands.Relations.Add("NodeRelation", ds.Tables[0].Columns["CategoryId"], ds.Tables[0].Columns["ParentCategoryId"]); HttpContext.Current.Cache["SubMenuBrands"] = dsBrands; } int CategoryNo = 0; foreach (DataRow dbRow in ds.Tables[0].Rows) { if (dbRow.IsNull("ParentCategoryID")) { if ((bool)dbRow["VisibleInd"]) { //create new menu item // string itemText = dbRow["Name"].ToString(); int rows; try { rows = Int32.Parse(dbRow["Rows"].ToString()); } catch (Exception e) { rows = 0; } int columns; try { columns = Int32.Parse(dbRow["Columns"].ToString()); } catch (Exception e) { columns = 0; } string categoryId = dbRow["CategoryId"].ToString(); string seoURL = dbRow["SEOURL"].ToString(); string imageName=dbRow["ImageFile"].ToString(); string imageNameHOver = imageName.Replace(".","HOver."); string imagePath = ZNode.Libraries.Framework.Business.ZNodeConfigManager.EnvironmentConfig.OriginalImagePath +imageName ; imagePath = imagePath.Replace("~",""); string imagePathHOver = ZNode.Libraries.Framework.Business.ZNodeConfigManager.EnvironmentConfig.OriginalImagePath+imageNameHOver; imagePathHOver = imagePathHOver.Replace("~", ""); string categoryText = dbRow["Name"].ToString(); if (categoryText.ToLower() == "home") seoURL = "~/"; else seoURL = ZNodeSEOUrl.MakeURL(categoryId, SEOUrlType.Category, seoURL); imageName = imageName.Remove(imageName.IndexOf("."), imageName.Length - imageName.IndexOf(".")); string itemText = "<a href=\"" + seoURL.Replace("~","") + "\" onmouseover=\"roll_over('" + imageName + "', '" + imagePathHOver + "')\" onmouseout=\"roll_over('" + imageName + "', '" + imagePath + "')\" ><img border=\"0\" name =\"" + imageName + "\" src=\"" + imagePath + "\"/>"; // itemText = itemText.Replace("default", imagePath); categoryText = categoryText.Replace(" ", ""); string sepID = "sep" + categoryText; string sepPath = "<img src=\"~/Images/home/bete.png\"/>"; sepPath = sepPath.Replace("~", ""); if(CategoryNo!=0) ctrlMenu.AddSeparator(sepID, sepPath); OboutInc.EasyMenu_Pro.MenuItem mi = new OboutInc.EasyMenu_Pro.MenuItem(categoryText, itemText, "","", "", ""); ctrlMenu.AddItem(mi); ids[CategoryNo].AttachTo = categoryText; //recursively populate node if (categoryText.ToLower() == "brands") { RecursivelyPopulateMenuBrands(ids[CategoryNo], rows, columns); } else { RecursivelyPopulateMenuSubCategory(dbRow, ids[CategoryNo], dsBrands, rows, columns); // RecursivelyPopulateMenuBrands(ids[CategoryNo], categoryId, dsBrands); } CategoryNo++; } } } }
protected void LeerSubmenu(XmlNode menu, string IDParent, Boolean isTopMenu = false) { string cUrl = ""; string menuTitle = ""; string cDescription = ""; string menuItemID = ""; int nNumCor = 1; EasyMenu menuEM = new EasyMenu(); menuEM.ID = IDParent + "_Items"; menuEM.StyleFolder = "App_Themes/TemaAgrocomercio/EasyMenu/Horizontal1"; menuEM.Width = "140"; menuEM.ShowEvent = MenuShowEvent.MouseOver; menuEM.Align = isTopMenu ? MenuAlign.Under : MenuAlign.Advanced; menuEM.AttachTo = IDParent; foreach (XmlNode Item in menu) { cUrl = Item.Attributes["url"].Value; menuTitle = Item.Attributes["title"].Value; cDescription = Item.Attributes["description"].Value; menuItemID = menuEM.ID + "_" + nNumCor.ToString(); if (menuTitle.Length * 10 > int.Parse(menuEM.Width.Replace("px",""))) menuEM.Width = (menuTitle.Length * 10).ToString(); menuEM.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(menuItemID, menuTitle, "", cUrl, "", "")); if (cUrl == "#") LeerSubmenu(Item, menuItemID); nNumCor++; } Menu_placeHolder.Controls.Add(menuEM); }
private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { // create the Parent EasyMenu mainEM = new EasyMenu(); // set the ID (must be unique) mainEM.ID = "MainEM"; // set the style for this menu mainEM.StyleFolder = "styles/vertical1"; mainEM.Width = "140"; // show event is always so the menu is always visible // this menu doesn't require any AttachTo or Align properties set mainEM.ShowEvent = MenuShowEvent.Always; // display the menu vertically mainEM.Position = MenuPosition.Vertical; // the parent menu looks the same as the child menus so we don't need // to set different CSS classes names for its items or the menu // add the items for the menu mainEM.AddItem(new MenuItem("item1", "Item 1", "", "", "", "")); mainEM.AddItem(new MenuItem("item2", "Item 2", "", "", "", "")); mainEM.AddItem(new MenuItem("item3", "Item 3", "", "", "", "")); mainEM.AddItem(new MenuItem("item4", "Item 4", "", "", "", "")); mainEM.AddItem(new MenuItem("item5", "Item 5", "", "", "", "")); // add the menu to the placeholder on the page placeHolder1.Controls.Add(mainEM); // Create the submenus em_1 = new EasyMenu(); em_1.ID = "Easymenu1"; // this will attach to the first item of the parent menu (id=item1) em_1.AttachTo = "item1"; em_1.StyleFolder = "styles/vertical1"; em_1.Width = "140"; // it will show on mouse over em_1.ShowEvent = MenuShowEvent.MouseOver; // and will align to the right of the item to which it is attached em_1.Align = MenuAlign.Right; // here are this menu's items em_1.AddItem(new MenuItem("menuItem1", "SubItem 1", "", "", "", "alert('Item 1 - SubItem 1')")); em_1.AddItem(new MenuItem("menuItem2", "SubItem 2", "", "", "", "alert('Item 1 - SubItem 2')")); em_1.AddItem(new MenuItem("menuItem3", "SubItem 3", "", "", "", "alert('Item 1 - SubItem 3')")); em_1.AddItem(new MenuItem("menuItem4", "SubItem 4", "", "", "", "alert('Item 1 - SubItem 4')")); em_1.AddItem(new MenuItem("menuItem5", "SubItem 5", "", "", "", "alert('Item 1 - SubItem 5')")); // and so on for every submenu em_2 = new EasyMenu(); em_2.ID = "Easymenu2"; em_2.AttachTo = "item2"; em_2.StyleFolder = "styles/vertical1"; em_2.Width = "140"; em_2.ShowEvent = MenuShowEvent.MouseOver; em_2.Align = MenuAlign.Right; em_2.AddItem(new MenuItem("menuItem6", "SubItem 1", "", "", "", "alert('Item 2 - SubItem 1')")); em_2.AddItem(new MenuItem("menuItem7", "SubItem 2", "", "", "", "alert('Item 2 - SubItem 2')")); em_2.AddItem(new MenuItem("menuItem8", "SubItem 3", "", "", "", "alert('Item 2 - SubItem 3')")); em_4 = new EasyMenu(); em_4.ID = "Easymenu4"; em_4.AttachTo = "item4"; em_4.StyleFolder = "styles/vertical1"; em_4.Width = "140"; em_4.ShowEvent = MenuShowEvent.MouseOver; em_4.Align = MenuAlign.Right; em_4.AddItem(new MenuItem("menuItem9", "SubItem 1", "", "", "", "alert('Item 4 - SubItem 1')")); em_4.AddItem(new MenuItem("menuItem10", "SubItem 2", "", "", "", "alert('Item 4 - SubItem 2')")); em_5 = new EasyMenu(); em_5.ID = "Easymenu5"; em_5.AttachTo = "item5"; em_5.StyleFolder = "styles/vertical1"; em_5.Width = "140"; em_5.ShowEvent = MenuShowEvent.MouseOver; em_5.Align = MenuAlign.Right; em_5.AddItem(new MenuItem("menuItem11", "SubItem 1", "", "", "", "alert('Item 5 - SubItem 1')")); em_5.AddItem(new MenuItem("menuItem12", "SubItem 2", "", "", "", "alert('Item 5 - SubItem 2')")); em_5.AddItem(new MenuItem("menuItem13", "SubItem 3", "", "", "", "alert('Item 5 - SubItem 3')")); em_5.AddItem(new MenuItem("menuItem14", "SubItem 4", "", "", "", "alert('Item 5 - SubItem 4')")); em_5.AddItem(new MenuItem("menuItem15", "SubItem 5", "", "", "", "alert('Item 5 - SubItem 5')")); em_6 = new EasyMenu(); em_6.ID = "Easymenu6"; em_6.AttachTo = "menuItem3"; em_6.StyleFolder = "styles/vertical1"; em_6.Width = "140"; em_6.ShowEvent = MenuShowEvent.MouseOver; em_6.Align = MenuAlign.Right; em_6.OffsetVertical = 0; em_6.OffsetHorizontal = -4; em_6.AddItem(new MenuItem("menuItem31", "SubItem 1", "", "", "", "alert('Item 1 - SubItem 3 - SubItem 1')")); em_6.AddItem(new MenuItem("menuItem32", "SubItem 2", "", "", "", "alert('Item 1 - SubItem 3 - SubItem 2')")); em_6.AddItem(new MenuItem("menuItem33", "SubItem 3", "", "", "", "alert('Item 1 - SubItem 3 - SubItem 3')")); // add the submenus to the page placeHolder1.Controls.Add(em_1); placeHolder1.Controls.Add(em_2); placeHolder1.Controls.Add(em_4); placeHolder1.Controls.Add(em_5); placeHolder1.Controls.Add(em_6); } }
private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { // create the Parent EasyMenu mainEM = new EasyMenu(); // set the ID (must be unique) mainEM.ID = "MainEM"; // set the style for this menu mainEM.StyleFolder = "styles/horizontal2"; mainEM.Width = "330"; // show event is always so the menu is always visible // this menu doesn't require any AttachTo or Align properties set mainEM.ShowEvent = MenuShowEvent.Always; // display the menu horizontally mainEM.Position = MenuPosition.Horizontal; // the parent menu looks different so we need to set different // CSS classes names for its items and the menu itself // css classes names for the menu and the item container mainEM.CSSMenu = "ParentMenu"; mainEM.CSSMenuItemContainer = "ParentItemContainer"; // css classes names for MenuItems CSSClasses MenuItemCssClasses = mainEM.CSSClassesCollection[mainEM.CSSClassesCollection.Add(new CSSClasses(typeof(MenuItem)))]; MenuItemCssClasses.ComponentSubMenuCellOver="ParentItemSubMenuCellOver"; MenuItemCssClasses.ComponentContentCell="ParentItemContentCell"; MenuItemCssClasses.Component="ParentItem"; MenuItemCssClasses.ComponentSubMenuCell="ParentItemSubMenuCell"; MenuItemCssClasses.ComponentIconCellOver="ParentItemIconCellOver"; MenuItemCssClasses.ComponentIconCell="ParentItemIconCell"; MenuItemCssClasses.ComponentOver="ParentItemOver"; MenuItemCssClasses.ComponentContentCellOver="ParentItemContentCellOver"; // add the classes names to the collection mainEM.CSSClassesCollection.Add(MenuItemCssClasses); // css classes names for MenuSeparators CSSClasses MenuSeparatorCssClasses = mainEM.CSSClassesCollection[mainEM.CSSClassesCollection.Add(new CSSClasses(typeof(MenuSeparator)))]; MenuSeparatorCssClasses.ComponentSubMenuCellOver="ParentSeparatorSubMenuCellOver"; MenuSeparatorCssClasses.ComponentContentCell="ParentSeparatorContentCell"; MenuSeparatorCssClasses.Component="ParentSeparator"; MenuSeparatorCssClasses.ComponentSubMenuCell="ParentSeparatorSubMenuCell"; MenuSeparatorCssClasses.ComponentIconCellOver="ParentSeparatorIconCellOver"; MenuSeparatorCssClasses.ComponentIconCell="ParentSeparatorIconCell"; MenuSeparatorCssClasses.ComponentOver="ParentSeparatorOver"; MenuSeparatorCssClasses.ComponentContentCellOver="ParentSeparatorContentCellOver"; // add the classes names to the collection mainEM.CSSClassesCollection.Add(MenuSeparatorCssClasses); // add the items for the menu mainEM.AddItem(new MenuItem("item1", "Item 1", "", "", "", "")); mainEM.AddItem(new MenuItem("item2", "Item 2", "", "", "", "")); mainEM.AddItem(new MenuItem("item3", "Item 3", "", "", "", "")); mainEM.AddItem(new MenuItem("item4", "Item 4", "", "", "", "")); mainEM.AddItem(new MenuItem("item5", "Item 5", "", "", "", "")); // add the menu to the placeholder on the page placeHolder1.Controls.Add(mainEM); // Create the submenus em_1 = new EasyMenu(); em_1.ID = "Easymenu1"; // this will attach to the first item of the parent menu (id=item1) em_1.AttachTo = "item1"; em_1.StyleFolder = "styles/horizontal2"; em_1.Width = "140"; // it will show on mouse over em_1.ShowEvent = MenuShowEvent.MouseOver; // and will align under the item to which it is attached em_1.Align = MenuAlign.Under; // here are this menu's items em_1.AddItem(new MenuItem("menuItem1", "SubItem 1", "", "", "", "alert('Item 1 - SubItem 1')")); em_1.AddItem(new MenuItem("menuItem2", "SubItem 2", "", "", "", "alert('Item 1 - SubItem 2')")); em_1.AddItem(new MenuItem("menuItem3", "SubItem 3", "", "", "", "alert('Item 1 - SubItem 3')")); em_1.AddItem(new MenuItem("menuItem4", "SubItem 4", "", "", "", "alert('Item 1 - SubItem 4')")); em_1.AddItem(new MenuItem("menuItem5", "SubItem 5", "", "", "", "alert('Item 1 - SubItem 5')")); // and so on for every submenu em_2 = new EasyMenu(); em_2.ID = "Easymenu2"; em_2.AttachTo = "item2"; em_2.StyleFolder = "styles/horizontal2"; em_2.Width = "140"; em_2.ShowEvent = MenuShowEvent.MouseOver; em_2.Align = MenuAlign.Under; em_2.AddItem(new MenuItem("menuItem6", "SubItem 1", "", "", "", "alert('Item 2 - SubItem 1')")); em_2.AddItem(new MenuItem("menuItem7", "SubItem 2", "", "", "", "alert('Item 2 - SubItem 2')")); em_2.AddItem(new MenuItem("menuItem8", "SubItem 3", "", "", "", "alert('Item 2 - SubItem 3')")); em_4 = new EasyMenu(); em_4.ID = "Easymenu4"; em_4.AttachTo = "item4"; em_4.StyleFolder = "styles/horizontal2"; em_4.Width = "140"; em_4.ShowEvent = MenuShowEvent.MouseOver; em_4.Align = MenuAlign.Under; em_4.AddItem(new MenuItem("menuItem9", "SubItem 1", "", "", "", "alert('Item 4 - SubItem 1')")); em_4.AddItem(new MenuItem("menuItem10", "SubItem 2", "", "", "", "alert('Item 4 - SubItem 2')")); em_5 = new EasyMenu(); em_5.ID = "Easymenu5"; em_5.AttachTo = "item5"; em_5.StyleFolder = "styles/horizontal2"; em_5.Width = "140"; em_5.ShowEvent = MenuShowEvent.MouseOver; em_5.Align = MenuAlign.Under; em_5.AddItem(new MenuItem("menuItem11", "SubItem 1", "", "", "", "alert('Item 5 - SubItem 1')")); em_5.AddItem(new MenuItem("menuItem12", "SubItem 2", "", "", "", "alert('Item 5 - SubItem 2')")); em_5.AddItem(new MenuItem("menuItem13", "SubItem 3", "", "", "", "alert('Item 5 - SubItem 3')")); em_5.AddItem(new MenuItem("menuItem14", "SubItem 4", "", "", "", "alert('Item 5 - SubItem 4')")); em_5.AddItem(new MenuItem("menuItem15", "SubItem 5", "", "", "", "alert('Item 5 - SubItem 5')")); em_6 = new EasyMenu(); em_6.ID = "Easymenu6"; em_6.AttachTo = "menuItem3"; em_6.StyleFolder = "styles/horizontal2"; em_6.Width = "140"; em_6.ShowEvent = MenuShowEvent.MouseOver; em_6.Align = MenuAlign.Right; em_6.OffsetVertical = 0; em_6.OffsetHorizontal = -4; em_6.AddItem(new MenuItem("menuItem31", "SubItem 1", "", "", "", "alert('Item 1 - SubItem 3 - SubItem 1')")); em_6.AddItem(new MenuItem("menuItem32", "SubItem 2", "", "", "", "alert('Item 1 - SubItem 3 - SubItem 2')")); em_6.AddItem(new MenuItem("menuItem33", "SubItem 3", "", "", "", "alert('Item 1 - SubItem 3 - SubItem 3')")); // add the submenus to the page placeHolder1.Controls.Add(em_1); placeHolder1.Controls.Add(em_2); placeHolder1.Controls.Add(em_4); placeHolder1.Controls.Add(em_5); placeHolder1.Controls.Add(em_6); } }
private void BuildMenu2(OleDbDataReader oReader) { /*** main menu - records with ParentId = 0 ***/ EasyMenu mainEM = null; /*** ***/ /*** list with child menus ***/ Hashtable childMenus = null; while (oReader.Read()) { int parentId = oReader.GetInt32(1); if (parentId == 0) { if (mainEM == null) { mainEM = new EasyMenu(); mainEM.ID = "VmainEM"; mainEM.StyleFolder = "styles/horizontal1"; mainEM.Width = "400"; mainEM.ShowEvent = MenuShowEvent.Always; mainEM.Position = MenuPosition.Horizontal; } mainEM.AddItem(new OboutInc.EasyMenu_Pro.MenuItem("Vitem_" + oReader.GetInt32(0).ToString(), oReader.GetString(2), "", "", "", "")); placeHolder2.Controls.Add(mainEM); } else { if (childMenus == null) { childMenus = new Hashtable(); } /* first time the menu is ceated */ if (!childMenus.ContainsKey(parentId)) { EasyMenu childEM = new EasyMenu(); childEM.ID = "VchildEM_" + parentId; childEM.StyleFolder = "styles/horizontal1"; childEM.ShowEvent = MenuShowEvent.MouseOver; childEM.AttachTo = "Vitem_" + parentId; childEM.Width = "150"; int menuLevel = oReader.GetInt32(3); if (menuLevel == 1) { childEM.Align = MenuAlign.Under; } else { childEM.Align = MenuAlign.Left; } childEM.AddItem(new OboutInc.EasyMenu_Pro.MenuItem("Vitem_" + oReader.GetInt32(0).ToString(), oReader.GetString(2), "", "", "", "")); childMenus.Add(parentId, childEM); placeHolder1.Controls.Add(childEM); } /* items are added to the already created menu */ else { EasyMenu childEM = (EasyMenu)childMenus[parentId]; childEM.AddItem(new OboutInc.EasyMenu_Pro.MenuItem("Vitem_" + oReader.GetInt32(0).ToString(), oReader.GetString(2), "", "", "", "")); } } } }
protected void dgProducts_ItemCreated(object sender, DataGridItemEventArgs e) { if (e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Footer) { PlaceHolder PlaceHolder1 = (PlaceHolder)e.Item.FindControl("PlaceHolder1"); EasyMenu EasyMenu1 = new EasyMenu(); EasyMenu1.ID = "EasyMenu1_" + e.Item.ItemIndex.ToString(); EasyMenu1.ShowEvent = MenuShowEvent.Always; EasyMenu1.Position = MenuPosition.Horizontal; EasyMenu1.StyleFolder = "styles/horizontal1"; EasyMenu1.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu1.ID + "_item1", "Buy for...", "", "", "", "")); EasyMenu1.AddItem(new OboutInc.EasyMenu_Pro.MenuSeparator(EasyMenu1.ID + "_separator1", "|")); EasyMenu1.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu1.ID + "_item2", "Rent for...", "", "", "", "")); EasyMenu1.Width = "100%"; EasyMenu EasyMenu2 = new EasyMenu(); EasyMenu2.ID = "EasyMenu2_" + e.Item.ItemIndex.ToString(); EasyMenu2.ShowEvent = MenuShowEvent.MouseOver; EasyMenu2.Position = MenuPosition.Vertical; EasyMenu2.StyleFolder = "styles/horizontal1"; EasyMenu2.AttachTo = EasyMenu1.ID + "_item1"; EasyMenu2.Align = MenuAlign.Right; switch (e.Item.ItemIndex) { case 0: EasyMenu2.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu2.ID + "_item1", "49.99$ for a piece", "", "", "", "")); EasyMenu2.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu2.ID + "_item2", "89.99$ for two pieces", "", "", "", "")); break; case 1: EasyMenu2.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu2.ID + "_item1", "29.99$ for a piece", "", "", "", "")); EasyMenu2.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu2.ID + "_item2", "54.99$ for two pieces", "", "", "", "")); EasyMenu2.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu2.ID + "_item3", "99.99$ for four pieces", "", "", "", "")); break; } EasyMenu EasyMenu3 = new EasyMenu(); EasyMenu3.ID = "EasyMenu3_" + e.Item.ItemIndex.ToString(); EasyMenu3.ShowEvent = MenuShowEvent.MouseOver; EasyMenu3.Position = MenuPosition.Vertical; EasyMenu3.StyleFolder = "styles/horizontal1"; EasyMenu3.AttachTo = EasyMenu1.ID + "_item2"; EasyMenu3.Align = MenuAlign.Right; switch (e.Item.ItemIndex) { case 0: EasyMenu3.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu3.ID + "_item1", "2.99$ for a day", "", "", "", "")); EasyMenu3.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu3.ID + "_item2", "4.99$ for two days", "", "", "", "")); EasyMenu3.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu3.ID + "_item3", "9.99$ for a week", "", "", "", "")); break; case 1: EasyMenu3.AddItem(new OboutInc.EasyMenu_Pro.MenuItem(EasyMenu3.ID + "_item1", "Not Available", "", "", "", "")); break; } PlaceHolder1.Controls.Add(EasyMenu1); PlaceHolder1.Controls.Add(EasyMenu2); PlaceHolder1.Controls.Add(EasyMenu3); } }
private void Page_Load(object sender, System.EventArgs e) { string sConnectionString; OleDbDataReader oReader; // The database has 2 tables, Menus for the principal menus and MenuItems for the items // Each Menu has an ID, and each item of that menu must have the same MENUID so they can be related // The Menu that has no ATTACHTO property set in the database is the main menu (parent) // and is the one that has ShowEvent set to Always. This has to be the first menu to add on the page // hence we order by ATTACHTO field first. sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("../App_Data/DBDEMO_vertical.mdb"); OleDbConnection Cn = new OleDbConnection(sConnectionString); string SQL = "SELECT * FROM Menus a Inner Join MenuItems b ON (a.ID = b.MENUID) ORDER BY a.ATTACHTO, a.ID, b.ORDER"; OleDbCommand Com = new OleDbCommand(SQL,Cn); Cn.Open(); oReader = Com.ExecuteReader(); string lastMenuId = ""; EasyMenu oem = null; // Populate EM in one loop. while (oReader.Read()) { // Initialising a new EM if (oReader.GetString(oReader.GetOrdinal("menuID")) != lastMenuId) { oem = new EasyMenu(); oem.ID = oReader.GetString(oReader.GetOrdinal("menuid")); oem.Position = MenuPosition.Vertical; oem.Width = "140"; oem.IconsFolder = "Icons"; oem.StyleFolder = oReader.GetString(oReader.GetOrdinal("style")); // if an attachto property is set, this is not the main menu if (!oReader.IsDBNull(oReader.GetOrdinal("attachto"))) { oem.AttachTo = oReader.GetString(oReader.GetOrdinal("attachto")); oem.ShowEvent = MenuShowEvent.MouseOver; oem.Align = MenuAlign.Right; // we add the menus to the page controls placeHolder1.Controls.Add(oem); } // otherwise this is the main menu else { oem.ShowEvent = MenuShowEvent.Always; // we add the menu to the placeholder (to display it where we need in the page) placeHolder1.Controls.Add(oem); } } // Adding either a Separator or an Item if (oReader.GetString(oReader.GetOrdinal("ITEMTYPE")) == "S") oem.AddSeparator(oReader.GetString(oReader.GetOrdinal("b.ID")), oReader.IsDBNull(oReader.GetOrdinal("HTML")) ? "" : oReader.GetString(oReader.GetOrdinal("HTML"))); else if (oReader.GetString(oReader.GetOrdinal("ITEMTYPE")) == "I") oem.AddMenuItem(oReader.GetString(oReader.GetOrdinal("b.ID")), oReader.IsDBNull(oReader.GetOrdinal("HTML")) ? "" : oReader.GetString(oReader.GetOrdinal("HTML")), oReader.IsDBNull(oReader.GetOrdinal("ICON")) ? "" : oReader.GetString(oReader.GetOrdinal("ICON")), oReader.IsDBNull(oReader.GetOrdinal("URL")) ? "" : oReader.GetString(oReader.GetOrdinal("URL")), oReader.IsDBNull(oReader.GetOrdinal("URLTARGET")) ? "" : oReader.GetString(oReader.GetOrdinal("URLTARGET")), oReader.IsDBNull(oReader.GetOrdinal("ONCLIENTCLICK")) ? "" : oReader.GetString(oReader.GetOrdinal("ONCLIENTCLICK"))); lastMenuId = oReader.GetString(oReader.GetOrdinal("menuID")); } oReader.Close(); Cn.Close(); }