コード例 #1
0
        /// <summary>
        /// Adds a certain amount of random nodes
        /// </summary>
        /// <param name="amount"></param>
        public void AddRandomNodes(int amount)
        {
            if (amount < 1)
            {
                return;
            }
            GL.Shape shape1, shape2;
            if (GraphControl.Shapes.Count == 0)
            {
                shape1 = GraphControl.AddBasicShape("Root", new Point(100, 100));
                amount--;
            }

            for (int k = 0; k < amount; k++)
            {
                shape1 = GraphControl.Shapes[rnd.Next(0, GraphControl.Shapes.Count - 1)];
                shape2 = GraphControl.AddBasicShape("Random " + k, new Point(rnd.Next(20, GraphControl.Width - 70), rnd.Next(20, GraphControl.Height - 30)));
                Connect(shape1, shape2);
            }
        }