Beispiel #1
0
        public override void Draw(Graphics gr, float schaal, RectangleF window)
        {
            if ((richtpunt == null) | (eindpunt == null) | (richtlijn == null))
            {
                return;
            }

            // punten eenv. opslaan
            PointF RP = richtpunt.Coordinaat;
            PointF EP = eindpunt.Coordinaat;
            PointF AP = ((Punt)richtlijn.Dep_Vormen.Except(new Punt[] { richtpunt }).First()).Coordinaat;

            // stap 1: loodlijn AP-RP in RP
            float a_l, b_l, c_l;

            Calc_Loodlijn(AP, RP, RP, out a_l, out b_l, out c_l);

            // stap 2: middelloodlijn RP-EP
            float a_ml, b_ml, c_ml;

            Calc_Loodlijn(RP, EP, Midden(RP, EP), out a_ml, out b_ml, out c_ml);

            // stap 3: snijpunt l en ml
            PointF M    = Calc_Snijpunt(a_l, b_l, c_l, a_ml, b_ml, c_ml);
            PointF Mtek = new PointF(M.X - window.Left, M.Y - window.Top);

            Mtek = new PointF(Mtek.X * schaal * 10, Mtek.Y * schaal * 10);

            // stap 4: bepalen van ligging EP
            //	- AP invullen in l
            bool teken_AP = a_l * AP.X + b_l * AP.Y + c_l > 0;
            //	- EP invullen in l
            bool teken_EP     = a_l * EP.X + b_l * EP.Y + c_l > 0;
            bool meer_dan_180 = !(teken_AP ^ teken_EP);

            // stap 5: hoeken
            float start = (float)(Math.Atan2(RP.Y - M.Y, RP.X - M.X) * 180 / Math.PI);
            float end   = (float)(Math.Atan2(EP.Y - M.Y, EP.X - M.X) * 180 / Math.PI);
            float sweep = end - start;

            if (meer_dan_180 & (-180 < sweep) & (sweep < 180))
            {
                sweep += sweep < 0 ? 360 : -360;
            }
            if (!meer_dan_180 & ((sweep < -180) | (180 < sweep)))
            {
                sweep += sweep < 0 ? 360 : -360;
            }

            double R_tek = Ellips.Pyt(M, RP) * schaal * 10;

            Pen pen = (Pen)GetPen(true).Clone();

            pen.Width = pen.Width / 2.54f;
            gr.DrawArc(pen, (float)(Mtek.X - R_tek), (float)(Mtek.Y - R_tek), (float)(2 * R_tek), (float)(2 * R_tek), start, sweep);
        }
Beispiel #2
0
        public override Region GetRegion(Tekening tek)
        {
            if ((richtpunt == null) | (eindpunt == null) | (richtlijn == null))
            {
                return(new Region());
            }
            Graphics gr = tek.CreateGraphics();

            // punten eenv. opslaan
            PointF RP = richtpunt.Coordinaat;
            PointF EP = eindpunt.Coordinaat;
            PointF AP = ((Punt)(richtlijn.Dep_Vormen.Except(new Punt[] { richtpunt }).First())).Coordinaat;

            // stap 1: loodlijn AP-RP in RP
            float a_l, b_l, c_l;

            Calc_Loodlijn(AP, RP, RP, out a_l, out b_l, out c_l);

            // stap 2: middelloodlijn RP-EP
            float a_ml, b_ml, c_ml;

            Calc_Loodlijn(RP, EP, Midden(RP, EP), out a_ml, out b_ml, out c_ml);

            // stap 3: snijpunt l en ml
            PointF M    = Calc_Snijpunt(a_l, b_l, c_l, a_ml, b_ml, c_ml);
            PointF Mtek = tek.co_pt(M, gr.DpiX, gr.DpiY);

            // stap 4: bepalen van ligging EP
            //	- AP invullen in l
            bool teken_AP = a_l * AP.X + b_l * AP.Y + c_l > 0;
            //	- EP invullen in l
            bool teken_EP     = a_l * EP.X + b_l * EP.Y + c_l > 0;
            bool meer_dan_180 = !(teken_AP ^ teken_EP);

            // stap 5: hoeken
            float start = (float)(Math.Atan2(RP.Y - M.Y, RP.X - M.X) * 180 / Math.PI);
            float end   = (float)(Math.Atan2(EP.Y - M.Y, EP.X - M.X) * 180 / Math.PI);
            float sweep = end - start;

            if (meer_dan_180 & (-180 < sweep) & (sweep < 180))
            {
                sweep += sweep < 0 ? 360 : -360;
            }
            if (!meer_dan_180 & ((sweep < -180) | (180 < sweep)))
            {
                sweep += sweep < 0 ? 360 : -360;
            }

            double R_tek = Ellips.Pyt(M, RP) * tek.Schaal * gr.DpiX / 2.54f;

            GraphicsPath path = new GraphicsPath();

            path.AddArc((float)(Mtek.X - R_tek), (float)(Mtek.Y - R_tek), (float)(2 * R_tek), (float)(2 * R_tek), start, sweep);
            return(new Region(path));
        }
Beispiel #3
0
        public override RectangleF Bounds(Graphics gr)
        {
            // punten eenv. opslaan
            PointF RP = richtpunt.Coordinaat;
            PointF EP = eindpunt.Coordinaat;
            PointF AP = ((Punt)richtlijn.Dep_Vormen.Except(new Punt[] { richtpunt }).First()).Coordinaat;

            // stap 1: loodlijn AP-RP in RP
            float a_l, b_l, c_l;

            Calc_Loodlijn(AP, RP, RP, out a_l, out b_l, out c_l);

            // stap 2: middelloodlijn RP-EP
            float a_ml, b_ml, c_ml;

            Calc_Loodlijn(RP, EP, Midden(RP, EP), out a_ml, out b_ml, out c_ml);

            // stap 3: snijpunt l en ml
            PointF M = Calc_Snijpunt(a_l, b_l, c_l, a_ml, b_ml, c_ml);

            float R = (float)Ellips.Pyt(M, RP);

            return(new RectangleF(M.X - R, M.Y - R, 2 * R, 2 * R));
        }
Beispiel #4
0
        public override void Draw(Tekening tek, Graphics gr, bool widepen, bool fill)
        {
            if ((richtpunt == null) | (eindpunt == null) | (richtlijn == null))
            {
                return;
            }

            // punten eenv. opslaan
            PointF RP = richtpunt.Coordinaat;
            PointF EP = eindpunt.Coordinaat;
            PointF AP = ((Punt)(richtlijn.Dep_Vormen.Except(new Punt[] { richtpunt }).First())).Coordinaat;

            // stap 1: loodlijn AP-RP in RP
            float a_l, b_l, c_l;

            Calc_Loodlijn(AP, RP, RP, out a_l, out b_l, out c_l);

            // stap 2: middelloodlijn RP-EP
            float a_ml, b_ml, c_ml;

            Calc_Loodlijn(RP, EP, Midden(RP, EP), out a_ml, out b_ml, out c_ml);

            // stap 3: snijpunt l en ml
            PointF M    = Calc_Snijpunt(a_l, b_l, c_l, a_ml, b_ml, c_ml);
            PointF Mtek = tek.co_pt(M, gr.DpiX, gr.DpiY);

            // stap 4: bepalen van ligging EP
            //	- AP invullen in l
            bool teken_AP = a_l * AP.X + b_l * AP.Y + c_l > 0;
            //	- EP invullen in l
            bool teken_EP     = a_l * EP.X + b_l * EP.Y + c_l > 0;
            bool meer_dan_180 = !(teken_AP ^ teken_EP);

            // stap 5: hoeken
            float start = (float)(Math.Atan2(RP.Y - M.Y, RP.X - M.X) * 180 / Math.PI);
            float end   = (float)(Math.Atan2(EP.Y - M.Y, EP.X - M.X) * 180 / Math.PI);
            float sweep = end - start;

            if (meer_dan_180 & (-180 < sweep) & (sweep < 180))
            {
                sweep += sweep < 0 ? 360 : -360;
            }
            if (!meer_dan_180 & ((sweep < -180) | (180 < sweep)))
            {
                sweep += sweep < 0 ? 360 : -360;
            }

            double R_tek = Ellips.Pyt(M, RP) * tek.Schaal * gr.DpiX / 2.54f;


            Pen pen = (Pen)GetPen(false).Clone();

            if (Geselecteerd)
            {
                Pen selectie = new Pen(Color.Black, pen.Width + 2);
                pen.Width += 1;


                gr.DrawArc(selectie, (float)(Mtek.X - R_tek), (float)(Mtek.Y - R_tek), (float)(2 * R_tek), (float)(2 * R_tek), start, sweep);
                gr.DrawArc(pen, (float)(Mtek.X - R_tek), (float)(Mtek.Y - R_tek), (float)(2 * R_tek), (float)(2 * R_tek), start, sweep);
            }
            else
            {
                if (widepen)
                {
                    pen.Width    += 2;
                    pen.DashStyle = DashStyle.Solid;
                }
                gr.DrawArc(pen, (float)(Mtek.X - R_tek), (float)(Mtek.Y - R_tek), (float)(2 * R_tek), (float)(2 * R_tek), start, sweep);
            }
        }
Beispiel #5
0
        public override void Draw(Tekening tek, Graphics gr, bool widepen, bool fill)
        {
            if ((punt1 == null) | (punt2 == null))
            {
                return;
            }
            PointF p1 = tek.co_pt(punt1.Coordinaat, gr.DpiX, gr.DpiY);
            PointF p2 = tek.co_pt(punt2.Coordinaat, gr.DpiX, gr.DpiY);

            double alfa = Math.Atan2(punt1.Coordinaat.Y - punt2.Coordinaat.Y, punt1.Coordinaat.X - punt2.Coordinaat.X);
            double beta = alfa + Math.PI / 2;

            double dx = offset * tek.Schaal * Math.Cos(beta);
            double dy = offset * tek.Schaal * Math.Sin(beta);
            double sx = 5 * Math.Cos(beta);
            double sy = 5 * Math.Sin(beta);

            double t = 3 + 2 * LijnDikte;

            Pen pen  = (Pen)GetPen(false).Clone();                              // hoofdlijn
            Pen pen1 = new Pen(Geselecteerd ? Color.White : Color.Black, 1);    // hulplijnen

            double dbl_l = Ellips.Pyt(punt1.Coordinaat, punt2.Coordinaat);
            string l     = dbl_l.ToString("0.000");
            int    i     = ((dbl_l * tek.Schaal / 2.54f * gr.DpiX) < 50) ? -1 : 1;

            if (Geselecteerd)
            {
                Pen selectie  = new Pen(Color.Black, pen.Width + 2);
                Pen selectie1 = new Pen(Color.Black, 3);
                pen.Width += 1; pen1.Width += 1;

                gr.DrawLine(selectie1, p1, new PointF((float)(p1.X + dx + sx), (float)(p1.Y + dy + sy)));
                gr.DrawLine(selectie, new PointF((float)(p1.X + dx), (float)(p1.Y + dy)), new PointF((float)(p2.X + dx), (float)(p2.Y + dy)));
                gr.DrawLine(selectie1, p2, new PointF((float)(p2.X + dx + sx), (float)(p2.Y + dy + sy)));

                gr.DrawLine(pen1, p1, new PointF((float)(p1.X + dx + sx), (float)(p1.Y + dy + sy)));
                gr.DrawLine(pen, new PointF((float)(p1.X + dx), (float)(p1.Y + dy)), new PointF((float)(p2.X + dx), (float)(p2.Y + dy)));
                gr.DrawLine(pen1, p2, new PointF((float)(p2.X + dx + sx), (float)(p2.Y + dy + sy)));

                gr.FillPolygon(new SolidBrush(Color.FromArgb(255, pen.Color)), new PointF[] {
                    new PointF((float)(p1.X + dx), (float)(p1.Y + dy)),
                    new PointF((float)(p1.X + dx - 20 * Math.Cos(alfa) * i - t * Math.Cos(alfa + Math.PI / 2) * i), (float)(p1.Y + dy - 20 * Math.Sin(alfa) * i - t * Math.Sin(alfa + Math.PI / 2) * i)),
                    new PointF((float)(p1.X + dx - 20 * Math.Cos(alfa) * i - t * Math.Cos(alfa - Math.PI / 2) * i), (float)(p1.Y + dy - 20 * Math.Sin(alfa) * i - t * Math.Sin(alfa - Math.PI / 2) * i))
                });
                gr.FillPolygon(new SolidBrush(Color.FromArgb(255, pen.Color)), new PointF[] {
                    new PointF((float)(p2.X + dx), (float)(p2.Y + dy)),
                    new PointF((float)(p2.X + dx + 20 * Math.Cos(alfa) * i + t * Math.Cos(alfa + Math.PI / 2) * i), (float)(p2.Y + dy + 20 * Math.Sin(alfa) * i + t * Math.Sin(alfa + Math.PI / 2) * i)),
                    new PointF((float)(p2.X + dx + 20 * Math.Cos(alfa) * i + t * Math.Cos(alfa - Math.PI / 2) * i), (float)(p2.Y + dy + 20 * Math.Sin(alfa) * i + t * Math.Sin(alfa - Math.PI / 2) * i))
                });
                selectie1.Width = 1;
                gr.DrawPolygon(selectie1, new PointF[] {
                    new PointF((float)(p1.X + dx), (float)(p1.Y + dy)),
                    new PointF((float)(p1.X + dx - 20 * Math.Cos(alfa) * i - t * Math.Cos(alfa + Math.PI / 2) * i), (float)(p1.Y + dy - 20 * Math.Sin(alfa) * i - t * Math.Sin(alfa + Math.PI / 2) * i)),
                    new PointF((float)(p1.X + dx - 20 * Math.Cos(alfa) * i - t * Math.Cos(alfa - Math.PI / 2) * i), (float)(p1.Y + dy - 20 * Math.Sin(alfa) * i - t * Math.Sin(alfa - Math.PI / 2) * i))
                });
                gr.DrawPolygon(selectie1, new PointF[] {
                    new PointF((float)(p2.X + dx), (float)(p2.Y + dy)),
                    new PointF((float)(p2.X + dx + 20 * Math.Cos(alfa) * i + t * Math.Cos(alfa + Math.PI / 2) * i), (float)(p2.Y + dy + 20 * Math.Sin(alfa) * i + t * Math.Sin(alfa + Math.PI / 2) * i)),
                    new PointF((float)(p2.X + dx + 20 * Math.Cos(alfa) * i + t * Math.Cos(alfa - Math.PI / 2) * i), (float)(p2.Y + dy + 20 * Math.Sin(alfa) * i + t * Math.Sin(alfa - Math.PI / 2) * i))
                });

                Font f = new Font(FontFamily.GenericMonospace, 12);
                gr.TranslateTransform((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2);
                gr.RotateTransform((float)(alfa * 180 / Math.PI + 180));
                SizeF size = gr.MeasureString(l, f);
                gr.TranslateTransform(-size.Width / 2, -size.Height - offset * tek.Schaal);

                GraphicsPath path = new GraphicsPath();
                path.AddString(l, f.FontFamily, (int)f.Style, f.SizeInPoints * 1.3f, new PointF(), new StringFormat());
                gr.DrawPath(Pens.Black, path);
                gr.FillPath(new SolidBrush(Color.FromArgb(255, pen.Color)), path);
                gr.ResetTransform();
            }
            else
            {
                Font f = new Font(FontFamily.GenericMonospace, 12);
                if (widepen)
                {
                    gr.TranslateTransform((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2);
                    gr.RotateTransform((float)(alfa * 180 / Math.PI + 180));
                    SizeF size = gr.MeasureString(l, f);
                    gr.TranslateTransform(-size.Width / 2, -size.Height - offset);
                    gr.FillRectangle(Brushes.Black, 0, 0, size.Width, size.Height);
                    gr.ResetTransform();
                }
                else
                {
                    gr.DrawLine(pen1, p1, new PointF((float)(p1.X + dx + sx), (float)(p1.Y + dy + sy)));
                    gr.DrawLine(pen, new PointF((float)(p1.X + dx), (float)(p1.Y + dy)), new PointF((float)(p2.X + dx), (float)(p2.Y + dy)));
                    gr.DrawLine(pen1, p2, new PointF((float)(p2.X + dx + sx), (float)(p2.Y + dy + sy)));
                    gr.FillPolygon(new SolidBrush(Color.FromArgb(255, pen.Color)), new PointF[] {
                        new PointF((float)(p1.X + dx), (float)(p1.Y + dy)),
                        new PointF((float)(p1.X + dx - 20 * Math.Cos(alfa) * i - t * Math.Cos(alfa + Math.PI / 2) * i), (float)(p1.Y + dy - 20 * Math.Sin(alfa) * i - t * Math.Sin(alfa + Math.PI / 2) * i)),
                        new PointF((float)(p1.X + dx - 20 * Math.Cos(alfa) * i - t * Math.Cos(alfa - Math.PI / 2) * i), (float)(p1.Y + dy - 20 * Math.Sin(alfa) * i - t * Math.Sin(alfa - Math.PI / 2) * i))
                    });
                    gr.FillPolygon(new SolidBrush(Color.FromArgb(255, pen.Color)), new PointF[] {
                        new PointF((float)(p2.X + dx), (float)(p2.Y + dy)),
                        new PointF((float)(p2.X + dx + 20 * Math.Cos(alfa) * i + t * Math.Cos(alfa + Math.PI / 2) * i), (float)(p2.Y + dy + 20 * Math.Sin(alfa) * i + t * Math.Sin(alfa + Math.PI / 2) * i)),
                        new PointF((float)(p2.X + dx + 20 * Math.Cos(alfa) * i + t * Math.Cos(alfa - Math.PI / 2) * i), (float)(p2.Y + dy + 20 * Math.Sin(alfa) * i + t * Math.Sin(alfa - Math.PI / 2) * i))
                    });


                    gr.TranslateTransform((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2);
                    gr.RotateTransform((float)(alfa * 180 / Math.PI + 180));
                    SizeF size = gr.MeasureString(l, f);
                    gr.TranslateTransform(-size.Width / 2, -size.Height - offset * tek.Schaal);
                    gr.DrawString(l, f, new SolidBrush(LijnKleur), new PointF());
                    gr.ResetTransform();
                }
            }
        }
Beispiel #6
0
        public static Vorm FromString(string tekst, List <Vorm> vorm_list, List <Layer> layers)
        {
            string[] parts = tekst.Split(';');
            if (parts[3] == "")
            {
                parts[3] = "(default)";
            }
            Layer L = layers.Where(T => T.Naam == parts[3]).Count() == 0 ? layers.Where(T => T.Naam == "(default)").First() : layers.Where(T => T.Naam == parts[3]).First();
            Vorm  result;
            IEnumerable <Punt>   punten = vorm_list.Where(T => T.vorm_type == Vorm_type.Punt).Select(T => (Punt)T);
            IEnumerable <Rechte> lijnen = vorm_list.Where(T => T.vorm_type == Vorm_type.Rechte).Select(T => (Rechte)T);

            switch (parts[0])
            {
            case "boog":
                Cirkelboog b = new Cirkelboog(L);
                b.Zichtbaarheid = Convert.ToInt32(parts[1]);
                b.Niveau        = Convert.ToInt32(parts[2]);
                b.LijnKleur     = ColorTranslator.FromOle(Convert.ToInt32(parts[4]));
                b.LijnDikte     = Convert.ToInt32(parts[5]);
                b.LijnStijl     = (DashStyle)Convert.ToInt32(parts[6]);
                if (b.LijnStijl == DashStyle.Custom)
                {
                    b.DashPattern = parts[7].Split('/').Select(T => Convert.ToSingle(T)).ToArray();
                }
                for (int i = 8; i < parts.Length; i++)
                {
                    b.Punten.Add(punten.Where(T => T.ID == Convert.ToInt32(parts[i])).ElementAt(0));
                }
                result = b;
                break;

            case "kromme":
                Kromme k = new Kromme(L);
                k.Zichtbaarheid = Convert.ToInt32(parts[1]);
                k.Niveau        = Convert.ToInt32(parts[2]);
                k.LijnKleur     = ColorTranslator.FromOle(Convert.ToInt32(parts[4]));
                k.LijnDikte     = Convert.ToInt32(parts[5]);
                k.LijnStijl     = (DashStyle)Convert.ToInt32(parts[6]);
                if (k.LijnStijl == DashStyle.Custom)
                {
                    k.DashPattern = parts[7].Split('/').Select(T => Convert.ToSingle(T)).ToArray();
                }
                for (int i = 8; i < parts.Length; i++)
                {
                    k.Punten.Add(punten.Where(T => T.ID == Convert.ToInt32(parts[i])).ElementAt(0));
                }
                result = k;
                break;

            case "rechte":
                Rechte r = new Rechte(Convert.ToInt32(parts[1]), L);
                r.Zichtbaarheid = Convert.ToInt32(parts[2]);
                r.Niveau        = Convert.ToInt32(parts[4]);
                r.LijnKleur     = ColorTranslator.FromOle(Convert.ToInt32(parts[5]));
                r.LijnDikte     = Convert.ToInt32(parts[6]);
                r.LijnStijl     = (DashStyle)Convert.ToInt32(parts[7]);
                if (r.LijnStijl == DashStyle.Custom)
                {
                    r.DashPattern = parts[8].Split('/').Select(T => Convert.ToSingle(T)).ToArray();
                }
                r.Punt1 = punten.Where(T => T.ID == Convert.ToInt32(parts[9])).ElementAt(0);
                r.Punt2 = punten.Where(T => T.ID == Convert.ToInt32(parts[10])).ElementAt(0);
                result  = r;
                break;

            case "maatlijn":
                Maatlijn ml = new Maatlijn(L);
                ml.Zichtbaarheid = Convert.ToInt32(parts[1]);
                ml.Niveau        = Convert.ToInt32(parts[2]);
                ml.LijnKleur     = ColorTranslator.FromOle(Convert.ToInt32(parts[4]));
                ml.LijnDikte     = Convert.ToInt32(parts[5]);
                ml.LijnStijl     = (DashStyle)Convert.ToInt32(parts[6]);
                ml.Punt1         = punten.Where(T => T.ID == Convert.ToInt32(parts[7])).ElementAt(0);
                ml.Punt2         = punten.Where(T => T.ID == Convert.ToInt32(parts[8])).ElementAt(0);
                ml.Offset        = Convert.ToSingle(parts[9]);
                result           = ml;
                break;

            case "punt":
                Punt p = new Punt(Convert.ToInt32(parts[4]), L);
                p.Zichtbaarheid = Convert.ToInt32(parts[1]);
                p.Niveau        = Convert.ToInt32(parts[2]);
                p.X             = parts[5].MakeFloat();
                p.Y             = parts[6].MakeFloat();
                p.PuntStijl     = (Punt.enPuntStijl)Convert.ToInt32(parts[7]);
                p.Kleur         = ColorTranslator.FromOle(Convert.ToInt32(parts[8]));
                result          = p;
                break;

            case "cirkel":
                Cirkel c = new Cirkel(L);
                c.Zichtbaarheid = Convert.ToInt32(parts[1]);
                c.Niveau        = Convert.ToInt32(parts[2]);
                c.LijnKleur     = ColorTranslator.FromOle(Convert.ToInt32(parts[4]));
                c.LijnDikte     = Convert.ToInt32(parts[5]);
                c.LijnStijl     = (DashStyle)Convert.ToInt32(parts[6]);
                c.VulKleur1     = ColorTranslator.FromOle(Convert.ToInt32(parts[7]));
                c.VulKleur2     = ColorTranslator.FromOle(Convert.ToInt32(parts[8]));
                c.OpvulType     = (Vlak.OpvulSoort)Convert.ToInt32(parts[9]);
                c.VulStijl      = (HatchStyle)Convert.ToInt32(parts[10]);
                c.LoopHoek      = Convert.ToInt32(parts[11]);
                for (int i = 12; i < parts.Length; i++)
                {
                    c.Punten.Add(punten.Where(T => T.ID == Convert.ToInt32(parts[i])).ElementAt(0));
                }
                result = c;
                break;

            case "cirkelsector":
                CirkelSector cs = new CirkelSector(L);
                cs.Zichtbaarheid = Convert.ToInt32(parts[1]);
                cs.Niveau        = Convert.ToInt32(parts[2]);
                cs.LijnKleur     = ColorTranslator.FromOle(Convert.ToInt32(parts[4]));
                cs.LijnDikte     = Convert.ToInt32(parts[5]);
                cs.LijnStijl     = (DashStyle)Convert.ToInt32(parts[6]);
                cs.VulKleur1     = ColorTranslator.FromOle(Convert.ToInt32(parts[7]));
                cs.VulKleur2     = ColorTranslator.FromOle(Convert.ToInt32(parts[8]));
                cs.OpvulType     = (Vlak.OpvulSoort)Convert.ToInt32(parts[9]);
                cs.VulStijl      = (HatchStyle)Convert.ToInt32(parts[10]);
                cs.LoopHoek      = Convert.ToInt32(parts[11]);
                for (int i = 12; i < parts.Length; i++)
                {
                    cs.Punten.Add(punten.Where(T => T.ID == Convert.ToInt32(parts[i])).ElementAt(0));
                }
                result = cs;
                break;

            case "cirkelsegment":
                CirkelSegment csg = new CirkelSegment(L);
                csg.Zichtbaarheid = Convert.ToInt32(parts[1]);
                csg.Niveau        = Convert.ToInt32(parts[2]);
                csg.LijnKleur     = ColorTranslator.FromOle(Convert.ToInt32(parts[4]));
                csg.LijnDikte     = Convert.ToInt32(parts[5]);
                csg.LijnStijl     = (DashStyle)Convert.ToInt32(parts[6]);
                csg.VulKleur1     = ColorTranslator.FromOle(Convert.ToInt32(parts[7]));
                csg.VulKleur2     = ColorTranslator.FromOle(Convert.ToInt32(parts[8]));
                csg.OpvulType     = (Vlak.OpvulSoort)Convert.ToInt32(parts[9]);
                csg.VulStijl      = (HatchStyle)Convert.ToInt32(parts[10]);
                csg.LoopHoek      = Convert.ToInt32(parts[11]);
                for (int i = 12; i < parts.Length; i++)
                {
                    csg.Punten.Add(punten.Where(T => T.ID == Convert.ToInt32(parts[i])).ElementAt(0));
                }
                result = csg;
                break;

            case "ellips":
                Ellips el = new Ellips(L);
                el.Zichtbaarheid = Convert.ToInt32(parts[1]);
                el.Niveau        = Convert.ToInt32(parts[2]);
                el.LijnKleur     = ColorTranslator.FromOle(Convert.ToInt32(parts[4]));
                el.LijnDikte     = Convert.ToInt32(parts[5]);
                el.LijnStijl     = (DashStyle)Convert.ToInt32(parts[6]);
                el.VulKleur1     = ColorTranslator.FromOle(Convert.ToInt32(parts[7]));
                el.VulKleur2     = ColorTranslator.FromOle(Convert.ToInt32(parts[8]));
                el.OpvulType     = (Vlak.OpvulSoort)Convert.ToInt32(parts[9]);
                el.VulStijl      = (HatchStyle)Convert.ToInt32(parts[10]);
                el.LoopHoek      = Convert.ToInt32(parts[11]);
                el.F1            = punten.Where(T => T.ID == Convert.ToInt32(parts[12])).ElementAt(0);
                el.F2            = punten.Where(T => T.ID == Convert.ToInt32(parts[13])).ElementAt(0);
                el.P             = punten.Where(T => T.ID == Convert.ToInt32(parts[14])).ElementAt(0);
                result           = el;
                break;

            case "gkromme":
                GeslotenKromme g = new GeslotenKromme(L);
                g.Zichtbaarheid = Convert.ToInt32(parts[1]);
                g.Niveau        = Convert.ToInt32(parts[2]);
                g.LijnKleur     = ColorTranslator.FromOle(Convert.ToInt32(parts[4]));
                g.LijnDikte     = Convert.ToInt32(parts[5]);
                g.LijnStijl     = (DashStyle)Convert.ToInt32(parts[6]);
                g.VulKleur1     = ColorTranslator.FromOle(Convert.ToInt32(parts[7]));
                g.VulKleur2     = ColorTranslator.FromOle(Convert.ToInt32(parts[8]));
                g.OpvulType     = (Vlak.OpvulSoort)Convert.ToInt32(parts[9]);
                g.VulStijl      = (HatchStyle)Convert.ToInt32(parts[10]);
                g.LoopHoek      = Convert.ToInt32(parts[11]);
                for (int i = 12; i < parts.Length; i++)
                {
                    g.Punten.Add(punten.Where(T => T.ID == Convert.ToInt32(parts[i])).ElementAt(0));
                }
                result = g;
                break;

            case "veelhoek":
                Veelhoek v = new Veelhoek(L);
                v.Zichtbaarheid = Convert.ToInt32(parts[1]);
                v.Niveau        = Convert.ToInt32(parts[2]);
                v.LijnKleur     = ColorTranslator.FromOle(Convert.ToInt32(parts[4]));
                v.LijnDikte     = Convert.ToInt32(parts[5]);
                v.LijnStijl     = (DashStyle)Convert.ToInt32(parts[6]);
                v.VulKleur1     = ColorTranslator.FromOle(Convert.ToInt32(parts[7]));
                v.VulKleur2     = ColorTranslator.FromOle(Convert.ToInt32(parts[8]));
                v.OpvulType     = (Vlak.OpvulSoort)Convert.ToInt32(parts[9]);
                v.VulStijl      = (HatchStyle)Convert.ToInt32(parts[10]);
                v.LoopHoek      = Convert.ToInt32(parts[11]);
                for (int i = 12; i < parts.Length; i++)
                {
                    v.Punten.Add(punten.Where(T => T.ID == Convert.ToInt32(parts[i])).ElementAt(0));
                }
                result = v;
                break;

            case "tekst":
                Tekst t = new Tekst(L);
                t.Zichtbaarheid = Convert.ToInt32(parts[1]);
                t.niveau        = Convert.ToInt32(parts[2]);
                t.Uitlijning    = (ContentAlignment)Enum.Parse(typeof(ContentAlignment), parts[4]);
                t.Text          = parts[5].Replace("\\r\\n", Environment.NewLine);
                FontConverter conv = new FontConverter();
                t.Font       = (Font)conv.ConvertFromString(parts[6].Replace('|', ';'));
                t.Kleur      = ColorTranslator.FromOle(Convert.ToInt32(parts[7]));
                t.Punt       = punten.Where(T => T.ID == Convert.ToInt32(parts[8])).ElementAt(0);
                t.Meeschalen = parts[9] == "1";
                result       = t;
                break;

            case "raak":
                RaakBoog rb = new RaakBoog(L);
                rb.Zichtbaarheid = Convert.ToInt32(parts[1]);
                rb.Niveau        = Convert.ToInt32(parts[2]);
                rb.LijnKleur     = ColorTranslator.FromOle(Convert.ToInt32(parts[4]));
                rb.LijnDikte     = Convert.ToInt32(parts[5]);
                rb.LijnStijl     = (DashStyle)Convert.ToInt32(parts[6]);
                if (rb.LijnStijl == DashStyle.Custom)
                {
                    rb.DashPattern = parts[7].Split('/').Select(T => Convert.ToSingle(T)).ToArray();
                }
                rb.RichtPunt = punten.Where(T => T.ID == Convert.ToInt32(parts[8])).ElementAt(0);
                rb.EindPunt  = punten.Where(T => T.ID == Convert.ToInt32(parts[9])).ElementAt(0);
                rb.RichtLijn = lijnen.Where(T => T.ID == Convert.ToInt32(parts[10])).ElementAt(0);
                result       = rb;
                break;

            default:
                result = null;
                break;
            }
            return(result);
        }