Ejemplo n.º 1
0
        public void LoadFavorites()
        {
            if (!File.Exists(FavoritesFile))
            {
                return;
            }

            FavoriteROMs.Clear();

            using (StreamReader reader = new StreamReader(FavoritesFile))
            {
                while (!reader.EndOfStream)
                {
                    string   line          = reader.ReadLine();
                    string[] systemAndGame = line.Split(',');
                    string   system        = systemAndGame[0].Trim();
                    string   game          = systemAndGame[1].Trim();

                    ROMImage rom = new ROMImage(game, GameSystems.Find(sys => sys.Name == system));
                    FavoriteROMs.Add(rom);
                }
            }

            UpdateFavoritesButton();
        }
Ejemplo n.º 2
0
        private ROMImageList LoadROMs(GameSystem system)
        {
            if (!Directory.Exists(system.ROMsFolder))
            {
                MessageBox.Show(
                    "The ROM folder configured for this system does not exist.",
                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return(null);
            }

            DirectoryInfo dir = new DirectoryInfo(system.ROMsFolder);

            FileInfo[]   files      = dir.GetFiles();
            string[]     extensions = system.ROMExtensions.Split('|');
            ROMImageList roms       = new ROMImageList();

            foreach (FileInfo file in files)
            {
                foreach (string ext in extensions)
                {
                    if (!file.Name.Trim().ToLower().EndsWith("." + ext.Trim().ToLower()))
                    {
                        continue;
                    }

                    roms.Add(new ROMImage(file.Name, system));
                }
            }

            return(roms);
        }