private void buttonDelete_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count < 1) { return; } RomLabel label = (RomLabel)dataGridView.SelectedRows[0].Tag; if (MessageBox.Show(string.Format("Do you want do delete the label {0} ?", label.Name), "Warning", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } int romCount = RomLabelsBusiness.GetAll().Where(x => x.Labels.Any(l => l == label.Name)).Count(); if (romCount > 0) { FormCustomMessage.ShowError(string.Format("The label {0} is associated with {1} roms. You cannot delete it.", label.Name, romCount)); return; } foreach (DataGridViewRow item in dataGridView.SelectedRows) { RomLabelBusiness.Delete(item.Cells[0].Value.ToString()); dataGridView.Rows.Remove(item); } Updated = true; Clean(); }
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); } } }
public static void InitXml() { XML.LoadXmlConfig(); XML.LoadXmlGenres(); XML.LoadXmlLabels(); XML.LoadXmlPlatforms(); XML.LoadXmlRoms(); XML.LoadXmlRomStatus(); XML.LoadXmlRomLabels(); RomLabelBusiness.Fill(); GenreBusiness.Fill(); PlatformBusiness.Fill(); RomStatusBusiness.Fill(); RomLabelsBusiness.Fill(); RomBusiness.Fill(); }
private static bool Delete(Rom rom) { RomList.Remove(rom); if (rom.Status != null) { RomStatusBusiness.DeleteRomStatus(rom.Status); XML.SaveXmlRomStatus(); } if (rom.RomLabels != null) { RomLabelsBusiness.DeleteRomLabels(rom.Platform.Name, rom.FileName); XML.SaveXmlRomLabels(); } return(XML.DelRom(rom.Platform.Name, rom.FileName)); }
private void changeLabelsToolStripMenuItem_Click(object sender, EventArgs e) { try { if (dataGridView.SelectedRows.Count == 0) { return; } List <RomLabel> selectedLabels = new List <RomLabel>(); List <RomLabel> unselectedLabels = new List <RomLabel>(); RomLabels labels = ((Rom)dataGridView.SelectedRows[0].Tag).RomLabels; List <Rom> roms = new List <Rom>(); foreach (DataGridViewRow row in dataGridView.SelectedRows) { roms.Add((Rom)row.Tag); } if (!FormChooseList.ChooseLabel(roms, out selectedLabels, out unselectedLabels)) { return; } RomLabelsBusiness.SetRomLabel(roms, selectedLabels, unselectedLabels); foreach (DataGridViewRow row in dataGridView.SelectedRows) { FillLabelCell((Rom)row.Tag, row); } dataGridView.Refresh(); } catch (Exception ex) { FormCustomMessage.ShowError(ex.Message); } }
public static Rom SetRom(Rom rom, string id, string fileName, string romName, string series, string genre, string status, List <RomLabel> labels, string publisher, string developer, string description, string year, string dbName, string rating, bool idLocked, bool changeZipName, string boxPath, string titlePath, string gameplayPath, bool saveAsJpg, string emulator) { rom.Genre = string.IsNullOrEmpty(genre) ? null : GenreBusiness.Get(genre); string oldfile = rom.FileName; rom.Id = id; rom.Name = romName; rom.Publisher = publisher; rom.Developer = developer; rom.Description = description; rom.YearReleased = year; rom.DBName = dbName; rom.Series = series; rom.IdLocked = idLocked; rom.Emulator = emulator; float ratingParse = 0; if (float.TryParse(rating, out ratingParse)) { if (ratingParse > 0 && ratingParse <= 10) { rom.Rating = ratingParse; } } RomFunctions.RenameRomPictures(rom, fileName); RomFunctions.RenameRomFile(rom, fileName, changeZipName); if (string.IsNullOrEmpty(rom.Id)) { rom.DBName = string.Empty; } if (oldfile != rom.FileName) { Set(rom, oldfile); if (rom.Status != null) { RomStatusBusiness.DeleteRomStatus(rom.Status); rom.Status = null; } if (rom.RomLabels != null) { RomLabelsBusiness.DeleteRomLabels(rom.Platform.Name, oldfile); rom.RomLabels = null; } } else { Set(rom); } RomFunctions.SaveRomPictures(rom, boxPath, titlePath, gameplayPath, saveAsJpg); RomLabelsBusiness.SetRomLabel(rom, labels, null); RomStatusBusiness.SetRomStatus(rom, status); XML.SaveXmlRoms(rom.Platform.Name); rom.FileNameNoExt = RomFunctions.GetFileNameNoExtension(romName); return(rom); }