Пример #1
0
        public bool HasChildren(object parent)
        {
            MetaDataNameValue item = (MetaDataNameValue)parent;

            if (item.Node.Count == 0 || item.Node.NodeType == MetaDataTreeNode.Type.PROPERTY)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Пример #2
0
 public System.Collections.IEnumerable GetChildren(object parent)
 {
     if (parent == null)
     {
         if (root == null)
         {
             return(new List <MetaDataTreeNode>());
         }
         else
         {
             return(nodeChildrenToPathValue(root));
         }
     }
     else
     {
         MetaDataNameValue item = (MetaDataNameValue)parent;
         return(nodeChildrenToPathValue(item.Node));
     }
 }
Пример #3
0
        List <MetaDataNameValue> nodeChildrenToPathValue(MetaDataTreeNode node)
        {
            List <MetaDataNameValue> items = new List <MetaDataNameValue>();

            foreach (MetaDataTreeNode n in node.Child)
            {
                MetaDataNameValue item = new MetaDataNameValue();
                item.Name     = n.ToString();
                item.Node     = n;
                item.IconPath = "pack://application:,,,/Resources/Icons/prop.ico";

                if (n.NodeType == MetaDataTreeNode.Type.NAMESPACE)
                {
                    item.IconPath = "pack://application:,,,/Resources/Icons/namespace.ico";
                    item.NodeType = "Namespace";
                }
                else if (n.NodeType == MetaDataTreeNode.Type.ARRAY)
                {
                    item.IconPath = "pack://application:,,,/Resources/Icons/array.ico";
                    item.NodeType = "Array";
                }
                else if (n.NodeType == MetaDataTreeNode.Type.PROPERTY)
                {
                    MetaDataTreeProperty prop = (MetaDataTreeProperty)n;

                    if (String.IsNullOrEmpty(prop.Value))
                    {
                        continue;
                    }

                    item.Name     = FormatMetaData.formatPropertyName(prop.ToString());
                    item.Value    = FormatMetaData.formatPropertyValue(prop.Path, prop.Value);
                    item.NodeType = "Property";
                }
                else if (n.NodeType == MetaDataTreeNode.Type.VALUE)
                {
                    if (n.Parent.NodeType == MetaDataTreeNode.Type.PROPERTY)
                    {
                        continue;
                    }

                    item.Name     = "";
                    item.Value    = FormatMetaData.formatPropertyValue(n.Path, n.Data);
                    item.IconPath = "pack://application:,,,/Resources/Icons/constprop.ico";
                    item.NodeType = "Value";
                }
                else if (n.NodeType == MetaDataTreeNode.Type.LANGUAGE)
                {
                    item.Name     = "Language";
                    item.Value    = n.ToString();
                    item.NodeType = "Language";
                    item.IconPath = "pack://application:,,,/Resources/Icons/language.ico";
                }

                if (n.Parent != null && n.Parent.NodeType == MetaDataTreeNode.Type.ARRAY)
                {
                    MetaDataTreeArray arr = (MetaDataTreeArray)(n.Parent);

                    item.Value    = FormatMetaData.formatPropertyValue(n.Path, n.Data);
                    item.IconPath = "pack://application:,,,/Resources/Icons/constprop.ico";
                    item.NodeType = "Value";

                    int i = arr.getChildIndex(n);

                    item.Name = "[" + Convert.ToString(i) + "] " + item.Name;
                }

                items.Add(item);
            }

            return(items);
        }
Пример #4
0
        List<MetaDataNameValue> nodeChildrenToPathValue(MetaDataTreeNode node)
        {
                   
            List<MetaDataNameValue> items = new List<MetaDataNameValue>();  

            foreach(MetaDataTreeNode n in node.Child) {

                MetaDataNameValue item = new MetaDataNameValue();
                item.Name = n.ToString();
                item.Node = n;
                item.IconPath = "pack://application:,,,/Resources/Icons/prop.ico";

                if (n.NodeType == MetaDataTreeNode.Type.NAMESPACE)
                {
                    item.IconPath = "pack://application:,,,/Resources/Icons/namespace.ico";
                    item.NodeType = "Namespace";
                }
                else if (n.NodeType == MetaDataTreeNode.Type.ARRAY)
                {
                    item.IconPath = "pack://application:,,,/Resources/Icons/array.ico";
                    item.NodeType = "Array";
                }
                else if (n.NodeType == MetaDataTreeNode.Type.PROPERTY)
                {
                    MetaDataTreeProperty prop = (MetaDataTreeProperty)n;

                    if (String.IsNullOrEmpty(prop.Value)) continue;

                    item.Name = FormatMetaData.formatPropertyName(prop.ToString());
                    item.Value = FormatMetaData.formatPropertyValue(prop.Path, prop.Value);
                    item.NodeType = "Property";

                }
                else if (n.NodeType == MetaDataTreeNode.Type.VALUE)
                {

                    if (n.Parent.NodeType == MetaDataTreeNode.Type.PROPERTY) continue;

                    item.Name = "";
                    item.Value = FormatMetaData.formatPropertyValue(n.Path, n.Data);
                    item.IconPath = "pack://application:,,,/Resources/Icons/constprop.ico";
                    item.NodeType = "Value";

                }
                else if (n.NodeType == MetaDataTreeNode.Type.LANGUAGE)
                {
                    item.Name = "Language";
                    item.Value = n.ToString();
                    item.NodeType = "Language";
                    item.IconPath = "pack://application:,,,/Resources/Icons/language.ico";
                }

                if(n.Parent != null && n.Parent.NodeType == MetaDataTreeNode.Type.ARRAY) {

		            MetaDataTreeArray arr = (MetaDataTreeArray)(n.Parent);

                    item.Value = FormatMetaData.formatPropertyValue(n.Path, n.Data);
                    item.IconPath = "pack://application:,,,/Resources/Icons/constprop.ico";
                    item.NodeType = "Value";

		            int i = arr.getChildIndex(n);

		            item.Name = "[" + Convert.ToString(i) + "] " + item.Name;
	            }

                items.Add(item);
            }

            return(items);

        }