示例#1
0
        public static void PrimeXml(MainMenuItem[] items)
        {
            // This is only supposed to be used once, to prime the initial menu
            XmlSerializer serializer = new XmlSerializer(typeof (MainMenuItem[]));

            using (TextWriter writer = new StreamWriter("C:\\Windows\\Temp\\temp.xml"))
            {
                serializer.Serialize(writer, items);
            }
        }
示例#2
0
        public static MainMenuItem Submenu(string resourceKey, int userLevel, string permissions)
        {
            MainMenuItem result = new MainMenuItem()
            {
                Permissions = permissions,
                ResourceKey = resourceKey,
                UserLevel = userLevel,
                Type = MenuItemType.Submenu
            };

            return result;
        }
示例#3
0
        public static MainMenuItem Disabled(string image, string resourceKey, int userLevel, string permissions)
        {
            MainMenuItem result = new MainMenuItem()
            {
                ImageUrl = image,
                Permissions = permissions,
                ResourceKey = resourceKey,
                UserLevel = userLevel,
                Type = MenuItemType.Disabled
            };

            return result;
        }
示例#4
0
        public static MainMenuItem Link(string image, string navUrl, string resourceKey, int userLevel,
            string permissions)
        {
            MainMenuItem result = new MainMenuItem()
            {
                ImageUrl = image,
                NavigateUrl = navUrl,
                Permissions = permissions,
                ResourceKey = resourceKey,
                UserLevel = userLevel,
                Type = MenuItemType.Link
            };

            return result;
        }
示例#5
0
        private void WriteMenuItem(MainMenuItem menuItem, HtmlTextWriter output)
        {
            output.Write("<li class=\"{0}\">", menuItem.Type.ToString());
            string localizedText = "RESOURCE NOT FOUND";

            if (!String.IsNullOrEmpty(menuItem.ResourceKey))
            {
                object resourceObject = GetGlobalResourceObject("Menu5", "Menu5_" + menuItem.ResourceKey);
                if (resourceObject != null)
                {
                    localizedText = resourceObject.ToString();
                }
            }
            localizedText = Server.HtmlEncode(localizedText); // muy importante

            string iconSize = "40px";

            if (File.Exists(Server.MapPath("~/Images/PageIcons/" + menuItem.ImageUrl + "-20px.png")))
            {
                iconSize = "20px";
            }

            switch (menuItem.Type)
            {
                // TODO: More types here, and check with the CSS. Some work to get good looking

                    // MEH forcing build

                case MenuItemType.Link:
                    output.Write("<a href=\"{1}\"><img src=\"/Images/PageIcons/{0}-{3}.png\"  height=\"20\" width=\"20\"  />{2}</a>",
                        menuItem.ImageUrl, menuItem.NavigateUrl, localizedText, iconSize);
                    break;
                case MenuItemType.Disabled:
                    string imageUrl = "/Images/PageIcons/" + menuItem.ImageUrl + "-" + iconSize + ".png";
                    if (String.IsNullOrEmpty(menuItem.ImageUrl))
                    {
                        imageUrl = "/Images/PageIcons/transparency-16px.png"; // doesn't matter in slightest if browser resizes to 20px
                    }
                    output.Write("<a href='#disabled'><img src=\"{0}\" height=\"20\" width=\"20\" />{1}</a>", imageUrl, localizedText);
                    break;
                case MenuItemType.Submenu:
                    output.Write("<a href='#'>" + localizedText + "</a>");
                    break;
                case MenuItemType.Separator:
                    output.Write("&nbsp;<hr/>");
                    break;
                default:
                    throw new NotImplementedException();
            }

            if (menuItem.Children.Length > 0)
            {
                output.Write("<ul>");
                foreach (MainMenuItem child in menuItem.Children)
                {
                    WriteMenuItem(child, output);
                }
                output.Write("</ul>");
            }

            output.Write("</li>");
        }
示例#6
0
 public MainMenuItem()
 {
     Children = new MainMenuItem[0];
 }
示例#7
0
        public static void PrimeNewMenuFile()
        {
            MainMenuItem todoItem = MainMenuItem.Disabled(string.Empty, "Placeholder_Todo", 1, string.Empty);
            MainMenuItem[] todoItemArray = new MainMenuItem[] {todoItem};

            MainMenuItem peopleItem = MainMenuItem.Submenu("People", 1, string.Empty);
            peopleItem.Children = todoItemArray;

            MainMenuItem commsItem = MainMenuItem.Submenu("Communications", 1, string.Empty);
            peopleItem.Children = todoItemArray;

            MainMenuItem claimRefundItem = MainMenuItem.Link("iconshock-moneyback",
                "/Pages/v5/Financial/FileExpenseClaim.aspx", "Financial_ClaimExpense", 2, String.Empty);
            MainMenuItem separatorItem = MainMenuItem.Separator;

            MainMenuItem[] financialChildren = new[] {claimRefundItem, separatorItem};
            MainMenuItem financialItem = MainMenuItem.Submenu("Financial", 2, string.Empty);
            financialItem.Children = financialChildren;

            MainMenuItem[] protoMenu = new[] {peopleItem, commsItem, financialItem};
            PrimeXml(protoMenu);

        }
示例#8
0
 public MainMenuItem()
 {
     Children = new MainMenuItem[0];
 }