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 Genre CreateNewGenre(string name) { Genre genre = new Genre(); genre.Name = name; genre.Checked = true; Random r = new Random(); genre.Color = Color.FromArgb(r.Next(0, 255), r.Next(0, 255), r.Next(0, 255)); GenreBusiness.Set(genre); return(genre); }
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(); }
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); }