예제 #1
0
        private void AddChildren(Thing t, TreeViewItem tvi, int depth)
        {
            List <Thing> theChildren;

            if ((bool)checkBoxSort.IsChecked)
            {
                theChildren = t.Children.OrderByDescending(x => x.useCount).ToList();
            }
            else
            {
                theChildren = t.Children;
            }
            for (int i = 0; i < theChildren.Count; i++)
            {
                Thing  child  = theChildren[i];
                string header = child.Label + ":" + child.useCount;
                if (child.References.Count > 0)
                {
                    header += " (";
                    ModuleUKS parent = (ModuleUKS)base.ParentModule;
                    Thing     best   = parent.FindBestReference(child);
                    foreach (Link L in child.References)
                    {
                        if (L.T == best)
                        {
                            header += "*";
                        }
                        if (L.weight < 0)
                        {
                            header += "-";
                        }
                        header += L.T.Label + ", ";
                    }
                    header  = header.Substring(0, header.Length - 2);
                    header += ")";
                }
                if (child.V != null)
                {
                    if (child.V is int iVal)
                    {
                        header += " : " + iVal.ToString("X");
                    }
                    else
                    {
                        header += " : " + child.V.ToString();
                    }
                }
                TreeViewItem tviChild = new TreeViewItem {
                    Header = header
                };
                if (expandedItems.Contains(LeftOfColon(header)))
                {
                    tviChild.IsExpanded = true;
                }
                tvi.Items.Add(tviChild);
                tviChild.MouseRightButtonDown += Tvi_MouseRightButtonDown;
                if (depth < maxDepth)
                {
                    AddChildren(child, tviChild, depth + 1);
                    AddReferences(child, tviChild);
                    AddReferencedBy(child, tviChild);
                }
            }
        }
예제 #2
0
        private void AddChildren(Thing t, TreeViewItem tvi, int depth, string parentLabel)
        {
            if (totalItemCount > 3000)
            {
                return;
            }

            IList <Thing> theChildren;

            if ((bool)checkBoxSort.IsChecked)
            {
                theChildren = t.Children.OrderByDescending(x => x.useCount).ToList();
            }
            else
            {
                theChildren = t.Children;
            }

            for (int i = 0; i < theChildren.Count; i++)
            {
                Thing  child  = theChildren[i];
                string header = child.Label + ":" + child.useCount;
                if (child.References.Count > 0)
                {
                    header += " (";
                    ModuleUKS   parent = (ModuleUKS)base.ParentModule;
                    Thing       best   = parent.FindBestReference(child);
                    List <Link> refs   = child.References.OrderBy(x => - x.Value1).ToList();
                    for (int j = 0; j < refs.Count; j++)// child.References.Count; j++)// each (Link L in child.References)
                    {
                        if (header.Length - header.LastIndexOf('\n') > charsPerLine - 7 * depth)
                        {
                            header += "\n";
                        }
                        Link l = refs[j];// child.References[j];
                        if (l is Relationship r)
                        {
                            header += r.relationshipType.Label + "->" + r.T.Label + ", ";
                        }
                        else
                        {
                            if (l.T == best)
                            {
                                header += "*";
                            }
                            if (l.weight < 0)
                            {
                                header += "-";
                            }
                            header += l.T.Label + ", ";
                        }
                    }
                    //header = header.Substring(0, header.Length - 2);
                    header += ")";
                }
                if (child.V != null)
                {
                    if (child.V is int iVal)
                    {
                        header += " : " + iVal.ToString("X");
                    }
                    else
                    {
                        header += " : " + child.V.ToString();
                    }
                }
                TreeViewItem tviChild = new TreeViewItem {
                    Header = header
                };
                if (child.lastFired == MainWindow.theNeuronArray.Generation)
                {
                    tviChild.Background = new SolidColorBrush(Colors.LightGreen);
                }

                if (expandedItems.Contains("|" + parentLabel + "|" + LeftOfColon(header)))
                {
                    tviChild.IsExpanded = true;
                }
                tvi.Items.Add(tviChild);
                totalItemCount++;
                tviChild.MouseRightButtonDown += Tvi_MouseRightButtonDown;
                if (depth < maxDepth)
                {
                    AddChildren(child, tviChild, depth + 1, parentLabel + "|" + child.Label);
                    AddReferences(child, tviChild, parentLabel);
                    AddReferencedBy(child, tviChild, parentLabel);
                }
            }
        }