コード例 #1
0
ファイル: Storage.cs プロジェクト: borislavtotev/SoftUniOOP
 public static void SaveToFile(Path3D points, string filePath)
 {
     using (System.IO.StreamWriter file = new System.IO.StreamWriter(@filePath))
     {
         file.Write(points.path3DString);
     }
 }
コード例 #2
0
ファイル: Path3D.cs プロジェクト: borislavtotev/SoftUniOOP
        public void AddListOfPoints(List <Point3D> points)
        {
            string newPoints = Path3D.ListToString(points);

            this.path3DString += newPoints;
            this.list3DPoints  = Path3D.StringToList(this.path3DString);
        }
コード例 #3
0
ファイル: Storage.cs プロジェクト: AmaranthInHell/projects
        public static List<Path3D> LoadPaths()
        {
            List<Path3D> paths = new List<Path3D>();
            try
            {
                StreamReader reader = new StreamReader("paths.txt");
                using (reader)
                {
                    string line = reader.ReadLine();
                    while (line != null)
                    {
                        Path3D path = new Path3D();
                        string[] pointsArr = line.Split(' ');
                        foreach (var point in pointsArr)
                        {
                            if (point != string.Empty)
                            {
                                int x = Convert.ToInt32(point[0] - 48);
                                int y = Convert.ToInt32(point[2] - 48);
                                int z = Convert.ToInt32(point[4] - 48);
                                path.AddPath(new Point3D(x, y, z));
                            }
                        }
                        paths.Add(path);
                        line = reader.ReadLine();
                    }
                }
            }
            catch (IOException ioe)
            {
                Console.Error.WriteLine(ioe.Message);
            }

            return paths;
        }
コード例 #4
0
ファイル: Paths.cs プロジェクト: ialidzhikov/SoftUni
        static void Main()
        {
            Path3D pathOne = new Path3D();

            pathOne.Add(new Point3D(3, 3, 0));
            pathOne.Add(new Point3D(-7, 2, 21));
            pathOne.Add(Point3D.StartingPoint3D);

            Path3D pathTwo = new Path3D();

            pathTwo.Add(new Point3D(-1, -2, -5));
            pathTwo.Add(new Point3D(8, 5, 23));

            Path3D pathThree = new Path3D();

            pathThree.Add(Point3D.StartingPoint3D);
            pathThree.Add(new Point3D(-7, 2, 21));
            pathThree.Add(new Point3D(3, 3, 0));

            List <Path3D> paths = new List <Path3D>()
            {
                pathOne,
                pathTwo,
                pathThree,
            };

            Storage.SavePaths(paths);
            Storage.LoadPaths("savedPaths.txt");
        }
コード例 #5
0
        public static Path3D GetPath3D(GameObject g, out Type pathType)
        {
            pathType = GetPathType(g);
            Path3D path = null;

            if (pathType == null)
            {
                return(path);
            }

            // Based on the path type, use the appropriate logic to get the path.

            if (pathType.Equals(typeof(QuadraticBezierPathComponent)))
            {
                path = g.GetComponent <QuadraticBezierPathComponent>().Path;
            }
            else if (pathType.Equals(typeof(CubicBezierPathComponent)))
            {
                path = g.GetComponent <CubicBezierPathComponent>().Path;
            }
            else if (pathType.Equals(typeof(DynamicBezierPathComponent)))
            {
                path = g.GetComponent <DynamicBezierPathComponent>().Path;
            }
            else if (pathType.Equals(typeof(CirclePathComponent)))
            {
                path = g.GetComponent <CirclePathComponent>().Path;
            }
            else if (pathType.Equals(typeof(LinePathComponent)))
            {
                path = g.GetComponent <LinePathComponent>().Path;
            }

            return(path);
        }
コード例 #6
0
ファイル: Storage.cs プロジェクト: dr3zz/CSharp
        public static void Write()
        {
            StreamWriter sw = null;

            try
            {
                string filePath = System.IO.Path.Combine(Environment.CurrentDirectory, Storage.fileName);;
                sw = new StreamWriter(filePath);
                Path3D points = new Path3D();

                foreach (string x in points.Points)
                {
                    sw.WriteLine(x);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                }
            }
        }
コード例 #7
0
ファイル: Path3D.cs プロジェクト: borislavtotev/SoftUniOOP
        public Path3D(Point3D point)
        {
            this.list3DPoints = new List <Point3D>();
            this.list3DPoints.Add(point);

            this.path3DString = Path3D.ListToString(this.list3DPoints);
        }
コード例 #8
0
ファイル: Storage.cs プロジェクト: nok32/SoftUni
        public static Path3D LoadPathFromFile(string filePath)
        {
            using (StreamReader reader = new StreamReader(filePath))
            {
                Path3D path = new Path3D();
                string line = reader.ReadLine();
                const string PointPattern = @"[xyz=:\-\s](\d+(?:(?:\.|,)\d+)*)";

                while (line != null)
                {
                    MatchCollection match = Regex.Matches(line, PointPattern);

                    if (match.Count == 3)
                    {
                        double x = double.Parse(match[0].Groups[1].Value);
                        double y = double.Parse(match[1].Groups[1].Value);
                        double z = double.Parse(match[2].Groups[1].Value);

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

                    line = reader.ReadLine();
                }

                return path;
            }
        }
コード例 #9
0
ファイル: Storage.cs プロジェクト: simooo93/SoftUni-Homeworks
 public static void SavePath(string destiation, Path3D path)
 {
     foreach (var point in path.Points)
     {
         File.AppendAllText(destiation, point.ToString());
     }
 }
コード例 #10
0
ファイル: Program.cs プロジェクト: AmaranthInHell/projects
        static void Main(string[] args)
        {
            Point3D one = new Point3D(1, 2, 3);
            Point3D two = new Point3D(4, 5, 6);

            Console.WriteLine(DistanceCalculator.CalculateDistance(one, two));

            Path3D path1 = new Path3D();
            Path3D path2 = new Path3D();

            path2.AddPath(two);
            path2.AddPath(one);
            path1.AddPath(one);
            path1.AddPath(two);

            Storage.SavePaths(path1);
            Storage.SavePaths(path2);

            for (int i = 0; i < Storage.LoadPaths().Count; i++)
            {
                Console.Write("Path{0}: ", i + 1);
                for (int j = 0; j < Storage.LoadPaths()[i].Points.Count; j++)
                {
                    Console.Write(Storage.LoadPaths()[i].Points[j].ToString());
                    if (j < Storage.LoadPaths()[i].Points.Count - 1)
                    {
                        Console.Write(" - ");
                    }
                }
                Console.WriteLine();
            }
        }
コード例 #11
0
        static void Main(string[] args)
        {
            Point3D one = new Point3D(1, 2, 3);
            Point3D two = new Point3D(4, 5, 6);

            Console.WriteLine(DistanceCalculator.CalculateDistance(one, two));

            Path3D path1 = new Path3D();
            Path3D path2 = new Path3D();


            path2.AddPath(two);
            path2.AddPath(one);
            path1.AddPath(one);
            path1.AddPath(two);

            Storage.SavePaths(path1);
            Storage.SavePaths(path2);

            for (int i = 0; i < Storage.LoadPaths().Count; i++)
            {
                Console.Write("Path{0}: ", i + 1);
                for (int j = 0; j < Storage.LoadPaths()[i].Points.Count; j++)
                {
                    Console.Write(Storage.LoadPaths()[i].Points[j].ToString());
                    if (j < Storage.LoadPaths()[i].Points.Count - 1)
                    {
                        Console.Write(" - ");
                    }
                }
                Console.WriteLine();
            }
        }
コード例 #12
0
        static void Main(string[] args)
        {
            var point3DFirst   = new Point3D(0, 5, 9);
            var point3DSecond  = new Point3D(4, 7, 2);
            var point3DThird   = new Point3D(96, 46, 7);
            var point3DForth   = new Point3D(1, 16, 27);
            var point3DFifth   = new Point3D(15, 1, 127);
            var point3DSixth   = new Point3D(71, 16, 217);
            var point3DSeventh = new Point3D(16, 164, 57);

            var pathFirst = new Path3D(new Point3D[]
            {
                point3DFirst,
                point3DSecond,
                point3DThird,
                point3DForth,
                point3DFifth,
                point3DSixth,
                point3DSeventh
            });

            var pathSecond = new Path3D(new Point3D[]
            {
                point3DFirst,
                point3DThird,
                point3DFifth,
                point3DSeventh
            });

            var pathThird = new Path3D(new Point3D[]
            {
                point3DSecond,
                point3DForth,
                point3DSixth
            });

            var paths = new Path3D[] { pathFirst, pathSecond, pathThird };

            var content = new StringBuilder();

            foreach (var path in paths)
            {
                content.AppendLine(path.ToString());
            }

            string contentString = content.ToString();

            Storage.SaveToFile(FileName, contentString);
            Storage.LoadFromFile(FileName);

            Storage.SaveToFile(FileName, contentString);
            Storage.LoadFromFile(FileName);

            Storage.ReplaceFileContent(FileName, contentString);
            Storage.LoadFromFile(FileName);

            Storage.DeleteFile(FileName);
            Storage.LoadFromFile(FileName);
        }
コード例 #13
0
ファイル: Storage.cs プロジェクト: borislavtotev/SoftUniOOP
        public static void AddPathToFile(string filePath, Path3D newPath)
        {
            Path3D input = Storage.LoadPaths(filePath);

            input.AddListOfPoints(newPath.list3DPoints);

            Storage.SaveToFile(input, filePath);
        }
コード例 #14
0
ファイル: Storage.cs プロジェクト: borislavtotev/SoftUniOOP
        public static void AddListOfPointsToFile(string filePath, List <Point3D> points)
        {
            Path3D input = Storage.LoadPaths(filePath);

            input.AddListOfPoints(points);

            Storage.SaveToFile(input, filePath);
        }
コード例 #15
0
ファイル: Storage.cs プロジェクト: borislavtotev/SoftUniOOP
        public static void AddPointToFile(string filePath, Point3D point)
        {
            Path3D input = Storage.LoadPaths(filePath);

            input.AddPoint(point);

            Storage.SaveToFile(input, filePath);
        }
コード例 #16
0
ファイル: Paths.cs プロジェクト: simooo93/SoftUni-Homeworks
        static void Main()
        {
            //Euclidean3D.Point3D pointOne = new Euclidean3D.Point3D(0, 0, 0);
            //Euclidean3D.Point3D pointTwo = new Euclidean3D.Point3D(1, 2, 3);
            //Euclidean3D.Point3D pointTwo = new Euclidean3D.Point3D(0, 0, 0);

            Path3D path = new Path3D(Storage.PointExtraction(loadPath));
            Storage.SavePath(savePath, path);
            Console.WriteLine(path);
        }
コード例 #17
0
ファイル: Storage.cs プロジェクト: ya-ivanov/SoftUni
        public static Path3D ToPath3D(string text) //The user uses the ReadPath result to create Point3D objects and with them, create Path3D obj
        {
            Path3D path = new Path3D();
            Regex  rgx  = new Regex(@"Point \[X:(.*?),\sY:(.*?),\sZ:(.*?)]");

            foreach (Match m in Regex.Matches(text, @"Point \[X:(.*?),\sY:(.*?),\sZ:(.*?)]"))
            {
                path.addPoint(new Point3D(Double.Parse(m.Groups[1].Value), Double.Parse(m.Groups[2].Value), Double.Parse(m.Groups[3].Value)));
            }

            return(path);
        }
コード例 #18
0
ファイル: Storage.cs プロジェクト: ya-ivanov/SoftUni
 public static void SavePath(string fileName, Path3D path) // Write the Path3D object to a text file
 {
     try
     {
         using (StreamWriter sw = new StreamWriter(fileName, false, Encoding.GetEncoding("UTF-8")))
         {
             sw.WriteLine(path.ToString());
         }
     }
     catch (Exception)
     {
         throw new Exception("Error white writing to file.");
     }
 }
コード例 #19
0
ファイル: PathTest.cs プロジェクト: nok32/SoftUni
        public static void Main()
        {
            try
            {
                Point3D point1 = new Point3D(1, 10, 1);
                Point3D point2 = new Point3D(-3, 33333, 3);
                Path3D path = new Path3D(point1, point2);

                // Storage.SavePathToFile("text.txt", path.ToString());
                Console.WriteLine("Load from file:\n" + Storage.LoadPathFromFile("text.txt"));
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine(ex.Message);
            }                    
        }
コード例 #20
0
ファイル: Paths.cs プロジェクト: ya-ivanov/SoftUni
        static void Main()
        {
            Path3D path = new Path3D(new List <Point3D> {
                new Point3D(45, 7, 3),
                new Point3D(-1, -3, 7),
                new Point3D(6, 1, 0),
                new Point3D(-5, -2, 6)
            });                                                                // Create a Path3D object

            //Console.WriteLine(path.ToString());                              // Print it to the console


            Storage.SavePath("myPath.txt", path);                              // Save it in a file
            Path3D newPath = Storage.ToPath3D(Storage.ReadPath("myPath.txt")); // Set newPath object with the Path3D objects created from the

            // contents of the text file
            Console.WriteLine(newPath.ToString());                             // Print the newPath to the console
        }
コード例 #21
0
ファイル: PathsMain.cs プロジェクト: Dochko/SoftUni
        static void Main()
        {
            List<Path3D> sequenceOfPoints = new List<Path3D>();

            Path3D pointOne = new Path3D(1.123f, 2.234f, 3.456f);
            Path3D pointTwo = new Path3D(5.678f, 6.789f, 7.890f);
            Path3D pointThree = new Path3D(0.1264f, 13.665f, 19.789f);

            sequenceOfPoints.Add(pointOne);
            sequenceOfPoints.Add(pointTwo);
            sequenceOfPoints.Add(pointThree);

            //You can delete the text file in the Debug folder and comment
            //the LoadPoints() method to check, that the program works :)
            Storage.SavePoints(sequenceOfPoints);

            Storage.LoadPoints();
        }
コード例 #22
0
ファイル: Program.cs プロジェクト: elasharda1/Homeworks
        static void Main(string[] args)
        {
            Storage.Save("7 0 13|2 17 88", "text");
            var points = new List <Point>
            {
                new Point(1, 3, 5),
                new Point(2, 3, 5),
                new Point(5, 13, 51),
                new Point(1, 3, 25),
                new Point(1, 3, 5),
                new Point(4, 3, 6),
            };

            Storage.Save(points, "text2");

            var loadedPoints = Storage.Load("text2");
            var path         = new Path3D(loadedPoints);

            Console.WriteLine(path);
        }
コード例 #23
0
        static void Main(string[] args)
        {
            string filePath = "../../3Dpaths.txt";

            Point3D pointA  = new Point3D(1, 1, 1);
            Path3D  newPath = new Path3D(pointA);

            Storage.AddPathToFile(filePath, newPath);

            Point3D pointB = new Point3D(2, 2, 2);

            Storage.AddPointToFile(filePath, pointB);

            List <Point3D> points = new List <Point3D>()
            {
                new Point3D(3, 3, 3), new Point3D(4, 4, 4), new Point3D(5, 5, 5)
            };

            Storage.AddListOfPointsToFile(filePath, points);
        }
コード例 #24
0
        static void Main(string[] args)
        {
            Storage.Save("1 2 3|12 34 4", "saved");
            var points = new List <Point>
            {
                new Point(1, 3, 5),
                new Point(2, 3, 5),
                new Point(5, 13, 51),
                new Point(1, 3, 25),
                new Point(1, 3, 5),
                new Point(4, 3, 6),
            };

            Storage.Save(points, "saved1");

            var loadedPoints = Storage.Load("saved1");
            var path         = new Path3D(loadedPoints);

            Console.WriteLine(path);
        }
コード例 #25
0
 public static void SavePaths(Path3D path)
 {
     try
     {
         string       point  = "";
         StreamWriter writer = new StreamWriter("paths.txt");
         using (writer)
         {
             for (int i = 0; i < path.Points.Count; i++)
             {
                 point += path.Points[i] + " ";
             }
             writer.WriteLine(point);
             point += Environment.NewLine;
         }
     }
     catch (IOException ioe)
     {
         Console.Error.WriteLine(ioe.Message);
     }
 }
コード例 #26
0
ファイル: Storage.cs プロジェクト: AmaranthInHell/projects
 public static void SavePaths(Path3D path)
 {
     try
     {
         string point = "";
         StreamWriter writer = new StreamWriter("paths.txt");
         using (writer)
         {
             for (int i = 0; i < path.Points.Count; i++)
             {
                 point += path.Points[i] + " ";
             }
             writer.WriteLine(point);
             point += Environment.NewLine;
         }
     }
     catch (IOException ioe)
     {
         Console.Error.WriteLine(ioe.Message);
     }
 }
コード例 #27
0
        internal static void Main()
        {
            // Generating inputs
            Point3D pointZero = Point3D.StartingPoint3D;
            Point3D pointOne = new Point3D(1.0, 1.0, 1.0);
            Point3D pointTwo = new Point3D(2.0, 2.0, 2.0);
            List<Point3D> inputList = new List<Point3D> { pointZero, pointOne, pointTwo };

            // Save to file
            Path3D pathsToSave = new Path3D(inputList);
            Storage.SavePathsToFile(pathsToSave.Paths);

            // Load from file
            Path3D pathsToLoad = new Path3D(Storage.LoadPathsFromFile());
           
            // Print the list
            Console.WriteLine("Your paths are:");
            foreach (Point3D point in pathsToLoad.Paths)
            {
                Console.WriteLine(point.ToString());
            }
        }
コード例 #28
0
        public static List <Path3D> LoadPaths()
        {
            List <Path3D> paths = new List <Path3D>();

            try
            {
                StreamReader reader = new StreamReader("paths.txt");
                using (reader)
                {
                    string line = reader.ReadLine();
                    while (line != null)
                    {
                        Path3D   path      = new Path3D();
                        string[] pointsArr = line.Split(' ');
                        foreach (var point in pointsArr)
                        {
                            if (point != string.Empty)
                            {
                                int x = Convert.ToInt32(point[0] - 48);
                                int y = Convert.ToInt32(point[2] - 48);
                                int z = Convert.ToInt32(point[4] - 48);
                                path.AddPath(new Point3D(x, y, z));
                            }
                        }
                        paths.Add(path);
                        line = reader.ReadLine();
                    }
                }
            }
            catch (IOException ioe)
            {
                Console.Error.WriteLine(ioe.Message);
            }

            return(paths);
        }
コード例 #29
0
ファイル: Path3D.cs プロジェクト: borislavtotev/SoftUniOOP
        public Path3D(string pointSequence)
        {
            this.path3DString = pointSequence;

            this.list3DPoints = Path3D.StringToList(pointSequence);
        }
コード例 #30
0
ファイル: Path3D.cs プロジェクト: borislavtotev/SoftUniOOP
        public Path3D(List <Point3D> points)
        {
            this.list3DPoints = points;

            this.path3DString = Path3D.ListToString(points);
        }