示例#1
0
        private List <ShapeComponent> ReadedLinesToShapes(int spaces = 0)
        {
            List <string>         texts       = null;
            List <ShapeComponent> loadeshapes = new List <ShapeComponent>();

            while (ReadedLines.Count > 0 && CheckAmountOfSpaces(ReadedLines.First()) == spaces)
            {
                List <string> splittedLines = ReadedLines.First().Split(' ').ToList();
                List <string> items         = splittedLines.GetRange(spaces, splittedLines.Count() - spaces);
                ReadedLines.Remove(ReadedLines.First());
                ShapeComponent loadedshape = null;
                if (items.First() == "group")
                {
                    loadedshape = GetGroup(spaces + 3);
                }
                else if (items.First() == InternalEllipse.getInstance().GetName())
                {
                    loadedshape = InternalShape.Load(InternalEllipse.getInstance(), items);
                }
                else if (items.First() == InternalRectangle.getInstance().GetName())
                {
                    loadedshape = InternalShape.Load(InternalRectangle.getInstance(), items);
                }
                else if (items.First() == "ornament")
                {
                    if (texts == null)
                    {
                        texts = new List <string>()
                        {
                            "", "", "", ""
                        };
                    }
                    texts[TextDecorator.GetLocation((TextDecorator.TextLocations)Enum.Parse(typeof(TextDecorator.TextLocations), items[1]))] = items[2].Trim('"');
                }
                if (texts != null && loadedshape != null)
                {
                    loadeshapes.Add(new TextDecorator(loadedshape, texts));
                    texts = null;
                }
                else if (loadedshape != null)
                {
                    loadeshapes.Add(loadedshape);
                }
            }
            return(loadeshapes);
        }