コード例 #1
0
        protected void window_GetChildNodes(object sender, EventArgs e)
        {
            SlidingMenuLevel level = sender as SlidingMenuLevel;
            for (int idx = 0; idx < 5; idx++)
            {
                SlidingMenuItem i = new SlidingMenuItem();
                i.ID = level.ID + idx;
                i.Text = "Window " + idx;
                level.Controls.Add(i);

                SlidingMenuLevel l = new SlidingMenuLevel();
                l.Caption = "Window " + idx;
                l.ID = level.ID + "LL" + idx;
                l.GetChildNodes += window_GetChildNodes;
                i.Controls.Add(l);
            }
        }
コード例 #2
0
        private void CreateSingleMenuItem(
            Node node,
            Control parent)
        {
            if (node.Name == "Params")
                return;
            SlidingMenuItem item = new SlidingMenuItem {ID = "node" + node.DNA.Replace("-", "x")};

            if (Settings.Instance["UseFlatMenu"] == "True")
            {
                item.CssClass = "sliding-item menuFlat";
            }

            if (node.Get<string>().IndexOf("url:") == 0)
            {
                item.NoClick = true;
                HtmlGenericControl btn = new HtmlGenericControl("span");
                btn.Attributes.Add("class", Settings.Instance["UseFlatMenu"] == "True" ?
                    "buttonFlat menuBtn" :
                    "button menuBtn");

                HtmlGenericControl right = new HtmlGenericControl("span");
                right.Attributes.Add("class", "bRight");
                btn.Controls.Add(right);

                HtmlGenericControl left = new HtmlGenericControl("span");
                left.Attributes.Add("class", "bLeft");
                right.Controls.Add(left);

                HtmlGenericControl center = new HtmlGenericControl("span");
                center.Attributes.Add("class", "bCenter");
                left.Controls.Add(center);

                HtmlGenericControl cont = new HtmlGenericControl("span");
                center.Controls.Add(cont);

                HtmlAnchor a = new HtmlAnchor
                {
                    HRef = node.Get<string>().Replace("url:~/", ApplicationRoot.Root),
                    InnerHtml = Language.Instance[node.Name]
                };
                a.Attributes.Add("class", "menuLink");
                center.Controls.Add(a);

                item.Content.Controls.Add(btn);
                item.CssClass += " linkButton";

                if (node.Count > 0)
                {
                    SlidingMenuLevel l = new SlidingMenuLevel
                    {
                        Caption = a.InnerHtml,
                        ID = "ch" + node.DNA.Replace("-", "x")
                    };
                    item.Controls.Add(l);
                    foreach (Node idx in node)
                    {
                        CreateSingleMenuItem(idx, l);
                    }
                }
            }
            else
            {
                // Creating a button inside to make the menu appear more beautiful...
                ExtButton btn = new ExtButton {ID = "b" + item.ID};
                string btnText = Language.Instance[node.Name];
                btn.Text = btnText;
                btn.CssClass = Settings.Instance["UseFlatMenu"] == "True" ? 
                    "buttonFlat menuBtn" : 
                    "button menuBtn";
                item.Content.Controls.Add(btn);

                bool hasTrigger = false;

                if (node.Count > 0)
                {
                    // Checking to see if the only child node is the "params node"...
                    if (!(node.Count == 1 && node["Params"].Value != null))
                    {
                        SlidingMenuLevel l = new SlidingMenuLevel
                        {
                            Caption = btnText,
                            ID = "ch" + node.DNA.Replace("-", "x")
                        };
                        item.Controls.Add(l);
                        l.Xtra = node.DNA;
                        item.Xtra = node.DNA;
                        foreach (Node idx in node)
                        {
                            CreateSingleMenuItem(idx, l);
                        }
                    }
                    else
                        hasTrigger = true;
                }
                else
                {
                    hasTrigger = true;
                }
                if (hasTrigger)
                {
                    if (node["Params"].Value != null)
                    {
                        item.Xtra = "trigger" +
                            node.Value +
                            "-__params" +
                            node["Params"].Value;
                    }
                    else
                    {
                        item.Xtra = "trigger" + node.Value;
                    }
                }
                
            }
            parent.Controls.Add(item);
        }