Example #1
0
        public System.Collections.IEnumerable GetChildren(Aga.Controls.Tree.TreePath treePath)
        {
            _NodeModel node = null;

            if (treePath.IsEmpty())
            {
                if (m_rootNode != null)
                {
                    node = m_rootNode;
                }
            }
            else
            {
                node = (_NodeModel)treePath.LastNode;
            }

            if (node != null)
            {
                if (node.IsStructure)
                {
                    // scan members
                    var type = (BlendStructureType)node.m_value.Type;
                    foreach (var decl in type.MemberDecls)
                    {
                        var value     = node.m_value.GetMember(decl.Name);
                        var childNode = new _NodeModel(decl.Name, value);
                        yield return(childNode);
                    }
                }
                else if (node.IsPointer)
                {
                    // dereference
                    var address     = node.m_value.GetRawValue <BlendAddress>();
                    var pointerType = (BlendPointerType)node.m_value.Type;
                    var baseType    = pointerType.BaseType;
                    if (address.CanDereference(baseType))
                    {
                        List <BlendValueCapsule> result = null;
                        try
                        {
                            if (baseType.Equals(BlendPrimitiveType.Void()))
                            {
                                // void pointer
                                result = address.DereferenceAll();
                            }
                            else
                            {
                                result = address.DereferenceAll(baseType);
                            }
                        }
                        catch (BlenderException e)
                        {
                            Dialog.ShowError(e);
                            yield break;
                        }

                        if (result.Count == 1)
                        {
                            var childNode = new _NodeModel("*" + node.Name, result[0]);
                            yield return(childNode);
                        }
                        else
                        {
                            // If the number of dereferenced objects is over 1, we show it as an array.
                            for (int i = 0; i < result.Count; ++i)
                            {
                                var value     = result[i];
                                var childNode = new _NodeModel(node.Name + "[" + i + "]", value);
                                yield return(childNode);
                            }
                        }
                    }
                }
                else if (node.IsArray)
                {
                    var arrayType  = (BlendArrayType)node.m_value.Type;
                    int arrayCount = arrayType.ArrayDimension;
                    switch (arrayCount)
                    {
                    case 1:
                        for (int i = 0; i < arrayType.GetLength(0); ++i)
                        {
                            var value     = node.m_value.GetAt(i);
                            var childNode = new _NodeModel(node.Name + "[" + i + "]", value);
                            yield return(childNode);
                        }
                        break;


                    case 2:
                        for (int i = 0; i < arrayType.GetLength(0); ++i)
                        {
                            for (int j = 0; j < arrayType.GetLength(1); ++j)
                            {
                                var value     = node.m_value.GetAt(i, j);
                                var childNode = new _NodeModel(node.Name + "[" + i + "]" + "[" + j + "]", value);
                                yield return(childNode);
                            }
                        }
                        break;
                    }
                }
            }

            yield break;
        }
Example #2
0
 public void _Attach(BlendValueCapsule value)
 {
     m_rootNode = new _NodeModel("ROOT", value);
 }