Exemple #1
0
        NodeInfo CreateViewNode(IView view, NodesCollectionInfo collectionToAddViewNode, IInspectedObject modelNode, int level, List <NodeInfo> nodesToCollapse)
        {
            string nodeText = modelNode.DisplayName;

            if (modelNode.Comment != "")
            {
                nodeText += " (" + modelNode.Comment + ")";
            }

            bool createCollapsed    = false;
            bool createLazilyLoaded = false;

            if (level < 5)
            {
                if (OnNodeCreated != null)
                {
                    var args = new NodeCreatedEventArgs()
                    {
                        NodeObject = VisualizerNode.FromObject(modelNode)
                    };
                    OnNodeCreated(this, args);
                    createCollapsed    = args.CreateCollapsed.GetValueOrDefault(createCollapsed);
                    createLazilyLoaded = args.CreateLazilyLoaded.GetValueOrDefault(createLazilyLoaded);
                }
                if (createLazilyLoaded && !view.TreeSupportsLoadingOnExpansion)
                {
                    createLazilyLoaded = false;
                }
            }

            var viewNode = view.CreateNode(nodeText, modelNode, collectionToAddViewNode);

            if (createLazilyLoaded)
            {
                view.CreateNode(lazyLoadTag, lazyLoadTag, viewNode.ChildrenNodesCollection);
            }
            else
            {
                foreach (var child in modelNode.Children)
                {
                    CreateViewNode(view, viewNode.ChildrenNodesCollection, child, level + 1, nodesToCollapse);
                }
            }
            if (createCollapsed)
            {
                nodesToCollapse.Add(viewNode);
            }
            return(viewNode);
        }
            public void SetInitialProps(EventHandler <NodeCreatedEventArgs> nodeCreationHandler)
            {
                bool createCollapsed = false;

                if (level < 5)                 // todo: why 5?
                {
                    if (nodeCreationHandler != null)
                    {
                        var args = new NodeCreatedEventArgs()
                        {
                            NodeObject = this
                        };
                        nodeCreationHandler(this, args);
                        createCollapsed = args.CreateCollapsed.GetValueOrDefault(createCollapsed);
                    }
                }
                expanded = !createCollapsed;
                children.ForEach(c => c.SetInitialProps(nodeCreationHandler));
            }