Exemple #1
0
        private Boolean CheckVisibleMenus(List <Menuitem> toMenuitems, List <Int32> toAvailableMenuIds)
        {
            Boolean lbVisible = false;

            for (int lnIndex = 0; lnIndex < toMenuitems.Count; lnIndex++)
            {
                Menuitem loItem = (Menuitem)toMenuitems[lnIndex];
                if (toAvailableMenuIds.Contains(Convert.ToInt32(loItem.MenuID)) && loItem.Subitems.Count == 0)
                {
                    loItem.Visible = true;
                }
                else
                {
                    if (loItem.Subitems.Count == 0)
                    {
                        loItem.Visible = false;
                    }
                    else
                    {
                        loItem.Visible = CheckVisibleMenus(loItem.Subitems, toAvailableMenuIds);
                    }
                }
                if (loItem.Visible)
                {
                    lbVisible = true;
                }
            }
            return(lbVisible);
        }
Exemple #2
0
        private TableRow GenerateCommonMenu(Menuitem toMenuitem, int tnCurLevel)
        {
            TableRow  loRow;
            TableCell loCell;
            HyperLink loHyper;
            Literal   loText;

            System.Web.UI.WebControls.Image loImage;

            loRow  = new TableRow();
            loCell = new TableCell();
            loCell.VerticalAlign   = VerticalAlign.Top;
            loCell.HorizontalAlign = HorizontalAlign.Left;
            loHyper = new HyperLink();
            loText  = new Literal();

            if (toMenuitem.HyperLink == "")
            {
                loText.Text = toMenuitem.Caption;
                loCell.Controls.Add(loText);
                loCell.CssClass   = this._cssItem;
                loCell.ColumnSpan = 2;
            }
            else
            {
                loCell.VerticalAlign = VerticalAlign.Top;
                loCell.ColumnSpan    = 1;
                loImage = new System.Web.UI.WebControls.Image();
                if (tnCurLevel == 2)
                {
                    loImage.ImageUrl = this._MasterImage;
                    loImage.Width    = 8;
                }
                else
                {
                    loImage.Width    = 16;
                    loImage.ImageUrl = this._SubImage;
                }
                loImage.Height      = 15;
                loImage.BorderWidth = 0;
                loCell.Controls.Add(loImage);

                loHyper.Text        = toMenuitem.Caption;
                loHyper.NavigateUrl = "/" + AppDir + "/" + BasePage.AppendQueryString(toMenuitem.HyperLink, "");
                loHyper.CssClass    = this._cssSubitem;
                loCell.Controls.Add(loHyper);
            }
            loRow.Cells.Add(loCell);
            return(loRow);
        }
Exemple #3
0
        public string GetMenuURL(string tsMenuID)
        {
            Menuitem loMenuitem = this.FindMenuitem(this.TopMenuitems, tsMenuID);

            if (loMenuitem == null)
            {
                return("");
            }
            else
            {
                return(MyFramework.BusinessLogic.Common.BasePage.AppendQueryString(loMenuitem.HyperLink, "TopMenuId=" + loMenuitem.ParentMenuID + "&LeftMenuId=" + loMenuitem.MenuID));
            }
            //return loMenuitem.HyperLink;
        }
Exemple #4
0
 private void PAddMenuitem(List <Menuitem> toMenuitems, Menuitem toMenuitem)
 {
     if (toMenuitem.ParentMenuID == null || toMenuitem.ParentMenuID == "")
     {
         toMenuitems.Add(toMenuitem);
     }
     else
     {
         Menuitem loItem = PFindMenuitem(toMenuitems, toMenuitem.ParentMenuID);
         if (loItem != null)
         {
             loItem.Subitems.Add(toMenuitem);
         }
     }
 }
Exemple #5
0
 private void SetAvailableMenus(List <Menuitem> toMenuitems)
 {
     for (int lnIndex = 0; lnIndex < toMenuitems.Count; lnIndex++)
     {
         Menuitem loItem = (Menuitem)toMenuitems[lnIndex];
         if (loItem.Visible)
         {
             PAddMenuitem(this.AvailableItems, new Menuitem(loItem.MenuID, loItem.ParentMenuID, loItem.Caption, loItem.HyperLink, loItem.Level));
             if (loItem.Subitems.Count > 0)
             {
                 this.SetAvailableMenus(loItem.Subitems);
             }
         }
     }
 }
Exemple #6
0
        /// <summary>
        /// 把一个菜单项加入到菜单集合中.
        /// </summary>
        /// <param name="toMenuitem">加入一个菜单项</param>
        public void AddMenuitem(Menuitem toMenuitem)
        {
            Menuitem loMenuitem;

            if (toMenuitem.ParentMenuID == null || toMenuitem.ParentMenuID == "")
            {
                this.TopMenuitems.Add(toMenuitem);
            }
            else
            {
                loMenuitem = this.FindMenuitem(this.TopMenuitems, toMenuitem.ParentMenuID);
                if (loMenuitem != null)
                {
                    loMenuitem.Subitems.Add(toMenuitem);
                }
            }
        }
Exemple #7
0
        private Menuitem RecusiveFindMenuitem(Menuitem toCurrentItem, string tsMenuId)
        {
            Menuitem loTempItem;

            for (int lnIndex = 0; lnIndex < toCurrentItem.Subitems.Count; lnIndex++)
            {
                if (((Menuitem)toCurrentItem.Subitems[lnIndex]).MenuID == tsMenuId)
                {
                    return((Menuitem)toCurrentItem.Subitems[lnIndex]);
                }
                loTempItem = RecusiveFindMenuitem((Menuitem)toCurrentItem.Subitems[lnIndex], tsMenuId);
                if (loTempItem != null)
                {
                    return(loTempItem);
                }
            }
            return(null);
        }
Exemple #8
0
 private bool IsRelatedItem(Menuitem loItem)
 {
     return(loItem.MenuID.IndexOf(this.MenuPrefix) == 0);
 }