Beispiel #1
0
        private void button5_Click(object sender, EventArgs e)
        {
            StringBuilder result = new StringBuilder();

            string sSymulacjaPath = "Materialy wideo\\Symulacja";
            string sRobotPath     = "Materialy wideo\\Roboty";

            string sMovieDirectory          = @"C:\Doktorat";
            string sMovieDirectorySymulacja = string.Format("{0}\\{1}", sMovieDirectory, sSymulacjaPath);
            string sMovieDirectoryRobot     = string.Format("{0}\\{1}", sMovieDirectory, sRobotPath);

            List <string> sFilePathSymulacja = new List <string>(System.IO.Directory.GetFiles(sMovieDirectorySymulacja, "*.mp4*", System.IO.SearchOption.AllDirectories));
            List <string> sFilePathRoboty    = new List <string>(System.IO.Directory.GetFiles(sMovieDirectoryRobot, "*.avi*", System.IO.SearchOption.AllDirectories));

            result.AppendLine("% Symulacja ");

            foreach (var sim in sFilePathSymulacja)
            {
                string dirName   = Path.GetDirectoryName(sim);
                string sFileName = Path.GetFileNameWithoutExtension(sim);

                string sUrlPath = string.Format("{0}\\{1}.url", dirName, sFileName);

                string sUrl = FileItem2.getFileUrl(sUrlPath);

                string sOutDir = sim.Replace(@"C:\Doktorat\", string.Empty);
                sOutDir = sOutDir.Replace("\\", "/");


                string sFormatedMP4 = formatLookupPut(Path.GetFileName(sim), string.Format("run:{0}", sOutDir));
                string sFormatedURL = formatLookupPut(string.Format("{0}.url", Path.GetFileNameWithoutExtension(sim)), sUrl);

                result.AppendLine(sFormatedMP4);
                result.AppendLine(sFormatedURL);
                result.AppendLine();
            }

            result.AppendLine();
            result.AppendLine();
            result.AppendLine("% Robot ");

            foreach (var sim in sFilePathRoboty)
            {
                string dirName   = Path.GetDirectoryName(sim);
                string sFileName = Path.GetFileNameWithoutExtension(sim);

                string sUrlPath = string.Format("{0}\\{1}.url", dirName, sFileName);

                string sUrl = FileItem2.getFileUrl(sUrlPath);

                string sOutDir = sim.Replace(@"C:\Doktorat\", string.Empty);
                sOutDir = sOutDir.Replace("\\", "/");

                string sFormatedAVI = formatLookupPut(string.Format("Robot {0}", Path.GetFileName(sim)), string.Format("run:{0}", sOutDir));
                string sFormatedURL = formatLookupPut(string.Format("Robot {0}.url", Path.GetFileNameWithoutExtension(sim)), sUrl);

                result.AppendLine(sFormatedAVI);
                result.AppendLine(sFormatedURL);
                result.AppendLine();
            }


            string temp = result.ToString();
        }
Beispiel #2
0
        private List <MapItem2> loadFileDataRobot(string sDirectory)
        {
            List <MapItem2> result = new List <MapItem2>();
            MapItem2        currentMap;

            var directories = Directory.GetDirectories(sDirectory);

            foreach (var mainItem in directories)
            {
                currentMap = new MapItem2();

                DirectoryInfo mapName = new DirectoryInfo(mainItem);

                currentMap.Name = mapName.Name;
                result.Add(currentMap);

                var mapsDirectory = Directory.GetDirectories(mainItem);

                foreach (var algoDirectory in mapsDirectory)
                {
                    var caseDirectory = Directory.GetDirectories(algoDirectory);

                    foreach (var fileItem in caseDirectory)
                    {
                        string[] files = Directory.GetFiles(fileItem, "*.avi");

                        if (files.Length != 1)
                        {
                            throw new Exception("W katalogu jest wiecje niz jeden plik lub brak pliku katalog: " + fileItem);
                        }

                        DirectoryInfo algName = new DirectoryInfo(algoDirectory);
                        FileItem2     file;

                        switch (algName.Name)
                        {
                        case "R":
                            file          = new FileItem2();
                            file.FilePath = files[0];
                            currentMap.R.Add(file);
                            break;

                        case "PF":
                            file          = new FileItem2();
                            file.FilePath = files[0];
                            currentMap.PF.Add(file);
                            break;

                        case "RVO":
                            file          = new FileItem2();
                            file.FilePath = files[0];
                            currentMap.RVO.Add(file);
                            break;

                        case "PR":
                            file          = new FileItem2();
                            file.FilePath = files[0];
                            currentMap.PR.Add(file);
                            break;

                        case "R+":
                            file          = new FileItem2();
                            file.FilePath = files[0];
                            currentMap.Rplus.Add(file);
                            break;

                        case "PF+":
                            file          = new FileItem2();
                            file.FilePath = files[0];
                            currentMap.PFplus.Add(file);
                            break;

                        default:
                            break;
                        }
                    }
                }
            }

            return(result);
        }