Exemple #1
0
        public static void Fill(TreeEntry entry, double chance)
        {
            double f;

            while ((f = r.NextDouble()) < chance)
            {
                var e = new TextTreeEntry(f.ToString());
                entry.Add(e);
                Fill(e, chance * chance);
            }
        }
Exemple #2
0
        void Discover(TreeEntry entry, DirectoryInfo di, int level, int maxlevel)
        {
            if (level > maxlevel)
            {
                return;
            }

            var child = new TextTreeEntry(di.Name);

            entry.Add(child);

            foreach (var dir in di.GetDirectories())
            {
                Discover(child, dir, level + 1, maxlevel);
            }
        }
Exemple #3
0
        public int DrawGrid(int x, int y, int w, TreeEntry entry)
        {
            switch (entry.Count)
            {
            case 0:
                return(entry.Height);

            case 1:
                Set(x, y + 1, ACS.LLCORNER);
                Set(x + 1, y + 1, '-');
                return(DrawGrid(x + Offset, y + 1, w, entry[0]) + entry.Height);

            default:
                int height = 0;
                int i = 0, c = entry.Count - 1;
                foreach (TreeEntry child in entry)
                {
                    bool first  = i == 0;
                    bool last   = i == c;
                    bool middle = !first && !last;
                    if (first || middle)
                    {
                        Set(x, y + height + 1, ACS.LTEE);
                        Set(x + 1, y + height + 1, '-');
                    }
                    else
                    {
                        Set(x, y + height + 1, ACS.LLCORNER);
                        Set(x + 1, y + height + 1, '-');
                    }

                    int childHeight = DrawGrid(x + Offset, y + height + child.Height, w - 1, child);

                    if (!last)
                    {
                        for (int j = 1; j < childHeight; j++)
                        {
                            Set(x, y + height + j + 1, ACS.VLINE);
                        }
                    }

                    height += childHeight;
                    i++;
                }
                return(height + entry.Height);
            }
        }
Exemple #4
0
 public TreeView()
 {
     Root = new TreeEntry();
 }