Exemplo n.º 1
0
 public void DataBind(Library.Node <string, Library.Accessor> node)
 {
     foreach (Library.Node <string, Library.Accessor> subNode in node.SubNodes)
     {
         TreeNode tn = this.treeView1.Nodes.Add(subNode.NodeValue);
         tn.Tag = subNode;
         this.DataBind(tn, subNode);
     }
 }
 private void btnCreate_Click(object sender, EventArgs e)
 {
     Library.Node <string, Library.Accessor> rootFolder    = Library.Project.CurrentProject.Hierarchy.Find(Library.Project.FoldersName);
     Library.Node <string, Library.Accessor> currentFolder = rootFolder;
     CommonDirectories.ConfigDirectories.AddFolder(Library.Project.CurrentProject.Title, this.textBox1.Text);
     string[] list = this.textBox1.Text.Split('/');
     currentFolder.Find(list);
     this.DialogResult = System.Windows.Forms.DialogResult.OK;
     this.Close();
     this.UnregisterControls(ref this.localeComponentId);
 }
        public static ListConverter MakeUXhierarchyProject(Library.Project p, Library.Node <string, Library.Accessor> node)
        {
            ListConverter listConverter = new ListConverter();

            listConverter.Add(() =>
            {
                List <HashConverter> list = new List <HashConverter>();
                list.Add(HashConverter.HierarchyItems(p, node));
                return(list);
            });
            return(listConverter);
        }
Exemplo n.º 4
0
 private void DataBind(TreeNode parent, Library.Node <string, Library.Accessor> node)
 {
     foreach (Library.Node <string, Library.Accessor> subNode in node.SubNodes)
     {
         if (subNode.NodeValue != Library.Project.FoldersName)
         {
             TreeNode tn = parent.Nodes.Add(subNode.NodeValue);
             tn.Tag = subNode;
             this.DataBind(tn, subNode);
         }
     }
     foreach (Library.Leaf <Library.Accessor> subNode in node.Elements)
     {
         dynamic  obj = subNode.Object.GetObject(this.Current);
         TreeNode tn  = parent.Nodes.Add(Form1.StandardTitle(obj.ElementTitle));
         tn.Tag     = subNode;
         tn.Checked = subNode.IsSelected;
     }
 }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Library.Node <string> root    = new Library.Node <string>(null, "I am Root.");
            Library.Node <string> child1  = new Library.Node <string>(root, "This is the first child of root.");
            Library.Node <string> child11 = new Library.Node <string>(child1, "This is the first child of child1.");

            Console.WriteLine($"Node child1 of guid {child1.Id} and of value \"{child1.Value}\" has a depth of {child1.Depth} and its parent has a guid of {child1.Parent.Id} and a value of \"{child1.Parent.Value}\".");
            Console.WriteLine($"Node child11 of guid {child11.Id} and of value \"{child11.Value}\" has a depth of {child11.Depth} and its parent has a guid of {child11.Parent.Id} and a value of \"{child11.Parent.Value}\".");

            Console.WriteLine($"Node root equal to parent of child1? {root.Equals(child1.Parent)}");           // True
            Console.WriteLine($"Node root equal to parent of child11? {root.Equals(child11.Parent)}");         // False
            Console.WriteLine($"Node child1 equal to first child of root? {child1.Equals(root.Children[0])}"); // True
            Console.WriteLine($"Is child11 among child1's children? {child1.Children.Contains(child11)}");     // True
            Console.WriteLine($"Is child11's parent listed as child1? {child11.Parent.Equals(child1)}");       //True

            Console.WriteLine($"Trying to find child11 through GUID");
            Console.WriteLine($"Is child11 somewhere inside root's tree? {root.FindTraversing(child11.Id).Equals(child11)}"); //True

            Console.WriteLine($"Trying to find child11 through node detection");
            Console.WriteLine($"Is child11 somewhere inside root's tree? {root.FindTraversing(child11).Equals(child11)}"); //True

            Library.Node <string> child2 = new Library.Node <string>(root, "This is the second child of root.");
            Library.Node <string> child3 = new Library.Node <string>(root, "This is the third child of root.");

            Library.Node <string> child21 = new Library.Node <string>(child2, "This is the first child of child2.");
            Library.Node <string> child22 = new Library.Node <string>(child2, "This is the second child of child2.");

            Library.Node <string> child221 = new Library.Node <string>(child22, "This is the first child of child22.");

            Console.WriteLine($"Displaying root's tree:");
            Console.WriteLine(root);

            Console.WriteLine("Removal of child11 as child1's child through GUID");
            child1.RemoveChildNode(child11.Id);
            Console.WriteLine($"Is child11 still among child1's children? {child1.Children.Contains(child11)}"); // False
            Console.WriteLine($"Is child11 listed as not having a parent? {child11.Parent == null}");            //True

            Console.WriteLine("Removal of child1 as root's child through node detection");
            root.RemoveChildNode(child1);
            Console.WriteLine($"Is child1 still among root's children? {root.Children.Contains(child1)}"); // False
            Console.WriteLine($"Is child1 listed as not having a parent? {child1.Parent == null}");        //True
        }
        public static HashConverter HierarchyItems(Library.Project p, Library.Node <string, Library.Accessor> node)
        {
            HashConverter hash = new HashConverter();

            if (node.Elements.Count() > 0)
            {
                foreach (Library.Leaf <Library.Accessor> leaf in node.Elements)
                {
                    dynamic x = leaf.Object.GetObject(p);
                    hash.Set(x.Unique, x.Name);
                }
            }
            else if (node.SubNodes.Count() > 0)
            {
                uint index = 0;
                foreach (Library.Node <string, Library.Accessor> sub in node.SubNodes)
                {
                    hash.Set("index." + index.ToString(), sub.NodeValue);
                    ++index;
                }
            }
            return(hash);
        }
Exemplo n.º 7
0
        private bool HasSelectedChildren(Library.Node <string, Library.Accessor> current)
        {
            bool atLeastOneSelected = current.IsSelected;

            if (!atLeastOneSelected)
            {
                foreach (Library.Leaf <Library.Accessor> sub in current.Elements)
                {
                    if (sub.IsSelected)
                    {
                        return(true);
                    }
                }
                foreach (Library.Node <string, Library.Accessor> sub in current.SubNodes)
                {
                    atLeastOneSelected = atLeastOneSelected || this.HasSelectedChildren(sub);
                    if (atLeastOneSelected)
                    {
                        return(atLeastOneSelected);
                    }
                }
            }
            return(atLeastOneSelected);
        }
        public UXFramework.UXTree CreateTreeView(uint index, Library.Project p, Library.Node <string, Library.Accessor> projectTree)
        {
            Marshalling.MarshallingHash hash;
            List <UXFramework.UXRow>    subtree = new List <UXFramework.UXRow>();

            foreach (dynamic node in projectTree.Elements)
            {
                hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () =>
                {
                    return(new Dictionary <string, dynamic>()
                    {
                        { "Width", 20 },
                        { "Height", 25 },
                        { "Constraint-Width", "FIXED" },
                        { "Constraint-Height", "FIXED" },
                        { "ImageWidth", 16 },
                        { "ImageHeight", 16 }
                    });
                });
                UXFramework.UXBox          box1 = UXFramework.Creation.CreateBox(null, 16, 16);
                UXFramework.UXImage        im2  = UXFramework.Creation.CreateImage(hash, "image", "left.png");
                UXFramework.UXReadOnlyText ro   = UXFramework.Creation.CreateReadOnlyText(null, "text", node.NodeValue);

                hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () =>
                {
                    return(new Dictionary <string, dynamic>()
                    {
                        { "Width", 32 },
                        { "Height", 25 },
                        { "Constraint-Width", "FIXED" },
                        { "Constraint-Height", "FIXED" },
                        { "align", "left" },
                        { "Border", "2px solid Blue" }
                    });
                });
                UXFramework.UXCell cLeaf1 = UXFramework.Creation.CreateCell(hash, box1);
                UXFramework.UXCell cLeaf3 = UXFramework.Creation.CreateCell(hash, im2);
                hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () =>
                {
                    return(new Dictionary <string, dynamic>()
                    {
                        { "Height", 25 },
                        { "Constraint-Height", "FIXED" },
                        { "align", "left" },
                    });
                });
                UXFramework.UXCell cLeaf2 = UXFramework.Creation.CreateCell(hash, ro);
                hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () =>
                {
                    return(new Dictionary <string, dynamic>()
                    {
                        { "IsSelectable", true },
                        { "Background-Selectable", "#0B5395" },
                        { "Height", 25 },
                        { "Constraint-Height", "FIXED" },
                    });
                });

                UXFramework.UXRow row = UXFramework.Creation.CreateRow(3, hash, cLeaf1, cLeaf2, cLeaf3);
                row.SetUpdate(x =>
                {
                    Library.Node <string, Library.Accessor> n = x.GetProperty("ProjectRef").Value;
                    n.IsSelected = true;
                    currentNode  = n;
                    this.OpenProject();
                });
                subtree.Add(row);
            }

            if (projectTree.IsSelected)
            {
                foreach (Library.Node <string, Library.Accessor> sub in projectTree.SubNodes)
                {
                    hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () =>
                    {
                        return(new Dictionary <string, dynamic>()
                        {
                            { "Width", 20 },
                            { "Height", 25 },
                            { "Constraint-Width", "FIXED" },
                            { "Constraint-Height", "FIXED" },
                            { "ImageWidth", 16 },
                            { "ImageHeight", 16 }
                        });
                    });
                    UXFramework.UXReadOnlyText ro1 = UXFramework.Creation.CreateReadOnlyText(hash, "text", "+");
                    UXFramework.UXImage        im2 = UXFramework.Creation.CreateImage(hash, "image", "left.png");
                    UXFramework.UXReadOnlyText ro  = UXFramework.Creation.CreateReadOnlyText(null, "text", sub.NodeValue);

                    hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () =>
                    {
                        return(new Dictionary <string, dynamic>()
                        {
                            { "Width", 32 },
                            { "Height", 25 },
                            { "Constraint-Width", "FIXED" },
                            { "Constraint-Height", "FIXED" },
                            { "Border", "2px solid Blue" }
                        });
                    });
                    UXFramework.UXCell cNode1 = UXFramework.Creation.CreateCell(hash, ro1);
                    UXFramework.UXCell cNode3 = UXFramework.Creation.CreateCell(hash, im2);
                    hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () =>
                    {
                        return(new Dictionary <string, dynamic>()
                        {
                            { "Height", 25 },
                            { "Constraint-Height", "FIXED" },
                            { "Disposition", "LEFT_MIDDLE" },
                            { "Border", "2px solid Blue" }
                        });
                    });
                    UXFramework.UXCell cNode2 = UXFramework.Creation.CreateCell(hash, ro);
                    hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () =>
                    {
                        return(new Dictionary <string, dynamic>()
                        {
                            { "IsSelectable", true },
                            { "Background-Selectable", "#0B5395" },
                            { "Height", 25 },
                            { "Constraint-Height", "FIXED" },
                        });
                    });
                    UXFramework.UXRow row = UXFramework.Creation.CreateRow(3, hash, cNode1, cNode2, cNode3);

                    subtree.Add(row);
                }
            }

            hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () =>
            {
                return(new Dictionary <string, dynamic>()
                {
                    { "Width", 20 },
                    { "Height", 25 },
                    { "Constraint-Width", "FIXED" },
                    { "Constraint-Height", "FIXED" },
                });
            });

            UXFramework.UXReadOnlyText ro2;
            if (projectTree.SubNodes.Count() > 0)
            {
                if (projectTree.IsSelected)
                {
                    ro2 = UXFramework.Creation.CreateReadOnlyText(hash, "text", "-");
                }
                else
                {
                    ro2 = UXFramework.Creation.CreateReadOnlyText(hash, "text", "+");
                }
            }
            else
            {
                ro2 = UXFramework.Creation.CreateReadOnlyText(hash, "text", "&nbsp;");
            }
            UXFramework.UXImage image2 = UXFramework.Creation.CreateImage(hash, "image", "left.png");

            hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () =>
            {
                return(new Dictionary <string, dynamic>()
                {
                    { "Width", 32 },
                    { "Height", 25 },
                    { "Constraint-Width", "FIXED" },
                    { "Constraint-Height", "FIXED" },
                    { "Border", "2px solid Blue" }
                });
            });
            UXFramework.UXCell c3 = UXFramework.Creation.CreateCell(hash, ro2);
            UXFramework.UXCell c4 = UXFramework.Creation.CreateCell(hash, image2);
            hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () =>
            {
                return(new Dictionary <string, dynamic>()
                {
                    { "Height", 25 },
                    { "Constraint-Height", "FIXED" },
                });
            });
            UXFramework.UXReadOnlyText roText = UXFramework.Creation.CreateReadOnlyText(hash, "text", projectTree.NodeValue);
            hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () =>
            {
                return(new Dictionary <string, dynamic>()
                {
                    { "Height", 25 },
                    { "Constraint-Height", "FIXED" },
                    { "Border", "2px solid Blue" },
                    { "Disposition", "LEFT_MIDDLE" },
                });
            });
            UXFramework.UXCell c5 = UXFramework.Creation.CreateCell(hash, roText);

            hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () =>
            {
                return(new Dictionary <string, dynamic>()
                {
                    { "Id", "row" + index.ToString() },
                    { "IsSelectable", true },
                    { "IsClickable", true },
                    { "ProjectRef", projectTree },
                    { "Background-Selectable", "#0B5395" },
                    { "Background-Clickable", "#C8E3FB" },
                    { "Height", 25 },
                    { "Constraint-Height", "FIXED" },
                    { "Disposition", "LEFT_TOP" },
                    { "align", "left" },
                    { "valign", "top" }
                });
            });

            UXFramework.UXRow first = UXFramework.Creation.CreateRow(3, hash, c3, c5, c4);
            hash = Marshalling.MarshallingHash.CreateMarshalling("hash", () =>
            {
                return(new Dictionary <string, dynamic>()
                {
                    { "Disposition", "LEFT_TOP" },
                    { "align", "left" },
                    { "valign", "top" },
                    { "Width", 220 },
                    { "Constraint-Width", "FIXED" },
                    { "ColumnCount", 3 },
                    { "LineCount", subtree.Count() + 1 },
                });
            });

            UXFramework.UXTree tree = UXFramework.Creation.CreateTree(hash, "tree", first, subtree.ToArray());

            return(tree);
        }