Ejemplo n.º 1
0
        private void btnStart_Click(object sender, System.EventArgs e)
        {
            btnCancel.Enabled = false;
            btnCancel.Refresh(); //Hack

            //Create the directory if it doesn't exist already.
            Directory.CreateDirectory(textDestinationDir.Text);

            string[] archiveFolders = Directory.GetDirectories(textSourceDir.Text);
            if (archiveFolders.Length == 0)
            {
                statusLabel.Text = "No sub-directories found, check source dir!";
                return;
            }

            Console.WriteLine("Hold onto your hats, crunching {0} folders!", archiveFolders.Length);
            statusLabel.Text = "Unpacking archives...";
            statusLabel.Refresh(); //Hack
            progressBar.Maximum = archiveFolders.Length;
            progressBar.Refresh(); //Hack

            foreach (string subFolder in archiveFolders)
            {
                string[] files      = Directory.GetFiles(subFolder, "*.arc");
                string   folderName = new System.IO.DirectoryInfo(subFolder).Name;

                string folderFilepath = textDestinationDir.Text;
                if (Directory.Exists(folderFilepath + "\\\\" + folderName + ".wrkDir"))
                {
                    Console.WriteLine("Folder {0} already unpacked, skipping...", subFolder);
                    continue;
                }

                if (files.Length == 0)
                {
                    Console.WriteLine("No archive found in subfolder {0}, skipping...", subFolder);
                    continue;
                }

                MainEditor.CreateWorkingDirFromArchive(files, folderName, folderFilepath);
                progressBar.Value++;
                progressBar.Refresh();
            }

            string[] extractedProjects = Directory.GetDirectories(textDestinationDir.Text);

            statusLabel.Text = "Extraction complete. Beginning tests on " + extractedProjects.Length + "...";
            statusLabel.Refresh(); //Hack
            progressBar.Maximum = extractedProjects.Length;
            progressBar.Value   = 0;

            _outputDir = textDestinationDir.Text;
            File.Delete(_outputDir + "//results.txt");

            foreach (string projDir in extractedProjects)
            {
                _mainEditor.OpenFileFromWorkingDir(projDir, true);

                progressBar.Value++;
                progressBar.Refresh(); //Hack
            }

            Console.WriteLine("Automated tests completed.");
            statusLabel.Text  = "Completed.";
            progressBar.Value = 0;
            btnCancel.Enabled = true;
        }