Esempio n. 1
0
        private List <Composite> recursiveImport(int stopCount)
        {
            if (lines.Count.Equals(stopCount))
            {
                return(compList);
            }
            else
            {
                redPen = new Pen(Color.Red);
                //de line opdelen in verschillende woorden door het op te splitsen.
                wordParts = lines[stopCount].Split(' ').ToList();
                int countTabs = DetermineTabs(wordParts);
                RemoveTabs(wordParts, 0);
                //eerste woord van line controleren
                switch (wordParts.First())
                {
                case "group":
                {
                    comp = new Composite("Group", new Point(0, 0), new Size(50, 50));
                    if (ornamentitems.Count != 0)
                    {
                        foreach (string a in ornamentitems)
                        {
                            List <string> cache = new List <string>();
                            cache = a.Split(' ').ToList();
                            RemoveTabs(cache, 0);
                            string ornamentLocatie = cache[1];
                            cache[2].Replace(@"\", "");
                            string ornamentText = cache[2];
                            createOrnament(null, comp, ornamentLocatie, ornamentText);
                        }
                        ornamentitems.Clear();
                    }
                    comp.compositeIndex = countTabs;
                    comp.compositeSize  = int.Parse(wordParts[1]);
                    if (!countTabs.Equals(0))
                    {
                        comp.groepInGroup = true;
                        int amountGroup   = compList.Count;
                        int amountInGroup = compList[amountGroup - 1].subordinates.Count;
                        if (compList[amountGroup - 1].compositeSize != amountInGroup)
                        {
                            compList[amountGroup - 1].AddSubordinate(comp);
                            compList[amountGroup - 1].compositeSize = compList[amountGroup - 1].subordinates.Count;
                        }
                    }
                    wordParts.Clear();
                    stopCount++;
                    compList.Add(comp);
                    Form1.Instance.composites.Add(comp);
                    return(recursiveImport(stopCount));
                }

                case "rectangle":
                {
                    Shape s;
                    location = new Point(int.Parse(wordParts[1]), int.Parse(wordParts[2]));
                    size     = new Size(int.Parse(wordParts[3]), int.Parse(wordParts[4]));
                    if (!countTabs.Equals(0))
                    {
                        s         = createRectangle(location, size);
                        leaf      = new Leaf(s);
                        s.InGroup = true;
                        comp.subordinates.Add(leaf);
                        //Form1.Instance.maxWidth = 0;
                        //Form1.Instance.maxHeight = 0;
                        //Form1.Instance.groupSizeX.Clear();
                        //Form1.Instance.groupSizeY.Clear();
                        //Form1.Instance.determineGroupSize(comp, 0, 0);
                        //comp.Position = new Point(Form1.Instance.groupSizeX.Min(), Form1.Instance.groupSizeY.Min());
                        //comp.Size = new Size((Form1.Instance.groupSizeX.Max() + Form1.Instance.maxWidth) - Form1.Instance.groupSizeX.Min(),
                        //                     (Form1.Instance.groupSizeY.Max() + Form1.Instance.maxHeight) - Form1.Instance.groupSizeY.Min());
                    }
                    else
                    {
                        s = createRectangle(location, size);
                        Form1.Instance.moveOrnement(s, null);
                    }
                    wordParts.Clear();
                    checkIfShapeGetsOrnament(s);
                    stopCount++;
                    return(recursiveImport(stopCount));
                }

                case "ellipse":
                {
                    Shape s;
                    location = new Point(int.Parse(wordParts[1]), int.Parse(wordParts[2]));
                    size     = new Size(int.Parse(wordParts[3]), int.Parse(wordParts[4]));
                    if (!countTabs.Equals(0))
                    {
                        s         = createEllipse(location, size);
                        leaf      = new Leaf(s);
                        s.InGroup = true;
                        comp.subordinates.Add(leaf);
                        //Form1.Instance.maxWidth = 0;
                        //Form1.Instance.maxHeight = 0;
                        //Form1.Instance.groupSizeX.Clear();
                        //Form1.Instance.groupSizeY.Clear();
                        //Form1.Instance.determineGroupSize(comp, 0, 0);
                        //comp.Position = new Point(Form1.Instance.groupSizeX.Min(), Form1.Instance.groupSizeY.Min());
                        //comp.Size = new Size((Form1.Instance.groupSizeX.Max() + Form1.Instance.maxWidth) - Form1.Instance.groupSizeX.Min(),
                        //                     (Form1.Instance.groupSizeY.Max() + Form1.Instance.maxHeight) - Form1.Instance.groupSizeY.Min());
                    }
                    else
                    {
                        s = createEllipse(location, size);
                        Form1.Instance.moveOrnement(s, null);
                    }
                    wordParts.Clear();
                    checkIfShapeGetsOrnament(s);
                    stopCount++;
                    return(recursiveImport(stopCount));
                }

                case "ornament":
                {
                    ornamentitems.Add(lines[stopCount]);
                    stopCount++;
                    return(recursiveImport(stopCount));
                }
                }
            }
            return(recursiveImport(stopCount));
        }
Esempio n. 2
0
        private List <Composite> recursiveImport(int stopCount)
        {
            if (lines.Count.Equals(stopCount))
            {
                return(compList);
            }
            else
            {
                redPen = new Pen(Color.Red);
                //de line opdelen in verschillende woorden door het op te splitsen.
                wordParts = lines[stopCount].Split(' ').ToList();
                int countTabs = DetermineTabs(wordParts);
                RemoveTabs(wordParts, 0);
                //eerste woord van line controleren
                switch (wordParts.First())
                {
                case "group":
                {
                    comp = new Composite("Group", new Point(0, 0), new Size(50, 50));
                    comp.compositeIndex = countTabs;
                    comp.compositeSize  = int.Parse(wordParts[1]);
                    if (!countTabs.Equals(0))
                    {
                        comp.groepInGroup = true;
                        int amountGroup   = compList.Count;
                        int amountInGroup = compList[amountGroup - 1].subordinates.Count;
                        if (compList[amountGroup - 1].compositeSize != amountInGroup)
                        {
                            compList[amountGroup - 1].AddSubordinate(comp);
                            compList[amountGroup - 1].compositeSize = compList[amountGroup - 1].subordinates.Count;
                        }
                    }
                    wordParts.Clear();
                    stopCount++;
                    compList.Add(comp);
                    return(recursiveImport(stopCount));
                }

                case "rectangle":
                {
                    location = new Point(int.Parse(wordParts[1]), int.Parse(wordParts[2]));
                    size     = new Size(int.Parse(wordParts[3]), int.Parse(wordParts[4]));
                    if (!countTabs.Equals(0))
                    {
                        Shape s = createRectangle(location, size);
                        leaf      = new Leaf(s);
                        s.InGroup = true;
                        comp.subordinates.Add(leaf);
                    }
                    else
                    {
                        createRectangle(location, size);
                    }
                    wordParts.Clear();
                    stopCount++;
                    return(recursiveImport(stopCount));
                }

                case "ellipse":
                {
                    location = new Point(int.Parse(wordParts[1]), int.Parse(wordParts[2]));
                    size     = new Size(int.Parse(wordParts[3]), int.Parse(wordParts[4]));
                    if (!countTabs.Equals(0))
                    {
                        Shape s = createEllipse(location, size);
                        leaf      = new Leaf(s);
                        s.InGroup = true;
                        comp.subordinates.Add(leaf);
                    }
                    else
                    {
                        createEllipse(location, size);
                    }
                    wordParts.Clear();
                    stopCount++;
                    return(recursiveImport(stopCount));
                }
                }
            }
            return(null);
        }