예제 #1
0
        void updateEmuInfo()
        {
            EmulatorInfo lEmuInfo = new EmulatorScraperHandler().UpdateEmuInfo(platformComboBox.Text, (o) =>
            {
                EmulatorInfo emuInfo = (EmulatorInfo)o;
                if (logo != null)
                {
                    logo.Dispose();
                    logo = null;
                }
                if (fanart != null)
                {
                    fanart.Dispose();
                    fanart = null;
                }
                logo   = ImageHandler.BitmapFromWeb(emuInfo.LogoUrl);
                fanart = ImageHandler.BitmapFromWeb(emuInfo.FanartUrl);
                return(true);
            });

            if (lEmuInfo != null)
            {
                txt_Title.Text       = lEmuInfo.Title;
                txt_company.Text     = lEmuInfo.Developer;
                txt_description.Text = lEmuInfo.GetDescription();
                int grade;
                if (int.TryParse(lEmuInfo.Grade, out grade))
                {
                    gradeUpDown.Value = grade;
                }

                return;
            }
        }
예제 #2
0
        public EmulatorInfo GetInfo(string platformId)
        {
            if (!TryLoadPlatforms())
            {
                return(null);
            }

            Platform platform = _platforms.FirstOrDefault(p => p.Id.ToString() == platformId);

            if (platform == null)
            {
                return(null);
            }

            EmulatorInfo emuInfo = new EmulatorInfo();

            emuInfo.Title     = platform.Name;
            emuInfo.Developer = platform.Developer;
            //emuInfo.Grade = HttpUtility.HtmlDecode(a.InnerText);
            emuInfo.Overview       = platform.Overview;
            emuInfo.CPU            = platform.Cpu;
            emuInfo.Memory         = platform.Memory;
            emuInfo.Graphics       = platform.Graphics;
            emuInfo.Sound          = platform.Sound;
            emuInfo.Display        = platform.Display;
            emuInfo.Media          = platform.Media;
            emuInfo.MaxControllers = platform.MaxControllers;
            //baseImageUrl = a.InnerXml;
            //emuInfo.FanartUrl = baseImageUrl + a.InnerXml;
            //emuInfo.LogoUrl = baseImageUrl + a.InnerXml;

            return(emuInfo);
        }
        EmulatorInfo updateEmuInfo(string platformText, string selectedKey, Dictionary <string, string> emuInfos, Func <object, bool> completedDelegate)
        {
            EmulatorInfo emuInfo   = null;
            bool         completed = false;

            BackgroundTaskHandler handler = new BackgroundTaskHandler();

            handler.ActionDelegate = () =>
            {
                handler.ExecuteProgressHandler(0, "Looking up platforms...");
                string selectedId;
                if (emuInfos == null || string.IsNullOrEmpty(selectedKey))
                {
                    emuInfos = new EmulatorScraper().GetEmulators(platformText, out selectedKey);
                    if (selectedKey == null || !emuInfos.TryGetValue(selectedKey, out selectedId))
                    {
                        return;
                    }
                }
                else if (!emuInfos.TryGetValue(selectedKey, out selectedId))
                {
                    return;
                }

                handler.ExecuteProgressHandler(33, "Retrieving info for " + selectedKey);
                emuInfo = new EmulatorScraper().GetInfo(selectedId);
                if (emuInfo == null)
                {
                    return;
                }

                handler.ExecuteProgressHandler(67, "Updating " + emuInfo.Title);

                if (completedDelegate != null)
                {
                    completed = completedDelegate(emuInfo);
                }
                else
                {
                    completed = true;
                }
            };

            using (Conf_ProgressDialog progressDlg = new Conf_ProgressDialog(handler))
                progressDlg.ShowDialog();

            if (completed)
            {
                return(emuInfo);
            }

            if (emuInfos != null && string.IsNullOrEmpty(selectedKey))
            {
                using (Conf_EmuLookupDialog lookupDlg = new Conf_EmuLookupDialog(emuInfos))
                {
                    if (lookupDlg.ShowDialog() == DialogResult.OK && lookupDlg.SelectedKey != null)
                    {
                        return(updateEmuInfo(null, lookupDlg.SelectedKey, emuInfos, completedDelegate));
                    }
                }
            }
            else
            {
                MessageBox.Show("Error retrieving online info.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return(null);
        }
예제 #4
0
        void updateEmuInfo()
        {
            if (selectedEmulator == null)
            {
                return;
            }

            updateEmulator();
            updateProfile();

            EmulatorInfo lEmuInfo = new EmulatorScraperHandler().UpdateEmuInfo(selectedEmulator.PlatformTitle, (o) =>
            {
                EmulatorInfo emuInfo = (EmulatorInfo)o;
                if (emuInfo == null)
                {
                    return(false);
                }

                if (!string.IsNullOrEmpty(emuInfo.Title))
                {
                    selectedEmulator.Title = emuInfo.Title;
                }

                if (!string.IsNullOrEmpty(emuInfo.Developer))
                {
                    selectedEmulator.Company = emuInfo.Developer;
                }

                int grade;
                if (!string.IsNullOrEmpty(emuInfo.Grade) && int.TryParse(emuInfo.Grade, out grade))
                {
                    selectedEmulator.Grade = grade;
                }

                string description = emuInfo.GetDescription();
                if (!string.IsNullOrEmpty(description))
                {
                    selectedEmulator.Description = description;
                }

                using (ThumbGroup thumbGroup = new ThumbGroup(selectedEmulator))
                {
                    if (!string.IsNullOrEmpty(emuInfo.LogoUrl))
                    {
                        thumbGroup.FrontCover.Path = emuInfo.LogoUrl;
                        thumbGroup.SaveThumb(ThumbType.FrontCover);
                    }
                    if (!string.IsNullOrEmpty(emuInfo.FanartUrl))
                    {
                        thumbGroup.Fanart.Path = emuInfo.FanartUrl;
                        thumbGroup.SaveThumb(ThumbType.Fanart);
                    }
                }

                selectedEmulator.Save();
                return(true);
            });

            if (lEmuInfo != null)
            {
                setEmulatorToPanel(selectedListItem);
            }
        }