protected override void DoTask(NavigationContext context) { if (!getParameters(context)) return; SetProgress(string.Format("Looking up {0}", platformStr), 0); var platform = importer.GetPlatformByName(platformStr); if (platform != null) { SetProgress(string.Format("Retrieving info for {0}", platform.Name), 33); var platformInfo = importer.GetPlatformInfo(platform.Id); if (platformInfo != null) { System.Threading.Thread.Sleep(2000); SetProgress(string.Format("Updating {0}", emulator.Title), 67); emulator.Title = platformInfo.Title; emulator.Developer = platformInfo.Developer; emulator.Description = platformInfo.GetDescription(); using (ThumbGroup thumbGroup = new ThumbGroup(emulator)) { using (SafeImage image = ImageHandler.SafeImageFromWeb(platformInfo.LogoUrl)) { if (image != null) { thumbGroup.Logo.SetSafeImage(image.Image); thumbGroup.SaveThumb(ThumbType.Logo); } } using (SafeImage image = ImageHandler.SafeImageFromWeb(platformInfo.FanartUrl)) { if (image != null) { thumbGroup.Fanart.SetSafeImage(image.Image); thumbGroup.SaveThumb(ThumbType.Fanart); } } } emulator.Commit(); } } }
bool saveImage(SafeImage image, RomMatch romMatch, ThumbGroup thumbGroup, ThumbType thumbType) { if (!doWork) return false; lock (romMatch.SyncRoot) { if (!romMatch.OwnedByThread()) return false; if (image != null) { thumbGroup.GetThumbObject(thumbType).SetSafeImage(image.Image); thumbGroup.SaveThumb(thumbType); } } return true; }
private void newEmuButton_Click(object sender, EventArgs e) { newEmu = null; using (Wzd_NewEmu_Main wzd = new Wzd_NewEmu_Main(platformImporter)) { if (wzd.ShowDialog() == DialogResult.OK) newEmu = wzd.NewEmulator; if (newEmu != null) { updateEmulator(); updateProfile(); newEmu.Commit(); if (Importer != null) Importer.Restart(); using (ThumbGroup thumbGroup = new ThumbGroup(newEmu)) { if (wzd.Logo != null) { thumbGroup.Logo.SetSafeImage(wzd.Logo.Image); thumbGroup.SaveThumb(ThumbType.Logo); } if (wzd.Fanart != null) { thumbGroup.Fanart.SetSafeImage(wzd.Fanart.Image); thumbGroup.SaveThumb(ThumbType.Fanart); } } ListViewItem item = new ListViewItem(newEmu.Title) { Tag = newEmu }; emulatorListView.Items.Add(item); selectedListItem = item; emulatorListView.SelectedItems.Clear(); if (selectedListItem != null) selectedListItem.Selected = true; else if (emulatorListView.Items.Count > 0) emulatorListView.Items[0].Selected = true; updateEmuPositions = true; } } }
private void updateInfoButton_Click(object sender, EventArgs e) { if (selectedEmulator == null) return; updateEmulator(); updateProfile(); PlatformInfo profileInfo = PlatformScraperHandler.GetPlatformInfo(selectedEmulator.Platform, platformImporter, p => { if (!string.IsNullOrEmpty(p.Title)) selectedEmulator.Title = p.Title; if (!string.IsNullOrEmpty(p.Developer)) selectedEmulator.Developer = p.Developer; int grade; if (!string.IsNullOrEmpty(p.Grade) && int.TryParse(p.Grade, out grade)) selectedEmulator.Grade = grade; string description = p.GetDescription(); if (!string.IsNullOrEmpty(description)) selectedEmulator.Description = description; using (ThumbGroup thumbGroup = new ThumbGroup(selectedEmulator)) { if (!string.IsNullOrEmpty(p.LogoUrl)) { thumbGroup.Logo.Path = p.LogoUrl; thumbGroup.SaveThumb(ThumbType.Logo); } if (!string.IsNullOrEmpty(p.FanartUrl)) { thumbGroup.Fanart.Path = p.FanartUrl; thumbGroup.SaveThumb(ThumbType.Fanart); } } selectedEmulator.Commit(); return true; }); if (profileInfo != null) setEmulatorToPanel(selectedListItem); }