Esempio n. 1
0
        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 changeStatusToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (dataGridView.SelectedRows.Count == 0)
                {
                    return;
                }

                RomStatus status      = ((Rom)dataGridView.SelectedRows[0].Tag).Status;
                var       statusvalue = status == null ? "" : status.Status;
                string    newstatus   = "";

                if (!FormChoose.ChooseStatus(statusvalue, out newstatus))
                {
                    return;
                }

                List <Rom> romList = new List <Rom>();

                foreach (DataGridViewRow row in dataGridView.SelectedRows)
                {
                    var rom = (Rom)row.Tag;
                    romList.Add(rom);
                }

                RomStatusBusiness.SetRomStatus(romList, newstatus);

                foreach (DataGridViewRow row in dataGridView.SelectedRows)
                {
                    Rom rom = (Rom)row.Tag;

                    if (rom.Status != null && !string.IsNullOrEmpty(rom.Status.Status))
                    {
                        row.Cells[columnStatus.Index].Value           = rom.Status.Status;
                        row.Cells[columnStatus.Index].Style.BackColor = Color.Navy;
                        row.Cells[columnStatus.Index].Style.ForeColor = Color.White;
                    }
                    else
                    {
                        row.Cells[columnStatus.Index].Value           = "";
                        row.Cells[columnStatus.Index].Style.ForeColor = dataGridView.RowTemplate.DefaultCellStyle.ForeColor;
                        row.Cells[columnStatus.Index].Style.BackColor = dataGridView.RowTemplate.DefaultCellStyle.BackColor;
                    }
                }

                dataGridView.Refresh();
            }
            catch (Exception ex)
            {
                FormCustomMessage.ShowError(ex.Message);
            }
        }
Esempio n. 3
0
 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();
 }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        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);
        }