Exemplo n.º 1
0
        private string SpecialStringFormat(XmlNode node)
        {
            MenuBinding Item = GetMenuBinding(node);

            if (Item != null)
            {
                // Item.DataFields;
            }
            Regex r = new Regex("{p.[0-9]}");

            return("");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Limit children to MenuBinding Controls
        /// Throws an error on duplicate bindings
        /// </summary>
        /// <param name="obj">Child to be added to CustomMenu Control</param>
        protected override void AddParsedSubObject(object obj)
        {
            base.AddParsedSubObject(obj);

            if (obj is MenuBinding)
            {
                MenuBinding item = (MenuBinding)obj;
                try
                {
                    NodeBindings.Add(item.DataMember, item);
                }
                catch (Exception e)
                {
                    throw new Exception("A Node with the name " + item.DataMember + " has already been bound to this Menu.");
                }
            }
        }
Exemplo n.º 3
0
 protected void EnsureDataBindings(ControlCollection controls)
 {
     foreach (Control control in controls)
     {
         if (control is MenuBinding)
         {
             MenuBinding item = (MenuBinding)control;
             try
             {
                 NodeBindings.Add(item.DataMember, item);
             }
             catch (Exception e)
             {
                 //throw new Exception("A Node with the name " + item.DataMember + " has already been bound to this Menu.");
             }
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Returns an array of strings which contain a
        /// map of optional MenuBinding DataFields to the
        /// Node's attrubutes
        /// </summary>
        /// <param name="node">Node to extract optional bindings</param>
        /// <returns></returns>
        public string GetPopulatedField(XmlNode node, string FormatField)
        {
            MenuBinding Item = GetMenuBinding(node);

            string[] Fields             = Item.GetDataFields();
            string   NewFormattedString = new String(FormatField.ToCharArray());

            Regex par = new Regex("{p.[0-9]}");
            Regex std = new Regex("{[0-9]}");

            if (Item != null && Fields.Length > 0)
            {
                Match stdMatch = std.Match(FormatField);
                if (stdMatch != null)
                {
                    foreach (Group g in stdMatch.Groups)
                    {
                        if (g.Value.Length > 0)
                        {
                            int    fieldIndex = int.Parse(g.Value[1].ToString());
                            string attValue   = XmlUtil.GetAttributeValue(node, Fields[fieldIndex]);
                            NewFormattedString = NewFormattedString.Replace(g.Value, attValue);
                        }
                    }
                }

                Match parMatch = par.Match(FormatField);
                if (parMatch != null)
                {
                    foreach (Group g in parMatch.Groups)
                    {
                        if (g.Value.Length > 0)
                        {
                            int    fieldIndex = int.Parse(g.Value[3].ToString());
                            string attName    = Fields[fieldIndex];
                            string attValue   = XmlUtil.GetAttributeValue(node.ParentNode, attName);
                            NewFormattedString = NewFormattedString.Replace(g.Value, attValue);
                        }
                    }
                }
            }
            return(NewFormattedString);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Returns the display text for a DataMember specified by its DataTextField,
        /// try attribute "name", else return the Node name.
        /// </summary>
        /// <param name="node">Node name</param>
        /// <returns></returns>
        private string GetDataBoundTextField(XmlNode node)
        {
            MenuBinding Item = GetMenuBinding(node);

            if (Item != null)
            {
                string attributeValue = XmlUtil.GetAttributeValue(node, Item.DataTextField);
                string nameAttribute  = XmlUtil.GetAttributeValue(node, "name");
                if (!string.IsNullOrEmpty(attributeValue))
                {
                    return(attributeValue);
                }
                else if (!string.IsNullOrEmpty(nameAttribute))
                {
                    return(nameAttribute);
                }
            }
            return(node.Name);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Wraps the XmlNode into a MenuListItem with inner controls
        /// </summary>
        /// <param name="node">Node to wrap as a MenuListItem</param>
        /// <returns></returns>
        public MenuListItem GetFormattedListItem(XmlNode node)
        {
            // Create base objects
            MenuListItem Item      = new MenuListItem();
            Literal      ItemText  = new Literal();
            HyperLink    ItemLink  = new HyperLink();
            Image        itemImage = new Image();

            itemImage.Visible = false;
            // Set default values
            ItemText.Text = GetDataBoundTextField(node);
            ItemLink.Text = GetDataBoundTextField(node);
            //ItemLink.NavigateUrl = "#";

            MenuBinding ItemBinding = GetMenuBinding(node);

            if (ItemBinding != null)
            {
                //string[] OptFields = GetPopulatedFields(node);

                string href = XmlUtil.GetAttributeValue(node, "href");
                if (!string.IsNullOrEmpty(href))
                {
                    ItemLink.NavigateUrl = href;
                }
                // Set the url for the hyperlink
                else if (ItemBinding.URL != null)
                {
                    ItemLink.NavigateUrl = GetPopulatedField(node, ItemBinding.URL);
                }

                // If defined, set the URL Target
                string target = XmlUtil.GetAttributeValue(node, "target");
                if (!string.IsNullOrEmpty(target))
                {
                    ItemLink.Target = target;
                }
                else if (ItemBinding.URLTarget != null)
                {
                    ItemLink.Target = GetPopulatedField(node, ItemBinding.URLTarget);
                }
                string onclick = XmlUtil.GetAttributeValue(node, "onclick");
                if (!string.IsNullOrEmpty(onclick))
                {
                    string ClientAction = onclick;
                    ItemLink.Attributes.Add("onclick", ClientAction);
                }
                //Client click
                else if (ItemBinding.OnClientClick != null)
                {
                    string ClientAction = GetPopulatedField(node, ItemBinding.OnClientClick);
                    ItemLink.Attributes.Add("onclick", ClientAction);
                }
                // set icon
                string tableName = XmlUtil.GetAttributeValue(node, "tableName");

                itemImage.Visible = false;
                if (!string.IsNullOrEmpty(tableName))
                {
                    string iconPath = pedc.GetTableIcon(tableName, true);
                    if (!string.IsNullOrEmpty(iconPath))
                    {
                        itemImage.ImageUrl = iconPath;
                        itemImage.CssClass = "MenuItemIcon";
                        itemImage.Visible  = true;
                    }
                }
            }

            // Combine the controls to produce MenuListItem
            ItemLink.Controls.Add(itemImage);
            ItemLink.Controls.Add(ItemText);

            Item.Controls.Add(ItemLink);
            return(Item);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Gets the MenuBinding for the specified XMLNode.
        /// Null if NodeBindings does not contain a node with the Node name
        /// </summary>
        /// <param name="node">Node to compare against bindings</param>
        /// <returns></returns>
        public MenuBinding GetMenuBinding(XmlNode node)
        {
            MenuBinding Binding = (MenuBinding)NodeBindings[node.Name];

            return(Binding);
        }