Esempio n. 1
0
 internal void SetActiveLevel(SlidingMenuLevel level)
 {
     ActiveLevel = level == null ? null : level.ID;
     _bread.Controls.Clear();
     UpdateBreadCrumb(level);
     _bread.ReRender();
 }
Esempio n. 2
0
 internal void SetAllChildrenNonVisible(ASP.Control from)
 {
     foreach (ASP.Control idx in from.Controls)
     {
         SlidingMenuLevel lev = idx as SlidingMenuLevel;
         if (lev != null)
         {
             if (lev.Style[Styles.display] != "none")
             {
                 lev.Style["display"] = "none";
             }
         }
         SetAllChildrenNonVisible(idx);
     }
 }
Esempio n. 3
0
        internal SlidingMenuLevel FindChildLevel()
        {
            // Finding child SliderMenuLevel control
            SlidingMenuLevel child = null;

            foreach (ASP.Control idx in Controls)
            {
                if (idx is SlidingMenuLevel)
                {
                    child = idx as SlidingMenuLevel;
                    break;
                }
            }
            return(child);
        }
Esempio n. 4
0
        private void SlideBackwards(LinkButton sender, bool allTheWay)
        {
            string           idOfToBecomeActive = sender.ID.Substring(3);
            SlidingMenuLevel previousActive     = AjaxManager.Instance.FindControl <SlidingMenuLevel>(ActiveLevel);
            SlidingMenuLevel level = AjaxManager.Instance.FindControl <SlidingMenuLevel>(idOfToBecomeActive);
            int noLevels           = 0;

            ASP.Control idxLevel = previousActive.Parent;
            while (true)
            {
                if (idxLevel is SlidingMenuLevel)
                {
                    noLevels += 1;
                }
                if (idxLevel == level)
                {
                    break;
                }
                if (idxLevel is SlidingMenuLevel)
                {
                    (idxLevel as SlidingMenuLevel).SetForReRendering();
                }
                idxLevel = idxLevel.Parent;
            }
            SetActiveLevel(level);

            // Animating Menu levels...
            ASP.Control rootLevel = null;
            foreach (ASP.Control idx in Controls)
            {
                if (!(idx is SlidingMenuLevel))
                {
                    continue;
                }
                rootLevel = idx;
                break;
            }
            _bread.Style["display"] = "gokk"; // To force a new value to the display property...
            _bread.Style["display"] = "none";
            new SlidingMenuItem.EffectRollOut(
                rootLevel,
                _bread,
                AnimationDuration,
                true,
                noLevels,
                allTheWay)
            .Render();
        }
Esempio n. 5
0
        internal void ExpandChildren()
        {
            SlidingMenuLevel child = FindChildLevel();

            if (child != null)
            {
                child.Style["display"] = "";
                Root.SetActiveLevel(child);
            }

            if (!this.IsLeaf)
            {
                if (child.EnsureChildNodes())
                {
                    child.ReRender();
                }
                Root.SetAllChildrenNonVisible(Root);
                ASP.Control idxFromThis = child;
                while (idxFromThis != null && !(idxFromThis is SlidingMenu))
                {
                    if (idxFromThis is SlidingMenuLevel)
                    {
                        (idxFromThis as SlidingMenuLevel).Style["display"] = "";
                    }
                    idxFromThis = idxFromThis.Parent;
                }

                // Animating Menu levels...
                ASP.Control rootLevel = null;
                foreach (ASP.Control idx in Root.Controls)
                {
                    if (idx is SlidingMenuLevel)
                    {
                        rootLevel = idx;
                        break;
                    }
                }
                Root.BreadCrumb.Style["display"] = "gokk"; // To force a new value to the display property...
                Root.BreadCrumb.Style["display"] = "none";
                new EffectRollOut(rootLevel,
                                  Root.BreadCrumb,
                                  Root.AnimationDuration)
                .Render();
            }
        }
Esempio n. 6
0
        private void UpdateBreadCrumb(SlidingMenuLevel to)
        {
            ASP.Control idx   = to;
            bool        first = true;

            while (true)
            {
                if (idx == null || idx is SlidingMenu)
                {
                    break; // Finished
                }
                else if (idx is SlidingMenuItem)
                {
                    RaWebControl btn = null;
                    if (first)
                    {
                        btn          = new Label();
                        btn.CssClass = "bread-item-left bread-item-last";
                        first        = false;
                    }
                    else
                    {
                        btn          = new LinkButton();
                        btn.CssClass = "bread-item-left";
                        btn.Click   += btn_Click;
                    }
                    SlidingMenuLevel curLevel = null;
                    foreach (ASP.Control idx2 in idx.Controls)
                    {
                        if (idx2 is SlidingMenuLevel)
                        {
                            btn.ID   = "rxB" + idx2.ID;
                            curLevel = idx2 as SlidingMenuLevel;
                        }
                    }

                    Label right = new Label();
                    right.ID       = btn.ID + "rxq";
                    right.CssClass = "bread-item-right";
                    btn.Controls.Add(right);

                    Label center = new Label();
                    center.ID       = btn.ID + "cxq";
                    center.CssClass = "bread-item-center";
                    center.Text     =
                        string.IsNullOrEmpty(curLevel.Caption) ?
                        (idx as SlidingMenuItem).Text :
                        curLevel.Caption;
                    right.Controls.Add(center);

                    _bread.Controls.AddAt(0, btn);
                }
                idx = idx.Parent;
            }
            // Creating home bread-crumb button
            RaWebControl home = null;

            if (to == null)
            {
                home = new Label();
            }
            else
            {
                home        = new LinkButton();
                home.Click += btnHome_Click;
            }
            home.ID       = "BTNbreadGoHome";
            home.CssClass = "bread-item-left bread-item-first";

            Label right2 = new Label();

            right2.ID       = home.ID + "r";
            right2.CssClass = "bread-item-right";
            home.Controls.Add(right2);

            Label center2 = new Label();

            center2.ID       = home.ID + "c";
            center2.CssClass = "bread-item-center";
            center2.Text     = "&nbsp;";
            right2.Controls.Add(center2);

            Label centerContent = new Label();

            centerContent.ID       = home.ID + "cc";
            centerContent.CssClass = "sliding-bread-home";
            centerContent.Text     = "&nbsp;";
            center2.Controls.Add(centerContent);

            _bread.Controls.AddAt(0, home);
        }
Esempio n. 7
0
        private void OpenMenuItem(SlidingMenuItem item, List <string> ids, int totalLevels, bool animate)
        {
            // Making sure item has loaded its children
            SlidingMenuLevel childLevel = item.FindChildLevel();

            if (childLevel == null)
            {
                // No more items underneath...
                childLevel   = item.Parent as SlidingMenuLevel;
                totalLevels -= (ids.Count + 1);
                ids.Clear();
            }
            else
            {
                if (childLevel.EnsureChildNodes())
                {
                    childLevel.ReRender();
                }
            }

            // Checking to see if we're finished
            if (ids.Count == 0)
            {
                // Wrapping up...
                SetAllChildrenNonVisible(this);
                ASP.Control idxFromThis = childLevel;
                while (idxFromThis != null && !(idxFromThis is SlidingMenu))
                {
                    if (idxFromThis is SlidingMenuLevel)
                    {
                        (idxFromThis as SlidingMenuLevel).Style["display"] = "";
                    }
                    idxFromThis = idxFromThis.Parent;
                }
                // Animating Menu levels...
                ASP.Control rootLevel = null;
                foreach (ASP.Control idx in Controls)
                {
                    if (idx is SlidingMenuLevel)
                    {
                        rootLevel = idx;
                        break;
                    }
                }
                BreadCrumb.Style["display"] = "gokk"; // To force a new value to the display property...
                if (animate)
                {
                    BreadCrumb.Style["display"] = "none";
                }
                if (ActiveLevel == null)
                {
                    if (!animate)
                    {
                        ((SlidingMenuLevel)rootLevel).Style[Styles.marginLeft] =
                            "-" + (100 * totalLevels) + "%";
                    }
                    else
                    {
                        new SlidingMenuItem.EffectRollOut(rootLevel,
                                                          BreadCrumb,
                                                          AnimationDuration,
                                                          false,
                                                          totalLevels)
                        .Render();
                    }
                }
                else
                {
                    if (!animate)
                    {
                        ((SlidingMenuLevel)rootLevel).Style[Styles.marginLeft] =
                            "-" + (100 * totalLevels) + "%";
                    }
                    else
                    {
                        new SlidingMenuItem.EffectRollOut(rootLevel,
                                                          BreadCrumb,
                                                          AnimationDuration,
                                                          true,
                                                          -1,
                                                          true)
                        .ChainThese(
                            new SlidingMenuItem.EffectRollOut(rootLevel,
                                                              BreadCrumb,
                                                              AnimationDuration,
                                                              false,
                                                              totalLevels))
                        .Render();
                    }
                }
                childLevel.Style["display"] = "";
                SetActiveLevel(childLevel);
            }
            else
            {
                SlidingMenuItem itemNext = Selector.Selector.FindControl <SlidingMenuItem>(childLevel, ids[0]);
                ids.RemoveAt(0);
                OpenMenuItem(itemNext, ids, totalLevels, animate);
            }
        }