public BuildMenuWithInterfaces(string i_Name)
        {
            //Initialize main menu
            this.m_MainMenu = new MainMenu(i_Name);

            //Initialize first sub menu and sub items
            EdgeMenuItem   countCapitals      = new EdgeMenuItem("Count Capitals", new CountCaps());
            EdgeMenuItem   showVersion        = new EdgeMenuItem("Show Version", new PrintVersion());
            ParentMenuItem versionAndCapitals = new ParentMenuItem("Version And Capitals", this.m_MainMenu);

            //Build first sub menu
            versionAndCapitals.Menu.AddItem(countCapitals);
            versionAndCapitals.Menu.AddItem(showVersion);
            m_MainMenu.AddItem(versionAndCapitals);

            //Initialize second sub menu and sub items
            EdgeMenuItem   showTime       = new EdgeMenuItem("Show Time", new PrintTime());
            EdgeMenuItem   showDate       = new EdgeMenuItem("Show Date", new PrintDate());
            ParentMenuItem showDateOrTime = new ParentMenuItem("Show Date/Time", this.m_MainMenu);

            //Build second sub menu
            showDateOrTime.Menu.AddItem(showTime);
            showDateOrTime.Menu.AddItem(showDate);
            this.m_MainMenu.AddItem(showDateOrTime);
        }
Exemple #2
0
        /// <summary>
        /// Binds the drop down list.
        /// </summary>
        protected void BindDropDownList()
        {
            if (IsNew)
            {
                using (IDataReader items = mc.MenuItem.LoadByMenuId(MenuId, LanguageId))
                {
                    ParentMenuItem.Items.Clear();
                    while (items.Read())
                    {
                        ListItem newItem = new ListItem(Offset((int)items["OutlineLevel"]) + items["Text"].ToString(), items["MenuItemId"].ToString());
                        ParentMenuItem.Items.Insert(ParentMenuItem.Items.Count, newItem);
                    }
                    items.Close();
                }
                using (IDataReader root = Mediachase.Cms.MenuItem.LoadMenuRoot(MenuId))
                {
                    if (root.Read())
                    {
                        ListItem newItem = new ListItem(root["Text"].ToString(), root["MenuItemId"].ToString());
                        ParentMenuItem.Items.Insert(0, newItem);
                    }
                    root.Close();
                }


                //ParentMenuItem.SelectedValue = MenuItemId.ToString();
                ManagementHelper.SelectListItem(ParentMenuItem, MenuItemId);
                ParentMenuItem.DataBind();
            }
            else
            {
                //gets all childs and current node
                ArrayList child = new ArrayList();
                child.Add(MenuItemId);
                using (IDataReader items = mc.MenuItem.LoadAllChild(MenuItemId))
                {
                    while (items.Read())
                    {
                        child.Add((int)items["MenuItemId"]);
                    }

                    items.Close();
                }

                using (IDataReader items = mc.MenuItem.LoadByMenuId(MenuId, LanguageId))
                {
                    ParentMenuItem.Items.Clear();
                    while (items.Read())
                    {
                        if (!child.Contains((int)items["MenuItemId"]))
                        {
                            ListItem newItem = new ListItem(Offset((int)items["OutlineLevel"]) + items["Text"].ToString(), items["MenuItemId"].ToString());
                            ParentMenuItem.Items.Insert(ParentMenuItem.Items.Count, newItem);
                        }
                    }
                    items.Close();
                }
                using (IDataReader root = Mediachase.Cms.MenuItem.LoadMenuRoot(MenuId))
                {
                    if (root.Read())
                    {
                        ListItem newItem = new ListItem(root["Text"].ToString(), root["MenuItemId"].ToString());
                        ParentMenuItem.Items.Insert(0, newItem);
                    }
                    root.Close();
                }

                if (ParentId != -1)
                {
                    ParentMenuItem.SelectedValue = ParentId.ToString();
                }


                ParentMenuItem.DataBind();
            }
        }