Ejemplo n.º 1
0
        public static void CreateTestObjects(GLib lib, int count)
        {
            createTestObjectsCount++;
            // Type
            GType type = new GType(lib, GeomType.Polygon);

            type.Name     = "Polygon test" + createTestObjectsCount.ToString();
            type.StyleStr = "pc=blue;bc=lightgreen;";
            Rect bounds  = lib.Bounds;
            int  libSize = (int)lib.Bounds.MinSize;

            // Objects
            Random r = new Random();

            for (int n = 0; n < count; n++)
            {
                int     maxSize = libSize / 10;
                int     x       = bounds.left + r.Next((int)bounds.Width - maxSize);
                int     y       = bounds.bottom + r.Next((int)bounds.Height - maxSize);
                Point[] points  = new Point[3];
                for (int i = 0; i < points.Length; i++)
                {
                    points[i].X = x + r.Next(maxSize);
                    points[i].Y = y + r.Next(maxSize);
                }
                GPolygon polygon = new GPolygon(type, points);
                polygon.Caption = n.ToString();
            }
        }
Ejemplo n.º 2
0
        static GObject Create(GRange range)
        {
            GObject gobj;

            switch (range.Type.GeomType)
            {
            case GeomType.Point: gobj = new GPoint(); break;

            case GeomType.Polyline: gobj = new GPolyline(); break;

            case GeomType.Polygon: gobj = new GPolygon(); break;

            case GeomType.Caption: gobj = new GCaption(); break;

            default: throw new Exception("Unknown GeomType: " + range.Type.GeomType);
            }
            gobj.range = range;
//			gobj.AssignId();
            return(gobj);
        }