Esempio n. 1
0
    protected void nbMenu_GroupDataBound(object source, NavBarGroupEventArgs e)
    {
        IHierarchyData         hierarchyData = (e.Group.DataItem as IHierarchyData);
        XmlElement             xmlElement    = hierarchyData.Item as XmlElement;
        XmlAttributeCollection attributes    = xmlElement.Attributes;

        if (xmlElement.Attributes["Caption"] != null)
        {
            e.Group.Name = xmlElement.Attributes["Caption"].Value;
        }
        else
        {
            e.Group.Name = xmlElement.Attributes["Text"].Value;
        }

        if (xmlElement.Attributes["Visible"] != null && xmlElement.Attributes["Visible"].Value.ToLower() == "false")
        {
            e.Group.Visible = false;
        }

        if (e.Group.Expanded && TitleImageUrl == "")
        {
            this.titleImageUrl = xmlElement.Attributes["ImageUrl"] != null ? xmlElement.Attributes["ImageUrl"].Value : "";
        }
    }
Esempio n. 2
0
        public static async Task <IHierarchyData> Find(this IEnumerable <IHierarchyData> roots, string path)
        {
            var hierarchyDatas = roots as IHierarchyData[] ?? roots.ToArray();

            if (roots == null || !hierarchyDatas.Any() || string.IsNullOrEmpty(path))
            {
                return(null);
            }
            IHierarchyData found = null;

            foreach (
                var root in
                hierarchyDatas.Where(root => path.StartsWith(root.RelativePath, StringComparison.OrdinalIgnoreCase))
                )
            {
                if (root.RelativePath == path)
                {
                    found = root;
                    break;
                }
                found = await root.FindDescendant(path);

                if (found != null)
                {
                    break;
                }
            }
            return(found);
        }
Esempio n. 3
0
        public static Dictionary <string, object> ToDictionary(IHierarchyData data)
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            if (null != data)
            {
                result.Add("Type", data.Type);
                result.Add("Path", data.Path);
                if (data.Item is XmlNode)
                {
                    XmlNode nodeItem = data.Item as XmlNode;
                    foreach (XmlAttribute attribute in nodeItem.Attributes)
                    {
                        if ("Type" == attribute.Name)
                        {
                            throw new ArgumentException("Invalid attribute name 'Type'. That name has a different meaning in hierachical data object");
                        }
                        if ("Path" == attribute.Name)
                        {
                            throw new ArgumentException("Invalid attribute name 'Path'. That name has a different meaning in hierachical data object");
                        }
                        result.Add(attribute.Name, attribute.Value);
                    }
                }
            }
            return(result);
        }
Esempio n. 4
0
    protected void nbMenu_GroupDataBound(object source, NavBarGroupEventArgs e) {
        IHierarchyData hierarchyData = (e.Group.DataItem as IHierarchyData);
        XmlElement xmlElement = hierarchyData.Item as XmlElement;
        XmlAttributeCollection attributes = xmlElement.Attributes;

        e.Group.Expanded = false;
        foreach (NavBarItem item in e.Group.Items)
        {
            if (item.Selected)
            {
                e.Group.Expanded = true;
                break;
            }
        }

        if (xmlElement.Attributes["Caption"] != null)
            e.Group.Name = xmlElement.Attributes["Caption"].Value;
        else
            e.Group.Name = xmlElement.Attributes["Text"].Value;

        if (xmlElement.Attributes["Visible"] != null && xmlElement.Attributes["Visible"].Value.ToLower() == "false")
            e.Group.Visible = false;

        if (e.Group.Expanded && titleImageUrl == "")
            this.titleImageUrl = xmlElement.Attributes["ImageUrl"] != null ? xmlElement.Attributes["ImageUrl"].Value : "";
    }
Esempio n. 5
0
File: Utils.cs Progetto: rebider/soa
    protected virtual bool GetStatus(object dataItem, string name)
    {
        IHierarchyData hierarchyData = (dataItem as IHierarchyData);
        XmlElement     xmlElement    = hierarchyData.Item as XmlElement;

        return(GetStatusCore(xmlElement, name));
    }
        private void RecursiveDataBindInternal(IHierarchicalEnumerable enumerable, StringBuilder sb)
        {
            bool first = true;

            if (this.Site != null)
            {
                return;
            }
            foreach (object item in enumerable)
            {
                IHierarchyData data = enumerable.GetHierarchyData(item);
                if (null != data)
                {
                    PropertyDescriptorCollection props = TypeDescriptor.GetProperties(data);
                    if (props.Count > 0)
                    {
                        string title       = ((string)(props["Title"].GetValue(data)));
                        string description = ((string)(props["Description"].GetValue(data)));
                        string url         = ((string)(props["Url"].GetValue(data)));
                        string cssClass    = null;
                        if (item is SiteMapNode)
                        {
                            cssClass = ((SiteMapNode)(item))["cssClass"];
                        }
                        if (first)
                        {
                            first = false;
                        }
                        else
                        {
                            sb.Append(",");
                        }
                        sb.AppendFormat("{{\'title\':\'{0}\',\'url\':\'{1}\'", BusinessRules.JavaScriptString(title), BusinessRules.JavaScriptString(url));
                        if (!(String.IsNullOrEmpty(description)))
                        {
                            sb.AppendFormat(",\'description\':\'{0}\'", BusinessRules.JavaScriptString(description));
                        }
                        if (url == Page.Request.RawUrl)
                        {
                            sb.Append(",\'selected\':true");
                        }
                        if (!(String.IsNullOrEmpty(cssClass)))
                        {
                            sb.AppendFormat(",\'cssClass\':\'{0}\'", cssClass);
                        }
                        if (data.HasChildren)
                        {
                            IHierarchicalEnumerable childEnumerable = data.GetChildren();
                            if (null != childEnumerable)
                            {
                                sb.Append(",\'children\':[");
                                RecursiveDataBindInternal(childEnumerable, sb);
                                sb.Append("]");
                            }
                        }
                        sb.Append("}");
                    }
                }
            }
        }
Esempio n. 7
0
        protected void InfoMenu_OnItemDataBound(object sender, MenuItemEventArgs e)
        {
            IHierarchyData itemHierarchyData = (IHierarchyData)e.Item.DataItem;
            var            element           = (XmlElement)itemHierarchyData.Item;

            var classAttr = element.Attributes["SpriteClassName"];

            if (classAttr != null)
            {
                e.Item.Image.SpriteProperties.CssClass = classAttr.Value;
            }

            if (e.Item.Parent.Name == "theme" && e.Item.Name == Utils.CurrentTheme)
            {
                e.Item.Selected = true;
            }

            if (e.Item.Name == "print")
            {
                var url = GetPrintItemNavigationUrl();
                if (string.IsNullOrEmpty(url))
                {
                    e.Item.Visible = false;
                }
                else
                {
                    e.Item.NavigateUrl = url;
                }
            }
        }
Esempio n. 8
0
        private PruningTree CreatePruningInformation(IHierarchyData root)
        {
            PruningTree tree = new PruningTree();

            if (root.HasChildren)
            {
                var anyVisible = ShowEmpty;
                foreach (var child in root.GetChildren())
                {
                    var childTree = CreatePruningInformation((IHierarchyData)child);
                    anyVisible = anyVisible || childTree.IsVisible;
                    tree.Children.Add(childTree);
                }
                tree.IsVisible = anyVisible;
            }
            else
            {
                var pc = (PanelContent)root.Item;
                tree.IsVisible = (ShowEmpty || pc.HasResult) && SelectPanelTemplate(root) != null;
                tree.IsVisible = tree.IsVisible &&
                                 (SingletonValues ||
                                  GetPanelTypeEnum(root) != PanelType.Values ||
                                  pc.ResultAsValues().Size > 1);
            }
            return(tree);
        }
Esempio n. 9
0
        public static void SelecteTo(this IHierarchyData from, IHierarchyData to)
        {
            if (from == null)
            {
                return;
            }
            from.IsSelected = true;
            var hierarchy = from.GetHierarchy().ToArray();
            var flag      = to == null || hierarchy[0].Equals(to);

            for (var i = 0; i < hierarchy.Length - 1; i++)
            {
                if (flag)
                {
                    var current = hierarchy[i];
                    current.SelectedChild = hierarchy[i + 1];
                    //current.IsSelected = true;
                    current.IsExpanded = true;
                }
                else
                {
                    flag = hierarchy[i] == to;
                }
            }
        }
Esempio n. 10
0
 public static IHierarchyData FindSameParent(this IHierarchyData one, IHierarchyData another)
 {
     if (one == null || another == null)
     {
         return(null);
     }
     return(one.FindSameParentWith(another));
 }
Esempio n. 11
0
    protected bool GetIsUpdatedVisible(object dataItem)
    {
        bool           isUpdated     = false;
        IHierarchyData hierarchyData = (dataItem as IHierarchyData);
        XmlElement     xmlElement    = hierarchyData.Item as XmlElement;

        string value = GetAttributeValue(xmlElement, "IsUpdated");

        bool.TryParse(value, out isUpdated);
        return(isUpdated);
    }
    protected void ASPxNavBar1_GroupDataBound(object source, NavBarGroupEventArgs e)
    {
        IHierarchyData         hierarchyData = (e.Group.DataItem as IHierarchyData);
        XmlElement             xmlElement    = hierarchyData.Item as XmlElement;
        XmlAttributeCollection attributes    = xmlElement.Attributes;

        if (xmlElement.Attributes["View"] != null)
        {
            e.Group.Text = xmlElement.Attributes["View"].Value;
        }
    }
Esempio n. 13
0
        private IPanelType GetPanelType(IHierarchyData panelHierarchy)
        {
            var        panelTypeEnum = GetPanelTypeEnum(panelHierarchy);
            IPanelType panelType;

            if (_panelTypes.TryGetValue(panelTypeEnum, out panelType))
            {
                return(panelType);
            }
            return(_panelTypes[PanelType.Unknown]);
        }
Esempio n. 14
0
    // <Snippet3>
    private void Page_Load(object sender, System.EventArgs e)
    {
        IHierarchicalEnumerable ihe         = (IHierarchicalEnumerable)SiteMap.RootNode.ChildNodes;
        IEnumerator             enumeration = ihe.GetEnumerator();

        while (enumeration.MoveNext())
        {
            // Print out SiteMapNode Titles.
            IHierarchyData hierarchicalNode = ihe.GetHierarchyData(enumeration.Current);
            PrintFullChildNodeInfo(hierarchicalNode);
        }
    }
Esempio n. 15
0
        void AddItem(C1FlexGrid flex, IHierarchyData item, int level)
        {
            // add this item
            var nd = flex.Rows.AddNode(level);

            nd.Row.UserData = item;
            nd.Data         = ((Category)item).Name;

            // add children
            foreach (IHierarchyData child in item.GetChildren())
            {
                AddItem(flex, child, level + 1);
            }
        }
Esempio n. 16
0
 public static object ExtractValue(IHierarchyData data, string propertyName)
 {
     if ("Type" == propertyName)
     {
         return(data.Type);
     }
     else if ("Path" == propertyName)
     {
         return(data.Path);
     }
     else
     {
         return(ExtractValue(data.Item, propertyName));
     }
 }
Esempio n. 17
0
        public static void ClearSelectionTo(this IHierarchyData from, IHierarchyData to)
        {
            if (from == null)
            {
                return;
            }
            from.IsSelected = false;
            var parent = from.Parent;

            while (parent != null && parent != to)
            {
                parent.IsSelected    = false;
                parent.SelectedChild = null;
                parent = parent.Parent;
            }
        }
Esempio n. 18
0
    protected void ActionMenu_ItemDataBound(object sender, MenuItemEventArgs e)
    {
        IHierarchyData itemHierarchyData = (IHierarchyData)e.Item.DataItem;
        var            element           = (XmlElement)itemHierarchyData.Item;

        var classAttr = element.Attributes["SpriteClassName"];

        if (classAttr != null)
        {
            e.Item.Image.SpriteProperties.CssClass = classAttr.Value;
        }

        if (e.Item.Parent == e.Item.Menu.RootItem)
        {
            e.Item.ClientVisible = false;
        }
    }
Esempio n. 19
0
 private void FillBoundChildrenRecursive(IHierarchicalEnumerable hEnumerable, MyTreeNodeCollection nodeCollection)
 {
     if (hEnumerable != null)
     {
         foreach (object obj2 in hEnumerable)
         {
             IHierarchyData hierarchyData = hEnumerable.GetHierarchyData(obj2);
             MyTreeNode     child         = new MyTreeNode(this);
             nodeCollection.Add(child);
             child.Bind(hierarchyData);
             if (((this.MaxDataBindDepth < 0) || (child.Depth != this.MaxDataBindDepth)) && ((hierarchyData != null) && hierarchyData.HasChildren))
             {
                 IHierarchicalEnumerable children = hierarchyData.GetChildren();
                 this.FillBoundChildrenRecursive(children, child.ChildNodes);
             }
         }
     }
 }
Esempio n. 20
0
    // </Snippet3>
    // <Snippet2>
    // Print out the current data node, then iterate through its
    // children and do the same.
    private void PrintFullChildNodeInfo(IHierarchyData node)
    {
        string whitespace = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        string br         = "<BR>";

        Response.Write(node.ToString() + br);
        Response.Write(whitespace + node.Path + br);

        // Check for specific types and perform extended functions.
        if (node.Type == "SiteMapNode")
        {
            // Because SiteMapNode implements the IHierarchyData interface,
            // the IHierarchyData object can be cast directly as a SiteMapNode,
            // rather than accessing the Item property for the object that
            // the Type property identifies.
            SiteMapNode siteNode = node.Item as SiteMapNode;
            Response.Write(whitespace + siteNode.Url + br);
            Response.Write(whitespace + siteNode.Description + br);
        }
        else if (node.Type == "SomeBusinessObject")
        {
            // If the IHierarchyData instance is a wrapper class on a business
            // object of some kind, you can retrieve the business object by using
            // the IHierarchyData.Item property.
            //          SomeBusinessObject busObj = node.Item as SomeBusinessObject;
        }

        if (node.HasChildren)
        {
            IEnumerator children = ((IHierarchicalEnumerable)node.GetChildren()).GetEnumerator();

            while (children.MoveNext())
            {
                // Print out SiteMapNode Titles recursively.
                IHierarchyData hierarchicalNode = node.GetChildren().GetHierarchyData(children.Current);
                PrintFullChildNodeInfo(hierarchicalNode);
            }
        }
    }
Esempio n. 21
0
    protected void ASPxCallback1_Callback(object sender, CallbackEventArgs e)
    {
        int newsID = int.Parse(e.Parameter);
        IHierarchicalDataSource    dataSource = (IHierarchicalDataSource)XmlDataSource1;
        HierarchicalDataSourceView view       = dataSource.GetHierarchicalView("");
        IHierarchicalEnumerable    enumerable = view.Select();
        int    index = 1;
        string text  = "";

        foreach (object obj in enumerable)
        {
            if (newsID == index)
            {
                IHierarchyData data = enumerable.GetHierarchyData(obj);
                PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(data);
                PropertyDescriptor           descriptor = properties.Find("Text", true);
                text = descriptor.GetValue(obj).ToString();
                break;
            }
            index++;
        }
        e.Result = text;
    }
Esempio n. 22
0
        public void GetHierarchicalView()
        {
            Page    page = new Page();
            DSPoker ds   = new DSPoker();

            ds.ID   = "ds";
            ds.Data = @"<?xml version=""1.0"" encoding=""utf-8""?>
					<bookstore xmlns:bk=""urn:samples"">
					  <book genre=""novel"" publicationdate=""1999"" bk:ISBN=""0192100262"">
					    <title>Pride and Prejudice</title>
					    <author>
					      <first-name>Jane</first-name>
					      <last-name>Austen</last-name>
					    </author>
					    <price>24.95</price>
					  </book>
					  <book genre=""novel"" publicationdate=""1985"" bk:ISBN=""0771008139"">
					    <title>The Handmaid's Tale</title>
					    <author>
					      <first-name>Margaret</first-name>
					      <last-name>Atwood</last-name>
					    </author>
					    <price>29.95</price>
					  </book>
					</bookstore>"                    ;
            HierarchicalDataSourceView view = ds.DoGetHierarchicalView("");
            IHierarchicalEnumerable    num  = view.Select();

            foreach (object obj in num)
            {
                IHierarchyData hdata   = num.GetHierarchyData(obj);
                XmlElement     element = (XmlElement)hdata.Item;
                Assert.AreEqual("bookstore", element.Name, "RootElementName");
                Assert.AreEqual("Pride and PrejudiceJaneAusten24.95The Handmaid's TaleMargaretAtwood29.95", element.InnerText, "InnerText");
                Assert.AreEqual(2, element.ChildNodes.Count, "ChildElementNodes");
            }
        }
Esempio n. 23
0
 public static object ExtractValue(IHierarchyData data, string propertyName)
 {
     if ("Type" == propertyName)
         return data.Type;
     else if ("Path" == propertyName)
         return data.Path;
     else
         return ExtractValue(data.Item, propertyName);
 }
Esempio n. 24
0
    /* Main NavBar */
    protected void nbMenu_ItemDataBound(object source, DevExpress.Web.ASPxNavBar.NavBarItemEventArgs e)
    {
        e.Item.Name = e.Item.Text;

        IHierarchyData itemHierarchyData = (e.Item.DataItem as IHierarchyData);
        XmlElement     xmlElement        = itemHierarchyData.Item as XmlElement;

        if (xmlElement.Attributes["Caption"] != null)
        {
            e.Item.Name = xmlElement.Attributes["Caption"].Value;
        }

        if (string.IsNullOrEmpty(DemoName))
        {
            this.demoName = "ASPxperience";
            if (xmlElement.OwnerDocument.DocumentElement.Attributes["Name"] != null)
            {
                this.demoName = xmlElement.OwnerDocument.DocumentElement.Attributes["Name"].Value;
            }
        }

        if (GetUrl(e.Item.NavigateUrl).ToLower() == Request.AppRelativeCurrentExecutionFilePath.ToLower())
        {
            if (Request.QueryString["Section"] != null)
            {
                if (xmlElement.Attributes["Section"] == null ||
                    Request.QueryString["Section"] != xmlElement.Attributes["Section"].Value)
                {
                    return;
                }
            }
            e.Item.Selected       = true;
            e.Item.Group.Expanded = true;

            XmlAttribute useFullTitle = xmlElement.Attributes["UseFullTitle"];
            if (useFullTitle != null && !bool.Parse(useFullTitle.Value))
            {
                if (xmlElement.Attributes["Title"] != null)
                {
                    this.title = xmlElement.Attributes["Title"].Value;
                }
            }
            else
            {
                XmlNode xmlGroupNode      = xmlElement.ParentNode;
                XmlNode xmlMainNode       = xmlGroupNode.ParentNode;
                string  titleFormatString = xmlMainNode.Attributes["TitleFormatString"] != null ? xmlMainNode.Attributes["TitleFormatString"].Value : "";
                string  mainTitle         = xmlMainNode.Attributes["Title"] != null ? xmlMainNode.Attributes["Title"].Value : "";
                string  groupTitle        = xmlGroupNode.Attributes["Title"] != null ? xmlGroupNode.Attributes["Title"].Value : "";
                string  demoTitle         = xmlElement.Attributes["Title"] != null ? xmlElement.Attributes["Title"].Value : "";

                if (string.IsNullOrEmpty(titleFormatString))
                {
                    if (!string.IsNullOrEmpty(mainTitle))
                    {
                        titleFormatString = "{0}";
                    }
                    if (!string.IsNullOrEmpty(groupTitle))
                    {
                        titleFormatString += " - {1}";
                    }
                    if (!string.IsNullOrEmpty(demoTitle))
                    {
                        titleFormatString += " - {2}";
                    }
                }
                this.title = string.Format(titleFormatString, mainTitle, groupTitle, demoTitle);
            }

            foreach (XmlNode itemNode in xmlElement.ChildNodes)
            {
                switch (itemNode.Name)
                {
                case "Description": {
                    this.description = itemNode.InnerXml;
                    break;
                }

                case "GeneralTerms": {
                    this.generalTerms = itemNode.InnerXml;
                    if (itemNode.Attributes["ShowHeader"] != null &&
                        itemNode.Attributes["ShowHeader"].Value.ToLower() == "false")
                    {
                        this.showTermsHeader = false;
                    }
                    break;
                }
                }
            }
        }
    }
Esempio n. 25
0
		internal void Bind (IHierarchyData hierarchyData)
		{
			this.hierarchyData = hierarchyData;
			DataBound = true;
			DataPath = hierarchyData.Path;
			dataItem = hierarchyData.Item;

			MenuItemBinding bin = GetBinding ();
			if (bin != null) {

				// Bind Enabled property

				if (bin.EnabledField != "")
					try { Enabled = Convert.ToBoolean (GetBoundPropertyValue (bin.EnabledField)); }
					catch { Enabled = bin.Enabled; }
				else
					Enabled = bin.Enabled;

				// Bind ImageUrl property

				if (bin.ImageUrlField.Length > 0) {
					ImageUrl = Convert.ToString (GetBoundPropertyValue (bin.ImageUrlField));
					if (ImageUrl.Length == 0)
						ImageUrl = bin.ImageUrl;
				}
				else if (bin.ImageUrl.Length > 0)
					ImageUrl = bin.ImageUrl;

				// Bind NavigateUrl property

				if (bin.NavigateUrlField.Length > 0) {
					NavigateUrl = Convert.ToString (GetBoundPropertyValue (bin.NavigateUrlField));
					if (NavigateUrl.Length == 0)
						NavigateUrl = bin.NavigateUrl;
				}
				else if (bin.NavigateUrl.Length > 0)
					NavigateUrl = bin.NavigateUrl;

				// Bind PopOutImageUrl property

				if (bin.PopOutImageUrlField.Length > 0) {
					PopOutImageUrl = Convert.ToString (GetBoundPropertyValue (bin.PopOutImageUrlField));
					if (PopOutImageUrl.Length == 0)
						PopOutImageUrl = bin.PopOutImageUrl;
				}
				else if (bin.PopOutImageUrl.Length > 0)
					PopOutImageUrl = bin.PopOutImageUrl;

				// Bind Selectable property

				if (bin.SelectableField != "")
					try { Selectable = Convert.ToBoolean (GetBoundPropertyValue (bin.SelectableField)); }
					catch { Selectable = bin.Selectable; }
				else
					Selectable = bin.Selectable;

				// Bind SeparatorImageUrl property

				if (bin.SeparatorImageUrlField.Length > 0) {
					SeparatorImageUrl = Convert.ToString (GetBoundPropertyValue (bin.SeparatorImageUrlField));
					if (SeparatorImageUrl.Length == 0)
						SeparatorImageUrl = bin.SeparatorImageUrl;
				}
				else if (bin.SeparatorImageUrl.Length > 0)
					SeparatorImageUrl = bin.SeparatorImageUrl;

				// Bind Target property

				if (bin.TargetField.Length > 0) {
					Target = Convert.ToString (GetBoundPropertyValue (bin.TargetField));
					if (Target.Length == 0)
						Target = bin.Target;
				}
				else if (bin.Target.Length > 0)
					Target = bin.Target;

				// Bind ToolTip property

				if (bin.ToolTipField.Length > 0) {
					ToolTip = Convert.ToString (GetBoundPropertyValue (bin.ToolTipField));
					if (ToolTip.Length == 0)
						ToolTip = bin.ToolTip;
				}
				else if (bin.ToolTip.Length > 0)
					ToolTip = bin.ToolTip;

				// Bind Value property
				string value = null;
				if (bin.ValueField.Length > 0) {
					value = Convert.ToString (GetBoundPropertyValue (bin.ValueField));
				}
				if (String.IsNullOrEmpty (value)) {
					if (bin.Value.Length > 0)
						value = bin.Value;
					else if (bin.Text.Length > 0)
						value = bin.Text;
					else
						value = String.Empty;
				}
				Value = value;

				// Bind Text property
				string text = null;
				if (bin.TextField.Length > 0) {
					text = Convert.ToString (GetBoundPropertyValue (bin.TextField));
					if (bin.FormatString.Length > 0)
						text = string.Format (bin.FormatString, text);
				}
				if (String.IsNullOrEmpty (text)) {
					if (bin.Text.Length > 0)
						text = bin.Text;
					else if (bin.Value.Length > 0)
						text = bin.Value;
					else
						text = String.Empty;
				}
				Text = text;

			}
			else {
				Text = Value = GetDefaultBoundText ();
			}

			INavigateUIData navigateUIData = hierarchyData as INavigateUIData;
			if (navigateUIData != null) {
				ToolTip = navigateUIData.Description;
				Text = navigateUIData.ToString ();
				NavigateUrl = navigateUIData.NavigateUrl;
			}
		}
Esempio n. 26
0
		internal void Bind (IHierarchyData hierarchyData)
		{
			this.hierarchyData = hierarchyData;
			dataBound = true;
			dataPath = hierarchyData.Path;
			dataItem = hierarchyData.Item;
		}
Esempio n. 27
0
        private void RecursiveDataBindInternal(IHierarchicalEnumerable enumerable, StringBuilder sb)
        {
            bool first = true;

            if (this.Site != null)
            {
                return;
            }
            foreach (object item in enumerable)
            {
                IHierarchyData data = enumerable.GetHierarchyData(item);
                if (null != data)
                {
                    PropertyDescriptorCollection props = TypeDescriptor.GetProperties(data);
                    if (props.Count > 0)
                    {
                        string title       = ((string)(props["Title"].GetValue(data)));
                        string description = ((string)(props["Description"].GetValue(data)));
                        string url         = ((string)(props["Url"].GetValue(data)));
                        string cssClass    = null;
                        bool   isPublic    = false;
                        if (item is SiteMapNode)
                        {
                            cssClass = ((SiteMapNode)(item))["cssClass"];
                            isPublic = ("true" == ((string)(((SiteMapNode)(item))["public"])));
                        }
                        string    roles    = String.Empty;
                        ArrayList roleList = ((ArrayList)(props["Roles"].GetValue(data)));
                        if (roleList.Count > 0)
                        {
                            roles = String.Join(",", ((string[])(roleList.ToArray(typeof(string)))));
                        }
                        bool resourceAuthorized = true;
                        if (resourceAuthorized)
                        {
                            if (first)
                            {
                                first = false;
                            }
                            else
                            {
                                sb.Append(",");
                            }
                            sb.AppendFormat("{{title:\"{0}\",url:\"{1}\"", BusinessRules.JavaScriptString(title), BusinessRules.JavaScriptString(url));
                            if (!(String.IsNullOrEmpty(description)))
                            {
                                sb.AppendFormat(",description:\"{0}\"", BusinessRules.JavaScriptString(description));
                            }
                            if (url == Page.Request.RawUrl)
                            {
                                sb.Append(",selected:true");
                            }
                            if (!(String.IsNullOrEmpty(cssClass)))
                            {
                                sb.AppendFormat(",cssClass:\"{0}\"", cssClass);
                            }
                            if (data.HasChildren)
                            {
                                IHierarchicalEnumerable childrenEnumerable = data.GetChildren();
                                if (null != childrenEnumerable)
                                {
                                    sb.Append(",\"children\":[");
                                    RecursiveDataBindInternal(childrenEnumerable, sb);
                                    sb.Append("]");
                                }
                            }
                            sb.Append("}");
                        }
                    }
                }
            }
        }
Esempio n. 28
0
 private void BuildMainMenu(IHierarchicalEnumerable enumerable, StringBuilder sb, int depth)
 {
     foreach (object item in enumerable)
     {
         IHierarchyData data = enumerable.GetHierarchyData(item);
         if (data != null)
         {
             PropertyDescriptorCollection props = TypeDescriptor.GetProperties(data);
             if (props.Count > 0)
             {
                 string    title       = ((string)(props["Title"].GetValue(data)));
                 string    description = ((string)(props["Description"].GetValue(data)));
                 string    url         = ((string)(props["Url"].GetValue(data)));
                 string    cssClass    = null;
                 string    roles       = null;
                 ArrayList roleList    = ((ArrayList)(props["Roles"].GetValue(data)));
                 if (roleList.Count > 0)
                 {
                     roles = String.Join(",", ((string[])(roleList.ToArray(typeof(string)))));
                 }
                 if (item is SiteMapNode)
                 {
                     cssClass = ((SiteMapNode)(item))["cssClass"];
                     if ("true" == ((SiteMapNode)(item))["public"])
                     {
                         roles = "?";
                     }
                 }
                 sb.AppendFormat("{0} {1}", new String('+', depth), title);
                 sb.AppendLine();
                 if (!(String.IsNullOrEmpty(url)))
                 {
                     sb.AppendLine(url);
                 }
                 else
                 {
                     sb.AppendLine("about:blank");
                 }
                 if (!(String.IsNullOrEmpty(description)))
                 {
                     sb.AppendFormat("description: {0}", description);
                     sb.AppendLine();
                 }
                 if (!(String.IsNullOrEmpty(roles)))
                 {
                     sb.AppendFormat("roles: {0}", roles);
                     sb.AppendLine();
                 }
                 if (!(String.IsNullOrEmpty(cssClass)))
                 {
                     sb.AppendFormat("css-class: {0}", cssClass);
                     sb.AppendLine();
                 }
                 sb.AppendLine();
                 if (data.HasChildren)
                 {
                     IHierarchicalEnumerable childrenEnumerable = data.GetChildren();
                     if (childrenEnumerable != null)
                     {
                         BuildMainMenu(childrenEnumerable, sb, (depth + 1));
                     }
                 }
             }
         }
     }
 }
Esempio n. 29
0
 public ITemplate SelectFooterTemplate(IHierarchyData hierarchyData)
 {
     return(_panelView.ValuesPanelFooterTemplate ?? _panelView.PanelFooterTemplate);
 }
Esempio n. 30
0
        internal void Bind(IHierarchyData hierarchyData)
        {
            this.hierarchyData = hierarchyData;
            DataBound          = true;
            DataPath           = hierarchyData.Path;
            dataItem           = hierarchyData.Item;

            TreeNodeBinding bin = GetBinding();

            if (bin != null)
            {
                // Bind ImageToolTip property

                if (bin.ImageToolTipField.Length > 0)
                {
                    ImageToolTip = Convert.ToString(GetBoundPropertyValue(bin.ImageToolTipField));
                    if (ImageToolTip.Length == 0)
                    {
                        ImageToolTip = bin.ImageToolTip;
                    }
                }
                else if (bin.ImageToolTip.Length > 0)
                {
                    ImageToolTip = bin.ImageToolTip;
                }

                // Bind ImageUrl property

                if (bin.ImageUrlField.Length > 0)
                {
                    ImageUrl = Convert.ToString(GetBoundPropertyValue(bin.ImageUrlField));
                    if (ImageUrl.Length == 0)
                    {
                        ImageUrl = bin.ImageUrl;
                    }
                }
                else if (bin.ImageUrl.Length > 0)
                {
                    ImageUrl = bin.ImageUrl;
                }

                // Bind NavigateUrl property

                if (bin.NavigateUrlField.Length > 0)
                {
                    NavigateUrl = Convert.ToString(GetBoundPropertyValue(bin.NavigateUrlField));
                    if (NavigateUrl.Length == 0)
                    {
                        NavigateUrl = bin.NavigateUrl;
                    }
                }
                else if (bin.NavigateUrl.Length > 0)
                {
                    NavigateUrl = bin.NavigateUrl;
                }

                // Bind PopulateOnDemand property

                if (bin.HasPropertyValue("PopulateOnDemand"))
                {
                    PopulateOnDemand = bin.PopulateOnDemand;
                }

                // Bind SelectAction property

                if (bin.HasPropertyValue("SelectAction"))
                {
                    SelectAction = bin.SelectAction;
                }

                // Bind ShowCheckBox property

                if (bin.HasPropertyValue("ShowCheckBox"))
                {
                    ShowCheckBox = bin.ShowCheckBox;
                }

                // Bind Target property

                if (bin.TargetField.Length > 0)
                {
                    Target = Convert.ToString(GetBoundPropertyValue(bin.TargetField));
                    if (Target.Length == 0)
                    {
                        Target = bin.Target;
                    }
                }
                else if (bin.Target.Length > 0)
                {
                    Target = bin.Target;
                }

                // Bind Text property
                string text = null;
                if (bin.TextField.Length > 0)
                {
                    text = Convert.ToString(GetBoundPropertyValue(bin.TextField));
                    if (bin.FormatString.Length > 0)
                    {
                        text = string.Format(bin.FormatString, text);
                    }
                }
                if (String.IsNullOrEmpty(text))
                {
                    if (bin.Text.Length > 0)
                    {
                        text = bin.Text;
                    }
                    else if (bin.Value.Length > 0)
                    {
                        text = bin.Value;
                    }
                }
                if (!String.IsNullOrEmpty(text))
                {
                    Text = text;
                }

                // Bind ToolTip property

                if (bin.ToolTipField.Length > 0)
                {
                    ToolTip = Convert.ToString(GetBoundPropertyValue(bin.ToolTipField));
                    if (ToolTip.Length == 0)
                    {
                        ToolTip = bin.ToolTip;
                    }
                }
                else if (bin.ToolTip.Length > 0)
                {
                    ToolTip = bin.ToolTip;
                }

                // Bind Value property
                string value = null;
                if (bin.ValueField.Length > 0)
                {
                    value = Convert.ToString(GetBoundPropertyValue(bin.ValueField));
                }
                if (String.IsNullOrEmpty(value))
                {
                    if (bin.Value.Length > 0)
                    {
                        value = bin.Value;
                    }
                    else if (bin.Text.Length > 0)
                    {
                        value = bin.Text;
                    }
                }
                if (!String.IsNullOrEmpty(value))
                {
                    Value = value;
                }
            }
            else
            {
                Text = Value = GetDefaultBoundText();
            }

            INavigateUIData navigateUIData = hierarchyData as INavigateUIData;

            if (navigateUIData != null)
            {
                SelectAction = TreeNodeSelectAction.None;
                Text         = navigateUIData.ToString();
                NavigateUrl  = navigateUIData.NavigateUrl;
                ToolTip      = navigateUIData.Description;
            }
        }
Esempio n. 31
0
        internal void Bind(IHierarchyData hierarchyData)
        {
            this.hierarchyData = hierarchyData;
            this.DataBound     = true;
            this.DataPath      = hierarchyData.Path;
            this.dataItem      = hierarchyData.Item;
            TreeNodeBinding binding = this.GetBinding();

            if (binding != null)
            {
                if (binding.ImageUrlField.Length > 0)
                {
                    this.ImageUrl = Convert.ToString(this.GetBoundPropertyValue(binding.ImageUrlField));
                }
                if (string.IsNullOrEmpty(this.ImageUrl) && (binding.ImageUrl.Length > 0))
                {
                    this.ImageUrl = binding.ImageUrl;
                }
                if (binding.TargetField.Length > 0)
                {
                    this.Target = Convert.ToString(this.GetBoundPropertyValue(binding.TargetField));
                    if (this.Target.Length == 0)
                    {
                        this.Target = binding.Target;
                    }
                }
                else if (binding.Target.Length > 0)
                {
                    this.Target = binding.Target;
                }
                string text = null;
                if (binding.TextField.Length > 0)
                {
                    text = Convert.ToString(this.GetBoundPropertyValue(binding.TextField));
                    if (binding.FormatString.Length > 0)
                    {
                        text = string.Format(binding.FormatString, text);
                    }
                }
                if (string.IsNullOrEmpty(text))
                {
                    if (binding.Text.Length > 0)
                    {
                        text = binding.Text;
                    }
                    else if (binding.Value.Length > 0)
                    {
                        text = binding.Value;
                    }
                }
                if (!string.IsNullOrEmpty(text))
                {
                    this.Text = text;
                }
                if (binding.ToolTipField.Length > 0)
                {
                    this.ToolTip = Convert.ToString(this.GetBoundPropertyValue(binding.ToolTipField));
                }
                if (string.IsNullOrEmpty(this.ToolTip) && (binding.ToolTip.Length > 0))
                {
                    this.ToolTip = binding.ToolTip;
                }
                string str2 = null;
                if (binding.ValueField.Length > 0)
                {
                    str2 = Convert.ToString(this.GetBoundPropertyValue(binding.ValueField));
                }
                if (string.IsNullOrEmpty(str2))
                {
                    if (binding.Value.Length > 0)
                    {
                        str2 = binding.Value;
                    }
                    else if (binding.Text.Length > 0)
                    {
                        str2 = binding.Text;
                    }
                }
                if (!string.IsNullOrEmpty(str2))
                {
                    this.Value = str2;
                }
                else
                {
                    this.Text = this.Value = this.GetDefaultBoundText();
                }
                if (binding.NavigateUrlField.Length > 0)
                {
                    this.NavigateUrl = Convert.ToString(this.GetBoundPropertyValue(binding.NavigateUrlField));
                    if (this.NavigateUrl.Length == 0)
                    {
                        this.NavigateUrl = binding.NavigateUrl;
                    }
                }
                else if (binding.NavigateUrl.Length > 0)
                {
                    this.NavigateUrl = binding.NavigateUrl;
                }
            }
            else
            {
                this.Text = this.Value;
            }
        }
Esempio n. 32
0
		internal void Bind (IHierarchyData hierarchyData)
		{
			this.hierarchyData = hierarchyData;
			DataBound = true;
			DataPath = hierarchyData.Path;
			dataItem = hierarchyData.Item;
			
			TreeNodeBinding bin = GetBinding ();
			if (bin != null) {
			
				// Bind ImageToolTip property

				if (bin.ImageToolTipField.Length > 0) {
					ImageToolTip = Convert.ToString (GetBoundPropertyValue (bin.ImageToolTipField));
					if (ImageToolTip.Length == 0)
						ImageToolTip = bin.ImageToolTip;
				} else if (bin.ImageToolTip.Length > 0)
					ImageToolTip = bin.ImageToolTip;
					
				// Bind ImageUrl property

				if (bin.ImageUrlField.Length > 0) {
					ImageUrl = Convert.ToString (GetBoundPropertyValue (bin.ImageUrlField));
					if (ImageUrl.Length == 0)
						ImageUrl = bin.ImageUrl;
				} else if (bin.ImageUrl.Length > 0)
					ImageUrl = bin.ImageUrl;
					
				// Bind NavigateUrl property

				if (bin.NavigateUrlField.Length > 0) {
					NavigateUrl = Convert.ToString (GetBoundPropertyValue (bin.NavigateUrlField));
					if (NavigateUrl.Length == 0)
						NavigateUrl = bin.NavigateUrl;
				} else if (bin.NavigateUrl.Length > 0)
					NavigateUrl = bin.NavigateUrl;
					
				// Bind PopulateOnDemand property
				
				if (bin.HasPropertyValue ("PopulateOnDemand"))
					PopulateOnDemand = bin.PopulateOnDemand;
				
				// Bind SelectAction property
					
				if (bin.HasPropertyValue ("SelectAction"))
					SelectAction = bin.SelectAction;
				
				// Bind ShowCheckBox property
					
				if (bin.HasPropertyValue ("ShowCheckBox"))
					ShowCheckBox = bin.ShowCheckBox;
					
				// Bind Target property

				if (bin.TargetField.Length > 0) {
					Target = Convert.ToString (GetBoundPropertyValue (bin.TargetField));
					if (Target.Length == 0)
						Target = bin.Target;
				} else if (bin.Target.Length > 0)
					Target = bin.Target;
					
				// Bind Text property
				string text = null;
				if (bin.TextField.Length > 0) {
					text = Convert.ToString (GetBoundPropertyValue (bin.TextField));
					if (bin.FormatString.Length > 0)
						text = string.Format (bin.FormatString, text);
				}
				if (String.IsNullOrEmpty (text)) {
					if (bin.Text.Length > 0)
						text = bin.Text;
					else if (bin.Value.Length > 0)
						text = bin.Value;
				}
				if (!String.IsNullOrEmpty (text))
					Text = text;
					
				// Bind ToolTip property

				if (bin.ToolTipField.Length > 0) {
					ToolTip = Convert.ToString (GetBoundPropertyValue (bin.ToolTipField));
					if (ToolTip.Length == 0)
						ToolTip = bin.ToolTip;
				} else if (bin.ToolTip.Length > 0)
					ToolTip = bin.ToolTip;
					
				// Bind Value property
				string value = null;
				if (bin.ValueField.Length > 0) {
					value = Convert.ToString (GetBoundPropertyValue (bin.ValueField));
				}
				if (String.IsNullOrEmpty (value)) {
					if (bin.Value.Length > 0)
						value = bin.Value;
					else if (bin.Text.Length > 0)
						value = bin.Text;
				}
				if (!String.IsNullOrEmpty (value))
					Value = value;
			} else {
				Text = Value = GetDefaultBoundText ();
			}

			INavigateUIData navigateUIData = hierarchyData as INavigateUIData;
			if (navigateUIData != null) {
				SelectAction = TreeNodeSelectAction.None;
				Text = navigateUIData.ToString ();
				NavigateUrl = navigateUIData.NavigateUrl;
				ToolTip = navigateUIData.Description;
			}
		}
Esempio n. 33
0
 public ITemplate SelectHeaderTemplate(IHierarchyData hierarchyData)
 {
     return(_panelView.ProductPanelHeaderTemplate ?? _panelView.PanelHeaderTemplate);
 }
Esempio n. 34
0
 public ITemplate SelectPanelTemplate(IHierarchyData hierarchyData)
 {
     return(_panelView.ProductsPanelTemplate);
 }
Esempio n. 35
0
 public static Dictionary<string, object> ToDictionary(IHierarchyData data)
 {
     Dictionary<string, object> result = new Dictionary<string, object>();
     if (null != data)
     {
         result.Add("Type", data.Type);
         result.Add("Path", data.Path);
         if (data.Item is XmlNode)
         {
             XmlNode nodeItem = data.Item as XmlNode;
             foreach (XmlAttribute attribute in nodeItem.Attributes)
             {
                 if ("Type" == attribute.Name) throw new ArgumentException("Invalid attribute name 'Type'. That name has a different meaning in hierachical data object");
                 if ("Path" == attribute.Name) throw new ArgumentException("Invalid attribute name 'Path'. That name has a different meaning in hierachical data object");
                 result.Add(attribute.Name, attribute.Value);
             }
         }
     }
     return result;
 }