private void btnGenerate_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; try { var files = DirectoryScanner.FindFilesMatching(txtRomFolder.Text, cboRomExt.SelectedText); var games = files.Select(f => new Game { Name = Path.GetFileNameWithoutExtension(f.Name), Path = string.Format("./{0}", f.Name) }).ToList(); SetGameImages(games); var gameList = new GameList { Game = games }; var xml = ProcessXML.SaveModelToXML(gameList); System.IO.File.WriteAllText(Path.Combine(txtRomFolder.Text, "gamelist.xml"), xml); } finally { Cursor = Cursors.Default; } }
private void GeneratePreviewXML() { var files = DirectoryScanner.FindFilesMatching(txtRomFolder.Text, cboRomExt.SelectedText); var games = files.Select(f => new Game { Name = Path.GetFileNameWithoutExtension(f.Name), Path = string.Format("./{0}", f.Name) }).ToList(); var shortList = games.Take(1).ToList(); SetGameImages(shortList); var gameList = new GameList { Game = shortList }; var xml = ProcessXML.SaveModelToXML(gameList); txtXmlPreview.Text = xml; }
private void SetGameImages(List <Game> gamelist) { if (chkImagefield.Checked) { var imgDir = txtRomFolder.Text; imgDir = chkImgUseSubfolder.Checked ? Path.Combine(imgDir, txtImgSubfolder.Text) : imgDir; var piSubDir = chkImgUseSubfolder.Checked ? txtImgSubfolder.Text : ""; var imageFiles = DirectoryScanner.FindImageFiles(imgDir); foreach (var imgFile in imageFiles) { var game = gamelist.FirstOrDefault(g => g.Name == Path.GetFileNameWithoutExtension(imgFile.Name)); if (game != null) { game.Image = string.Format("./{0}/{1}", piSubDir, imgFile.Name); } } } }
private void UpdateExtensionList() { extensions.Clear(); extensions = DirectoryScanner.GetFileExtensionsInDirectory(txtRomFolder.Text); cboRomExt.DataSource = new BindingSource(extensions, null); }