Ejemplo n.º 1
0
 public static void SavePath(Path3D path)
 {
     string filePath = string.Format(@"C:\Users\Iliyan\Dropbox\Fundamentals [OOP]\HM\Static Members and Name Spaces\" +
         "{0}.txt", (counter.ToString()));
     File.WriteAllText(filePath, string.Join(Environment.NewLine, path.Points3D()));
     counter++;
 }
Ejemplo n.º 2
0
 static void Main(string[] args)
 {
     string[] line = Console.ReadLine().Split(' ');
     while (line[0] != "End")
     {
         switch (line[0])
         {
             case "SavePath":
                 line = Console.ReadLine().Split(' ');
                 Path3D path = new Path3D();
                 while (Char.IsDigit(line[0][0]))
                 {
                     path.AddPoint3D(new Point3D(double.Parse(line[0]), double.Parse(line[1]), double.Parse(line[2])));
                     line = Console.ReadLine().Split(' ');
                 }
                 Storage.SavePath(path);
                 break;
             case "LoadPath":
                 Storage.LoadPath();
                 line = Console.ReadLine().Split(' ');
                 break;
             default:
                 break;
         }
     }
 }
Ejemplo n.º 3
0
        public static Path3D LoadPathFromFile(string filepath)
        {
            Path3D path = new Path3D();

            using (StreamReader reader = new StreamReader(filepath))
            {
                string line = reader.ReadLine();
                const string PointPattern = @"[xyz=:\-\s](\d+(?:(?:\.|,)\d+)*)";

                while (line != null)
                {
                    MatchCollection matches = Regex.Matches(line, PointPattern);
                    if (matches.Count == 3)
                    {
                        double x = double.Parse(matches[0].Groups[1].Value);
                        double y = double.Parse(matches[1].Groups[1].Value);
                        double z = double.Parse(matches[2].Groups[1].Value);

                        Point3D point = new Point3D(x, y, z);
                        path.AddPoints(point);
                    }

                    line = reader.ReadLine();
                }
            }
            return path;
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            while (line[0] != "End")
            {
                switch (line[0])
                {
                case "SavePath":
                    line = Console.ReadLine().Split(' ');
                    Path3D path = new Path3D();
                    while (Char.IsDigit(line[0][0]))
                    {
                        path.AddPoint3D(new Point3D(double.Parse(line[0]), double.Parse(line[1]), double.Parse(line[2])));
                        line = Console.ReadLine().Split(' ');
                    }
                    Storage.SavePath(path);
                    break;

                case "LoadPath":
                    Storage.LoadPath();
                    line = Console.ReadLine().Split(' ');
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 5
0
Archivo: Storage.cs Proyecto: Gab42/OOP
 public static void SavePath(string destination, Path3D path)
 {
     using (StreamWriter writer = new StreamWriter(destination))
     {
         XmlSerializer serialized = new XmlSerializer(path.GetType());
         serialized.Serialize(writer, path);
     }
 }
Ejemplo n.º 6
0
        public static void SavePath(Path3D path)
        {
            string filePath = string.Format(@"C:\Users\Iliyan\Dropbox\Fundamentals [OOP]\HM\Static Members and Name Spaces\" +
                                            "{0}.txt", (counter.ToString()));

            File.WriteAllText(filePath, string.Join(Environment.NewLine, path.Points3D()));
            counter++;
        }
Ejemplo n.º 7
0
 static void Main()
 {
     Point3D point1 = new Point3D(1, 3, 5);
     Point3D point2 = new Point3D(-4, 4.5, -7);
     Point3D point3 = new Point3D(1.2, 10, 12);
     Path3D path = new Path3D(Path3D.CreateSequenceOfPoints(point1, point2, point3));
     string text = path.ToString();
     Storage.SaveToFile(".../.../file.txt",text);
     Storage.LoadFile(".../.../file.txt");            
 }
Ejemplo n.º 8
0
Archivo: Program.cs Proyecto: Gab42/OOP
        static void Main(string[] args)
        {
            var path1 = new Path3D(
               new Point3D(5, 20.7, -8),
               new Point3D(6, 65, -6),
               new Point3D(1, 5, 10),
               new Point3D(0.5, -9.9, -6.9));

            Storage.SavePath(File, path1);
            Path3D path2 = Storage.LoadPath(File);

            Console.WriteLine(string.Join(Environment.NewLine, path2.Path));
        }