Esempio n. 1
0
 private int recursiveComputeLevel(Node node)
 {
     if (node.parent != null)
         return recursiveComputeLevel(node.Parent) + 1;
     else
         return 0;
 }
Esempio n. 2
0
 public StructureNodeInfo(Node nod, StructureDrawing structureDrawing, Rectangle r)
 {
     this.structureDrawing = structureDrawing;
     this.boundingRectangle = r;
     this.nod = nod;
 }
Esempio n. 3
0
 public Node AddNode(Node nod)
 {
     this.Nodes.Add(nod);
     nod.parent = this;
     asoc.Add(nod.Text, nod);
     return nod;
 }
Esempio n. 4
0
        void MainFormLoad(object sender, EventArgs e)
        {
            Image intImg = Image.FromFile("diamond.png");
            Image tImg = Image.FromFile("table.png");
            const int k = 5;
            Random r = new Random(255);
            try {
                for (int i = 0; i < k; i++) {
                    Structure di = new Structure(diagramContainer1, "ITEM" + i.ToString());
                    di.TitleImage = tImg;
                    Node cols = new Node("Columns", di);
                    cols.AddNode(new Node("id", true, intImg, di));
                    cols.AddNode(new Node("type", true, intImg, di));
                    cols.AddNode(new Node("name", di));
                    cols.AddNode(new Node("surname", di)).AddNode(new Node("child1", di)).AddNode(new Node("child2", di));
                    cols.AddNode(new Node("key", di));
                    cols.AddNode(new Node("anotherKey", di));
                    cols.AddNode(new Node("valid", di)).AddNode(new Node("child3", di)).AddNode(new Node("child4", di));
                    di.AddNode(cols);
                    di.AddOnDiagram(diagramContainer1, Color.FromArgb(r.Next(255), r.Next(255), r.Next(255)));
                    di.Drawing.Location = new Point(r.Next(300), r.Next(300));
                }
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
            for (int i = 0; i < k; i++) {

                Color c = Color.FromArgb(r.Next(255), r.Next(255), r.Next(255));
                int x = r.Next(k);
                int y = r.Next(k);
                if (x != y) {
                    diagramContainer1.AddLink(diagramContainer1.DiagramItems[x], diagramContainer1.DiagramItems[y]);
                }
            }
            diagramContainer1.Invalidate();

            CustomItem customItem = new CustomItem();
            customItem.Color = Color.Red;
            customItem.Name = "CustomItem";

            CustomDrawing customDrawing = new CustomDrawing(customItem);
            customDrawing.Movable = true;
            customDrawing.Size = new Size(100, 100);
            customItem.Drawing = customDrawing;

            Structure stru = (diagramContainer1.DiagramItems[0] as Structure);
            diagramContainer1.AddLink(stru.Nodes[0].Nodes[3], customItem);

            diagramContainer1.AddItem(customItem, customDrawing, true, true);
            diagramContainer1.AddLink(customItem, diagramContainer1.DiagramItems[0]);

            CircleDrawing customDrawing2 = new CircleDrawing(130, 130);
            customDrawing2.Movable = true;
            customDrawing2.Size = new Size(100, 100);
            diagramContainer1.AddDrawing(customDrawing2, true);

            diagramContainer1.AddLinkDrawing(customDrawing2, customDrawing);
            diagramContainer1.Invalidate();

            diagramContainer1.DrawableHeight = 705;
            diagramContainer1.DrawableWidth = 758;
        }
 public BeforeNodeExpandOrCollapseArg(Node n)
 {
     this.nod = n;
 }
Esempio n. 6
0
 private void RecursiveTraverse(Node node, Action<Node> action)
 {
     action(node);
     if ((!node.IsLeaf)) {
         for (int i = 0; i < node.Nodes.Count; i++) {
             RecursiveTraverse(node.Nodes[i], action);
         }
     }
 }
Esempio n. 7
0
 public void AddNode(Node node)
 {
     node.NodesChanged += OnListChanged;
     nodes.Add(node);
 }