private void FillLeafDisplayList(DisplayList dl, IReadOnlyFRPC dataPaths)
        {
            bool isLeafNode = IsLeaf;

            if (isLeafNode)
            {
                int pathIdx = dataPaths.TryGetIndexFromPath(LeafPath);
                if (pathIdx != -1)
                {
                    dl.Cmds.Add(new DisplayListCmd(dl.Items.Count, 1, this));
                    dl.Items.Add(new ListItem(false, pathIdx, DisplayScale));
                }
            }
            else if (IsCollapsed)
            {
                int firstItem = dl.Items.Count;
                FillListItems(dl.Items, dataPaths);

                int numItems = dl.Items.Count - firstItem;
                if (numItems > 0)
                {
                    dl.Cmds.Add(new DisplayListCmd(firstItem, numItems, this));
                }
            }
            else
            {
                foreach (ProfilerRDI childRdi in Children)
                {
                    if (childRdi.Displayed)
                    {
                        childRdi.FillLeafDisplayList(dl, dataPaths);
                    }
                }
            }
        }
        private void FillNonLeafValueList(ValueList vl, IReadOnlyFRPC dataPaths, IReadOnlyFRPC viewPaths, IEnumerable <string> restrictToViewPaths)
        {
            if (!IsLeaf && (restrictToViewPaths == null || restrictToViewPaths.Contains(LeafPath)))
            {
                int leafViewPathIdx = viewPaths.TryGetIndexFromPath(LeafPath);
                if (leafViewPathIdx != -1)                      // if the LeafPath isn't present in viewPaths, none of the children will be either
                {
                    if (!IsCollapsed)
                    {
                        // Make sure that all non-leaf children are computed first
                        foreach (ProfilerRDI childRdi in Children)
                        {
                            if (!childRdi.IsLeaf)
                            {
                                childRdi.FillNonLeafValueList(vl, dataPaths, viewPaths, restrictToViewPaths);
                            }
                        }

                        // Produce a cmd that accumulates all children - their values should now be valid
                        int firstItem = vl.Items.Count;
                        {
                            foreach (ProfilerRDI childRdi in Children)
                            {
                                if (childRdi.Displayed)
                                {
                                    IReadOnlyFRPC paths   = childRdi.IsLeaf ? dataPaths : viewPaths;
                                    int           pathIdx = paths.TryGetIndexFromPath(childRdi.LeafPath);
                                    if (pathIdx != -1)
                                    {
                                        vl.Items.Add(new ListItem(!childRdi.IsLeaf, pathIdx, childRdi.DisplayScale));
                                    }
                                }
                            }
                        }

                        int numItems = vl.Items.Count - firstItem;
                        vl.Cmds.Add(new ValueListCmd(firstItem, numItems, leafViewPathIdx));
                    }
                    else
                    {
                        int firstItem = vl.Items.Count;
                        FillListItems(vl.Items, dataPaths);

                        int numItems = vl.Items.Count - firstItem;
                        vl.Cmds.Add(new ValueListCmd(firstItem, numItems, leafViewPathIdx));
                    }
                }
            }
        }
 private void FillListItems(List <ListItem> items, IReadOnlyFRPC dataPaths)
 {
     if (IsLeaf)
     {
         int pathIdx = dataPaths.TryGetIndexFromPath(LeafPath);
         if (pathIdx != -1)
         {
             items.Add(new ListItem(false, pathIdx, DisplayScale));
         }
     }
     else
     {
         foreach (ProfilerRDI child in Children)
         {
             if (child.Displayed)
             {
                 child.FillListItems(items, dataPaths);
             }
         }
     }
 }