public void launchGame(Game Game) { var game = new FileInfo(Game.getRomPath()); string command = string.Format(this.getCommandTemplate(), game.FullName); string emuPath; if (File.Exists(Environment.CurrentDirectory + this.getEmulatorPath())) emuPath = Environment.CurrentDirectory + this.getEmulatorPath(); else emuPath = this.getEmulatorPath(); Program.Play = new Process() { StartInfo = new ProcessStartInfo() { FileName = emuPath, WorkingDirectory = new FileInfo(emuPath).Directory.FullName, WindowStyle = ProcessWindowStyle.Normal, Arguments = command, } }; var startTime = DateTime.Now; Program.Play.Start(); Program.Play.WaitForExit(); Game.registerTime(DateTime.Now, (int)DateTime.Now.Subtract(startTime).TotalSeconds); }
private void BulkFromDirectoryToolStripMenuItem_Click(object sender, EventArgs e) { // Init move as false - Let's not delete the originals without permission ;) bool move = false; // As for permission to delete originals (move is way quicker than just a raw copy.) if (MessageBox.Show("Do you want to delete the original files?", "Import Options", MessageBoxButtons.YesNo) == DialogResult.Yes) // if yes, set move to true/ move = true; // Initialise a folder browser dialog to get a directory to import form. var dia = new FolderBrowserDialog(); string dir = ""; // dir = selected dir if (dia.ShowDialog() == DialogResult.OK) dir = dia.SelectedPath; // Foreach file in the selected directory foreach (string s in Directory.GetFiles(dir, "*")) { // get info on file var fi = new FileInfo(s); // init a new game Game g; // Get the platform for it. string platform = DataManagement.getPlatform(s); // If we found one if (platform != null) { // create a new game g = new Game(new string[] { s, fi.Name.Replace(fi.Extension, "").Replace(".", ""), platform, move.ToString() }); } } // reloads all UI elements. reload(); }