コード例 #1
0
 private static void PopulateAllLinesCollection()
 {
     AllLinesCollection = new LineCollection();
     foreach (var lineSegment in LineSegmentCollection.Lines)
     {
         if (!AllLinesCollection.ContainsLine(lineSegment))
         {
             AllLinesCollection.AddLine(lineSegment);
         }
         foreach (var subSegment in lineSegment.SubSegments)
         {
             if (!AllLinesCollection.ContainsLine(subSegment))
             {
                 AllLinesCollection.AddLine(subSegment);
             }
         }
     }
 }
コード例 #2
0
        private static void ParseTextToData(string text)
        {
            LineSegmentCollection = new LineCollection();

            var lines = text.Split("\n");

            try {
                foreach (var line in lines)
                {
                    string lineStr = "";

                    if (line.Contains("\r"))
                    {
                        lineStr = line.Substring(0, line.Length - 1);
                    }
                    else
                    {
                        lineStr = line;
                    }

                    string[] points  = lineStr.Split(" ");
                    var      points1 = points[0].Split(",");
                    var      points2 = points[1].Split(",");

                    Point p1 = new Point(int.Parse(points1[0]), int.Parse(points1[1]));
                    Point p2 = new Point(int.Parse(points2[0]), int.Parse(points2[1]));

                    LineSegment newLineSegment = new LineSegment(p1, p2);
                    LineSegmentCollection.Lines.Add(newLineSegment);
                }
            } catch (Exception ex) {
                Console.WriteLine(ex);
            }

            Console.WriteLine("Loaded Data.");
        }