예제 #1
0
        public override ShapeBase ReadShape(IO.TextReader Reader)
        {
            int n = int.Parse(Reader.ReadLine().Trim());
            var ar = new int[n];
            for (int i = 0; i < n; i++)
            {
                ar[i] = int.Parse(Reader.ReadLine().Trim());
            }
            int m = int.Parse(Reader.ReadLine().Trim());

            var Points = new PointF[m];

            for (int i = 0; i < m; i++)
            {
                var L = Reader.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                Points[i] = new PointF(Single.Parse(L[0]), Single.Parse(L[1]));
            }

            var Collection = new ShapeCollection() { Name = "Parts" };

            var MyColors = new Color[] { Color.Red, Color.Blue, Color.Magenta, Color.Green, Color.Teal };

            for (int i = 0; i < n; i++)
            {
                m = ar[i];
                var S = new List<Line>();

                for (int j = 0; j < m; j++)
                {
                    var L = Reader.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    S.Add(new Line(Points[int.Parse(L[0]) - 1], Points[int.Parse(L[1]) - 1]));
                }

                Collection.Shapes.Add(new LinesShape(S) { Color = MyColors[i], Name = "Part " + (i + 1).ToString() });
            }

            return Collection;
        }