コード例 #1
0
        private void LoadInitialCard()
        {
            var path = Extensions.Unescape(_pcsx2Ui.Read("Folders", "MemoryCards"));

            if (path == "memcards")
            {
                path = Path.Combine(Settings.Default.pcsx2DataDir, "memcards");
            }
            if (!Directory.Exists(path))
            {
                var dialog = new FolderBrowserDialog {
                    Description = "Select the directory containing the memory card files"
                };
                if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    Close();
                    return;
                }
                tbCardPath.Text = dialog.SelectedPath;
            }
            else
            {
                tbCardPath.Text = path;
            }
            foreach (var newItem in Directory.GetFiles(tbCardPath.Text, "*.ps2").Select(str2 => new FileInfo(str2)).Select(info => new Legacy.MemoryCard {
                Name = info.Name,
                WriteTime = info.LastWriteTime.ToShortDateString(),
                Size = Legacy.Tools.GetSizeReadable2(info.Length)
            }))
            {
                lvMemCards.Items.Add(newItem);
            }
        }
コード例 #2
0
        private async void LoadBios()
        {
            var currentBios = Extensions.Unescape(pcsx2_ui.Read("Filenames", "BIOS"));
            var bioses      = new List <Legacy.Bios>();
            await Task.Run(delegate {
                foreach (var str in Directory.GetFiles(Settings.Default.pcsx2DataDir + @"\bios"))
                {
                    using (var reader = new StreamReader(str)) {
                        string str2;
                        while ((str2 = reader.ReadLine()) != null)
                        {
                            if (str2.Contains("ROMconf"))
                            {
                                var bytes = (from i in Encoding.UTF8.GetBytes(str2)
                                             where i != 0
                                             select i).ToArray <byte>();
                                var src  = Encoding.UTF8.GetString(bytes);
                                var str4 = Extensions.Between(src, (string)"OSDSYS", (string)"@rom");
                                if (Extensions.IsEmpty(str4))
                                {
                                    str4 = Extensions.Between(src, (string)"OSDSYS", (string)"@");
                                }
                                var item = new Legacy.Bios {
                                    DisplayInfo = GetValue(str4),
                                    Tag         = str,
                                    Location    = str
                                };
                                bioses.Add(item);
                            }
                        }
                    }
                }
            });

            bioses.ForEach(b => lbBios.Items.Add(b));
            var enumerator = ((IEnumerable)lbBios.Items).GetEnumerator();

            try {
                while (enumerator.MoveNext())
                {
                    var current = enumerator.Current;
                    var bios    = (Legacy.Bios)current;
                    if (bios.Tag.ToString() != currentBios)
                    {
                        continue;
                    }
                    lbBios.SelectedItem = bioses;
                    return;
                }
            }
            finally {
                var disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
        }