private void buttonChangeISOtoCHD_Click(object sender, EventArgs e) { if (comboBoxPlatform.Text == "") { return; } Platform platform = PlatformBusiness.Get(comboBoxPlatform.Text); var roms = RomBusiness.GetAll(platform); int count = 0; foreach (var rom in roms) { if (rom.FileName.EndsWith(".cue")) { var chdpath = platform.DefaultRomPath + "\\" + rom.FileNameNoExt + ".chd"; if (File.Exists(chdpath)) { var old = rom.FileName; rom.FileName = rom.FileNameNoExt + ".chd"; RomBusiness.SetRom(rom, old); count++; } } } MessageBox.Show(count.ToString() + " roms updated"); }
public static void Fill() { RomList = new List <Rom>(); var platformnames = Directory.GetDirectories(Values.PlatformsPath); if (!Directory.Exists(Values.PlatformsPath)) { Directory.CreateDirectory(Values.PlatformsPath); } foreach (var platformname in platformnames) { var name = platformname.Replace(Values.PlatformsPath + "\\", ""); var romNodes = XML.GetRomNodes(name); if (romNodes == null) { continue; } foreach (XmlNode node in romNodes) { Rom rom = new Rom(); rom.FileName = Functions.GetXmlAttribute(node, "FileName"); rom.FileNameNoExt = RomFunctions.GetFileNameNoExtension(rom.FileName); rom.Id = Functions.GetXmlAttribute(node, "Id"); rom.Name = Functions.GetXmlAttribute(node, "Name"); rom.DBName = Functions.GetXmlAttribute(node, "DBName"); rom.Platform = PlatformBusiness.Get(Functions.GetXmlAttribute(node, "Platform")); rom.Genre = GenreBusiness.Get(Functions.GetXmlAttribute(node, "Genre")); rom.Publisher = Functions.GetXmlAttribute(node, "Publisher"); rom.Developer = Functions.GetXmlAttribute(node, "Developer"); rom.YearReleased = Functions.GetXmlAttribute(node, "YearReleased"); rom.Description = Functions.GetXmlAttribute(node, "Description"); var idLocked = Functions.GetXmlAttribute(node, "IdLocked"); rom.IdLocked = string.IsNullOrEmpty(idLocked) ? false : Convert.ToBoolean(idLocked); var favorite = Functions.GetXmlAttribute(node, "Favorite"); rom.Favorite = string.IsNullOrEmpty(favorite) ? false : Convert.ToBoolean(favorite); rom.Emulator = Functions.GetXmlAttribute(node, "Emulator"); rom.Series = Functions.GetXmlAttribute(node, "Series"); float result = 0; if (float.TryParse(Functions.GetXmlAttribute(node, "Rating"), out result)) { rom.Rating = result; } rom.Status = RomStatusBusiness.Get(rom.Platform.Name, rom.FileName); rom.RomLabels = RomLabelsBusiness.Get(rom.Platform.Name, rom.FileName); RomList.Add(rom); } } }
private void buttonCleanIncorrectRomPlatform_Click(object sender, EventArgs e) { if (comboBoxPlatform.Text == "" || comboBoxPlatform.Text == "none") { FormCustomMessage.ShowError("Select a platform"); } var json = RomFunctions.GetPlatformJson(comboBoxPlatform.Text); if (json == "") { return; } var roms = RomBusiness.GetAll(PlatformBusiness.Get(comboBoxPlatform.Text)); int count = 0; List <Rom> romsUpdate = new List <Rom>(); foreach (var rom in roms) { if (string.IsNullOrEmpty(rom.Id)) { continue; } if (!json.Contains("\"id\": " + rom.Id + ",")) { rom.Id = ""; rom.Name = rom.FileNameNoExt; rom.DBName = ""; rom.Description = ""; rom.IdLocked = false; rom.Publisher = ""; rom.YearReleased = ""; rom.Developer = ""; rom.Rating = 0; romsUpdate.Add(rom); count++; Updated = true; } } RomBusiness.SetRom(romsUpdate); FormCustomMessage.ShowSuccess("Roms updated successfully! " + count.ToString() + " roms cleaned"); }
private void buttonRescan_Click(object sender, EventArgs e) { if (comboBoxPlatform.SelectedItem == null || comboBoxPlatform.SelectedIndex == 1) { FormCustomMessage.ShowError("No platform selected."); return; } var platform = PlatformBusiness.Get(comboBoxPlatform.Text); var result = PlatformBusiness.RescanRoms(platform); if (result) { FilterRoms(); } }
private void buttonUpdateAllRomsNames_Click(object sender, EventArgs e) { try { if (comboBoxPlatform.Text == "" || comboBoxPlatform.Text == "none") { FormCustomMessage.ShowError("Select a platform"); } Platform platform = PlatformBusiness.Get(comboBoxPlatform.Text); var roms = RomBusiness.GetAll(platform); int count = 0; List <Rom> romsUpdate = new List <Rom>(); foreach (var rom in roms) { var name = RomFunctions.GetMAMENameFromCSV(rom.FileNameNoExt); if (name == "") { continue; } if (rom.Name != name) { rom.Name = name; romsUpdate.Add(rom); count++; } } RomBusiness.SetRom(romsUpdate); FormCustomMessage.ShowSuccess("Rom names updated successfully! Total:" + count.ToString()); Updated = true; } catch (Exception ex) { //FormWait.CloseWait(); FormCustomMessage.ShowError(ex.Message); } finally { //FormWait.CloseWait(); } }
private void buttonShowMissingRoms_Click(object sender, EventArgs e) { try { if (comboBoxPlatform.Text == "" || comboBoxPlatform.Text == "none") { FormCustomMessage.ShowError("Select a platform"); } Platform platform = PlatformBusiness.Get(comboBoxPlatform.Text); var json = RomFunctions.GetPlatformJson(comboBoxPlatform.Text); if (string.IsNullOrEmpty(json)) { FormCustomMessage.ShowError("Json not found. Sync platform first"); } var games = APIFunctions.GetGamesListByPlatform(platform.Id, json, platform.Name); var roms = RomBusiness.GetAll(platform); StringBuilder builder = new StringBuilder(""); foreach (var game in games) { if (!roms.Any(x => x.Id == game.Id)) { builder.Append(game.Id + "-" + game.DBName + Environment.NewLine); } } FormInfo info = new FormInfo(builder.ToString()); info.Show(); Updated = true; } catch (Exception ex) { //FormWait.CloseWait(); FormCustomMessage.ShowError(ex.Message); } finally { //FormWait.CloseWait(); } }
private void buttonUpdateNameFromDBName_Click(object sender, EventArgs e) { try { if (comboBoxPlatform.Text == "" || comboBoxPlatform.Text == "none") { FormCustomMessage.ShowError("Select a platform"); } Platform platform = PlatformBusiness.Get(comboBoxPlatform.Text); var roms = RomBusiness.GetAll(platform); int count = 0; List <Rom> romsUpdate = new List <Rom>(); foreach (var rom in roms) { if (!string.IsNullOrEmpty(rom.DBName)) { var newname = rom.DBName.Replace(":", " -"); if (rom.Name != newname) { rom.Name = newname; romsUpdate.Add(rom); count++; } } } RomBusiness.SetRom(romsUpdate); FormCustomMessage.ShowSuccess("Rom names updated successfully! Total:" + count.ToString()); Updated = true; } catch (Exception ex) { //FormWait.CloseWait(); FormCustomMessage.ShowError(ex.Message); } finally { //FormWait.CloseWait(); } }
private void buttonChangePath_Click(object sender, EventArgs e) { var dir = Environment.CurrentDirectory + "\\" + Values.PlatformsPath; var dirs = Directory.GetDirectories(dir); foreach (var item in dirs) { var platformname = item.Substring(item.LastIndexOf("\\") + 1); var platform = PlatformBusiness.Get(platformname); var file = item + "\\roms.xml"; if (!File.Exists(file)) { continue; } var text = File.ReadAllText(file); text = text.Replace("Path=", "FileName="); text = text.Replace(platform.DefaultRomPath + "\\", ""); File.WriteAllText(file, text); } }
private void toolStripButtonRemoveInvalid_Click(object sender, EventArgs e) { try { if (comboBoxPlatform.SelectedValue != null) { RomFunctions.RemoveInvalidRomsEntries(PlatformBusiness.Get(comboBoxPlatform.SelectedValue.ToString())); } else { RomFunctions.RemoveInvalidRomsEntries(); } FilterRoms(); } catch (OperationCanceledException ioex) { return; } catch (Exception ex) { FormCustomMessage.ShowError(ex.Message); } }
private void buttonAdd_Click(object sender, EventArgs e) { Platform platform = null; int index = -1; updating = true; if (string.IsNullOrEmpty(textBoxPlatformName.Text.Trim())) { FormCustomMessage.ShowError("Can not save without a valid name."); return; } if (textBoxPlatformName.Enabled) { if (PlatformBusiness.Get(textBoxPlatformName.Text.Trim()) != null) { FormCustomMessage.ShowError("A platform with this name already exists."); return; } } if (!string.IsNullOrEmpty(textBoxDefaultRomPath.Text) && string.IsNullOrEmpty(textBoxDefaultRomExtensions.Text)) { FormCustomMessage.ShowError("Default rom extensions must also be filled"); return; } if (textBoxPlatformName.Enabled) { platform = new Platform(); } else { DataGridViewRow row = dataGridView.SelectedRows[0]; index = row.Index; platform = (Platform)row.Tag; textBoxPlatformName.Enabled = true; buttonAdd.Text = "Add"; } platform.Id = comboBoxPlatformsDB.SelectedValue.ToString(); platform.Name = textBoxPlatformName.Text.Trim(); platform.Color = buttonColor.BackColor; platform.ShowInFilter = checkBoxShowInFilters.Checked; platform.ShowInList = checkBoxShowInLinksList.Checked; platform.DefaultRomPath = textBoxDefaultRomPath.Text; platform.DefaultRomExtensions = textBoxDefaultRomExtensions.Text.Replace(".", ""); platform.UseRetroarch = checkBoxUseRetroarch.Checked; platform.DefaultEmulator = defaultEmulator; platform.Arcade = checkBoxArcade.Checked; platform.Console = checkBoxConsole.Checked; platform.Handheld = checkBoxHandheld.Checked; platform.CD = checkBoxCD.Checked; platform.Emulators = emulators; platform.IconPath = textBoxPlatformIcon.Text; PlatformBusiness.Set(platform); AddToGrid(platform, index); Updated = true; updating = false; Clean(); }