public void UpdateGameInfo(Game game) { lock (game.SyncRoot) { if (game.Id == null) return; associatedGame = game; Label = game.Title; thumbGroup = new ThumbGroup(game); ThumbnailImage = thumbGroup.FrontCoverDefaultPath; if (string.IsNullOrEmpty(ThumbnailImage)) ThumbnailImage = MP1Utils.DefaultLogo; ReleaseYear = game.Year; PlayCount = game.PlayCount; LastPlayed = game.Latestplay; Company = game.Developer; Grade = game.Grade; videoPreview = game.VideoPreview; if (string.IsNullOrEmpty(videoPreview) && EmulatorsCore.Options.ReadOption(o => o.FallBackToEmulatorVideo)) videoPreview = game.ParentEmulator.VideoPreview; if (!string.IsNullOrEmpty(videoPreview)) VideoPreviewId = "game" + game.Id.ToString(); } }
public static void LaunchDocument(ThumbItem item) { string manualPath; using (ThumbGroup thumbGroup = new ThumbGroup(item)) manualPath = thumbGroup.ManualPath; if (string.IsNullOrEmpty(manualPath)) return; using (Process proc = new Process()) { proc.StartInfo = new ProcessStartInfo(); proc.StartInfo.FileName = manualPath; proc.Start(); } }
public GameViewModel(Game game, EmulatorsMainModel model) { this.model = model; Game = game; Name = game.Title; Description = game.Description; using (ThumbGroup thumbs = new ThumbGroup(game)) { FrontCover = thumbs.FrontCoverDefaultPath; Fanart = thumbs.FanartDefaultPath; } Command = new MethodDelegateCommand(() => { model.GameSelected(Game); }); }
public virtual void DeleteThumbs() { using (ThumbGroup thumbs = new ThumbGroup(this)) { if (Directory.Exists(thumbs.ThumbPath)) { Logger.LogDebug("Deleting thumb folder '{0}'", thumbs.ThumbPath); try { Directory.Delete(thumbs.ThumbPath, true); } catch (Exception ex) { Logger.LogDebug("Failed to delete pre-existing thumb folder '{0}' - {1}", thumbs.ThumbPath, ex.Message); } } } }
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(); } } }
public EmulatorViewModel(Emulator emulator, EmulatorsMainModel model) { this.model = model; this.emulator = emulator; Name = emulator.Title; Description = emulator.Description; using (ThumbGroup thumbs = new ThumbGroup(emulator)) { FrontCover = thumbs.FrontCoverDefaultPath; Fanart = thumbs.FanartDefaultPath; } Command = new MethodDelegateCommand(() => { model.EmulatorSelected(emulator); }); ContextCommand = new MethodDelegateCommand(showContext); }
public ExtendedGUIListItem(DBItem item) { Game game = item as Game; if (game != null) { Sortable = true; UpdateGameInfo(game); return; } Emulator emu = item as Emulator; if (emu != null) { associatedEmulator = emu; Label = emu.Title; thumbGroup = new ThumbGroup(emu); ThumbnailImage = thumbGroup.FrontCoverDefaultPath; if (string.IsNullOrEmpty(ThumbnailImage)) ThumbnailImage = MP1Utils.DefaultLogo; videoPreview = emu.VideoPreview; if (!string.IsNullOrEmpty(videoPreview)) VideoPreviewId = "emu" + emu.Id.ToString(); return; } RomGroup group = item as RomGroup; if (group != null) { romGroup = group; Label = group.Title; IsGroup = true; IsFavourites = group.Favourite; if (group.ThumbGroup != null) { thumbGroup = group.ThumbGroup; ThumbnailImage = thumbGroup.FrontCoverDefaultPath; } if (string.IsNullOrEmpty(ThumbnailImage)) ThumbnailImage = MP1Utils.DefaultLogo; } }
void setGameArt(ThumbGroup thumbGroup) { bool lAllowEvents = allowChangedEvents; allowChangedEvents = false; pnlLogo.ThumbGroup = thumbGroup; pnlFanart.ThumbGroup = thumbGroup; allowChangedEvents = lAllowEvents; }
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; }
//Selects next Match from approved match lists. //Updates the Game with the specified Match details and commits void processNextApprovedMatch(bool priorityOnly) { RomMatch romMatch = takeFromList(approvedMatches, priorityApprovedMatches, priorityOnly); if (romMatch == null) return; Scraper selectedScraper; ScraperResult selectedMatch; lock (romMatch.SyncRoot) { if (!romMatch.OwnedByThread()) return; selectedScraper = romMatch.GameDetails.DataProvider; selectedMatch = romMatch.GameDetails; } if (!doWork) return; retrieveProgress("Updating: " + romMatch.Path); ScraperGame scraperGame = scraperProvider.DownloadInfo(selectedMatch); if (!doWork || !romMatch.OwnedByThread()) return; using (ThumbGroup thumbGroup = new ThumbGroup(romMatch.Game)) { using (SafeImage image = getImage(scraperGame.BoxFrontUrl, romMatch)) if (!saveImage(image, romMatch, thumbGroup, ThumbType.FrontCover)) return; using (SafeImage image = getImage(scraperGame.BoxBackUrl, romMatch)) if (!saveImage(image, romMatch, thumbGroup, ThumbType.BackCover)) return; using (SafeImage image = getImage(scraperGame.TitleScreenUrl, romMatch)) if (!saveImage(image, romMatch, thumbGroup, ThumbType.TitleScreen)) return; using (SafeImage image = getImage(scraperGame.InGameUrl, romMatch)) if (!saveImage(image, romMatch, thumbGroup, ThumbType.InGameScreen)) return; using (SafeImage image = getImage(scraperGame.FanartUrl, romMatch)) if (!saveImage(image, romMatch, thumbGroup, ThumbType.Fanart)) return; } lock (romMatch.SyncRoot) { if (!romMatch.OwnedByThread()) return; romMatch.ScraperGame = scraperGame; commitGame(romMatch); if (!doWork) return; } addToList(romMatch, RomMatchStatus.Committed, commitedMatches, null); }
void dBListView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { //if no items are selected, or we have just started selecting multiple items, clear the panel. //With multiple selections, only call the below code on the 2nd selection otherwise it will be //called for every new item added - which is unnecessary and expensive. if (dBListView.SelectedItems.Count == 2) { selectedGame = null; selectedListItem = null; if (itemThumbs != null) { itemThumbs.Dispose(); itemThumbs = null; } clearPanel(); return; } //When the user changes selection in the list view the SelectionChanged event is fired twice, //once for the item losing selection and once for the item gaining it, ensure we only //update once. if (!e.IsSelected || dBListView.SelectedItems.Count > 1) return; updateGame(); selectedListItem = dBListView.SelectedItems[0]; setRomToPanel(selectedListItem); }
//update panel with Game info void setRomToPanel(ListViewItem listViewItem) { saveSelectedGame = false; saveThumbs = false; saveDiscs = false; savePCSettings = false; Game dbRom = listViewItem.Tag as Game; selectedGame = dbRom; if (dbRom == null) return; allowChangedEvents = false; if (dbRom.ParentEmulator.IsPc()) { if (!tabControl1.TabPages.Contains(pcSettingsTab)) tabControl1.TabPages.Insert(1, pcSettingsTab); } else tabControl1.TabPages.Remove(pcSettingsTab); //update ThumbGroup if (itemThumbs != null) itemThumbs.Dispose(); itemThumbs = new ThumbGroup(dbRom); if (tabControl1.SelectedTab == thumbsTab) { setGameArt(itemThumbs); //load thumbs to panels thumbsLoaded = true; } else { setGameArt(null); thumbsLoaded = false; } idLabel.Text = dbRom.Id.ToString(); txt_Title.Text = dbRom.Title; txt_company.Text = dbRom.Developer; txt_description.Text = dbRom.Description; txt_yearmade.Text = dbRom.Year.ToString(); txt_genre.Text = dbRom.Genre; gradeUpDown.Value = dbRom.Grade; txt_Manual.Text = itemThumbs.ManualPath; //chk_Visible.Checked = dbRom.Visible; chk_Favourite.Checked = dbRom.Favourite; videoTextBox.Text = dbRom.VideoPreview; playCountLabel.Text = dbRom.PlayCount.ToString(); lastPlayLabel.Text = dbRom.Latestplay.ToShortDateString(); loadProfileDropdown(dbRom); discBindingSource.Clear(); if (dbRom.Discs.Count > 0) { int? selectedDisc = dbRom.CurrentDisc.Id; //int number = 1; foreach (GameDisc disc in dbRom.Discs) { //disc.Number = number++; if (disc.Id == selectedDisc) disc.Selected = true; discBindingSource.Add(disc); } } setPCSettings(dbRom); allowChangedEvents = 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; } } }
void setGameArt(ThumbGroup thumbGroup) { bool lAllowEvents = allowChangedEvents; allowChangedEvents = false; pnlBoxFront.ThumbGroup = thumbGroup; pnlBoxBack.ThumbGroup = thumbGroup; pnlTitleScreen.ThumbGroup = thumbGroup; pnlInGameScreen.ThumbGroup = thumbGroup; pnlFanart.ThumbGroup = thumbGroup; allowChangedEvents = lAllowEvents; }
void clearForm() { allowChangedEvents = false; saveSelectedEmulator = false; saveProfile = false; saveThumbs = false; txt_Title.Text = ""; platformComboBox.SelectedIndex = 0; romDirTextBox.Text = ""; filterTextBox.Text = ""; idLabel.Text = ""; txt_company.Text = ""; txt_description.Text = ""; txt_yearmade.Text = ""; gradeUpDown.Value = 0; thumbAspectComboBox.Text = ""; videoTextBox.Text = ""; txt_Manual.Text = ""; clearProfileForm(); if (emuThumbs != null) { emuThumbs.Dispose(); emuThumbs = null; } pnlLogo.ThumbGroup = null; pnlFanart.ThumbGroup = null; allowChangedEvents = true; }
//Updates the panels with the selected Emulator's details. private void setEmulatorToPanel(ListViewItem listViewItem) { //reset status flags saveSelectedEmulator = false; saveThumbs = false; saveProfile = false; //get the selected Emulator Emulator dbEmu = listViewItem.Tag as Emulator; selectedEmulator = dbEmu; if (dbEmu == null) return; allowChangedEvents = false; int index = platformComboBox.FindStringExact(dbEmu.Platform); if (index < 0) index = 0; platformComboBox.SelectedIndex = index; //.SelectedItem = platformComboBox.Items[index]; txt_Title.Text = dbEmu.Title; romDirTextBox.Text = dbEmu.PathToRoms; filterTextBox.Text = dbEmu.Filter; txt_company.Text = dbEmu.Developer; txt_yearmade.Text = dbEmu.Year.ToString(); txt_description.Text = dbEmu.Description; gradeUpDown.Value = dbEmu.Grade; EmuAutoConfig.SetupAspectDropdown(thumbAspectComboBox, dbEmu.CaseAspect); videoTextBox.Text = dbEmu.VideoPreview; idLabel.Text = dbEmu.Id.ToString(); if (emuThumbs != null) emuThumbs.Dispose(); emuThumbs = new ThumbGroup(dbEmu); if (mainTabControl.SelectedTab == thumbsTabPage) { setGameArt(emuThumbs); thumbsLoaded = true; } else { setGameArt(null); thumbsLoaded = false; } txt_Manual.Text = emuThumbs.ManualPath; selectedProfile = null; profileComboBox.Items.Clear(); foreach (EmulatorProfile profile in selectedEmulator.EmulatorProfiles) { profileComboBox.Items.Add(profile); if (profile.IsDefault) { profileComboBox.SelectedItem = profile; selectedProfile = profile; } } allowChangedEvents = true; profileComboBox_SelectedIndexChanged(profileComboBox, new EventArgs()); }
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); }
void clearPanel() { allowChangedEvents = false; idLabel.Text = ""; txt_Title.Text = ""; txt_company.Text = ""; txt_description.Text = ""; txt_yearmade.Text = ""; txt_genre.Text = ""; gradeUpDown.Value = 0; txt_Manual.Text = ""; chk_Favourite.Checked = false; videoTextBox.Text = ""; playCountLabel.Text = ""; lastPlayLabel.Text = ""; profileComboBox.Items.Clear(); setGameArt(null); if (itemThumbs != null) { itemThumbs.Dispose(); itemThumbs = null; } discBindingSource.Clear(); allowChangedEvents = true; }