Esempio n. 1
0
        public static List<Line> GetLinesOfPoint(Point p, Group g)
        {
            List<Line> lines = new List<Line>();

            foreach (IGraphicObject igo in g.GetGroup())
            {
                if (igo.GetType() == typeof(Line))
                {
                    Line l = (Line)igo;
                    if (Line.ContainsPoint(p, l) == true)
                    {
                        lines.Add(l);
                    }
                }
            }
            return lines;
        }
Esempio n. 2
0
        public static List<Curve> GetCurvesOfPoint(Point p, Group g)
        {
            List<Curve> curves = new List<Curve>();

            foreach (IGraphicObject igo in g.GetGroup())
            {
                if (igo.GetType() == typeof(Curve))
                {
                    Curve c = (Curve)igo;
                    if (Curve.ContainsPoint(p, c) == true)
                    {
                        curves.Add(c);
                    }
                }
            }
            return curves;
        }
Esempio n. 3
0
        public static List<Group> Deserialize(string filename)
        {
            List<Group> gs = new List<Group>();
            Group group = new Group();
            Line _line = new Line();
            Curve _curve = new Curve();

            string doc = System.IO.File.ReadAllText(filename);

            Generic gen = new Generic();
            Dictionary<string, string> coordinates = new Dictionary<string, string>();

            string line = "", expr = "", oldexpr = "", coor = "";
            StringReader sr = new StringReader(doc);
            while ((line = sr.ReadLine()) != null)
            {
                //1 - Groups ON (List<Group> gs)
                //2 - Group ON (Group group)
                //3 - Line ON (Line _line) ou Curve ON (Curve _curve)
                expr = gen.FromON(line, out coordinates);
                if (expr == "Group")
                {
                    group = new Group();
                    gs.Add(group);
                }
                else if (expr == "Line")
                {
                    _line = new Line();
                    group.AddLine(_line);
                    oldexpr = "Line";
                }
                else if (expr == "Curve")
                {
                    _curve = new Curve();
                    group.AddCurve(_curve);
                    oldexpr = "Curve";
                }

                //4 - Coordinates
                coor = gen.FromVOID(line, out coordinates);
                if (coor == "Start" && oldexpr == "Line")
                {
                    _line.Start = new Point(Convert.ToInt32(coordinates["X"]), Convert.ToInt32(coordinates["Y"]));
                }
                else if (coor == "End" && oldexpr == "Line")
                {
                    _line.End = new Point(Convert.ToInt32(coordinates["X"]), Convert.ToInt32(coordinates["Y"]));
                }
                else if (coor == "Start" && oldexpr == "Curve")
                {
                    _curve.Start = new Point(Convert.ToInt32(coordinates["X"]), Convert.ToInt32(coordinates["Y"]));
                }
                else if (coor == "CP1" && oldexpr == "Curve")
                {
                    _curve.CP1 = new Point(Convert.ToInt32(coordinates["X"]), Convert.ToInt32(coordinates["Y"]));
                }
                else if (coor == "CP2" && oldexpr == "Curve")
                {
                    _curve.CP2 = new Point(Convert.ToInt32(coordinates["X"]), Convert.ToInt32(coordinates["Y"]));
                }
                else if (coor == "End" && oldexpr == "Curve")
                {
                    _curve.End = new Point(Convert.ToInt32(coordinates["X"]), Convert.ToInt32(coordinates["Y"]));
                }
            }

            return gs;
        }
Esempio n. 4
0
 /// <summary>
 /// Close current group and add a new one.
 /// </summary>
 public void NewGroup()
 {
     currentGroup = new Drawing.Group();
 }