public void Remove(GamesLibraryModel item) { this._lstItems.Remove(item); this.OnNotifyCollectionChanged( new NotifyCollectionChangedEventArgs( NotifyCollectionChangedAction.Remove, item)); }
public static void RestoreSelectedRow() { GamesLibraryModel m = SelectedGame; // iterate through each row in the datagrid int count = DG.Items.Count; for (int i = 0; i < count; i++) { GamesLibraryModel game = DG.Items[i] as GamesLibraryModel; if (game.ID == m.ID) { /* * GamesLibraryModel lo = DG.Items.CurrentItem as GamesLibraryModel; * if (lo != null && game.ID != lo.ID) * { * // selection has skipped on 1 entry to far * //SelectRowByIndex(DG, (i - 1)); * DG.Items.MoveCurrentToPrevious(); * } * else * { * // match found * * SelectRowByIndex(DG, i); * } */ SelectRowByIndex(DG, i); break; } } }
public void Add(GamesLibraryModel item) { this._lstItems.Add(item); this.OnNotifyCollectionChanged( new NotifyCollectionChangedEventArgs( NotifyCollectionChangedAction.Add, item)); }
public void AddUpdateEntry(Game game) { //List<LibraryDataGDBLink> links = LibraryDataGDBLink.GetLibraryData().ToList(); if (game != null) { // see if game is already in collection var search = (from a in _DataCollection where a.ID == game.gameId select a).FirstOrDefault(); if (search == null) { // game does not exist in the view - add it GamesLibraryModel glm = CreateModelFromGame(game);//, links); DataCollection.Add(glm); } else { // game exists in the view - update it UpdateEntries(new List <Game> { game }); } } }
public void UpdateEntries(List <Game> games) { //List<LibraryDataGDBLink> links = LibraryDataGDBLink.GetLibraryData().ToList(); foreach (var game in games) { var g = DataCollection.Where(a => a.ID == game.gameId).FirstOrDefault(); if (g == null) { continue; } App _App = (App)Application.Current; using (_App.GamesLibrary.LibraryView.DeferRefresh()) { DataCollection.Remove(g); GamesLibraryModel glm = CreateModelFromGame(game);//, links); DataCollection.Add(glm); } // because we have effectively removed a game from the collection and re-added it // the indecies will be off. go back one. _App.GamesLibrary.LibraryView.View.MoveCurrentToPrevious(); } }
/* * * SEARCH FILTER * * */ public void Search(object item, FilterEventArgs e) { if (String.IsNullOrEmpty(_App.GamesLibrary.SearchText)) { e.Accepted = false; return; } GamesLibraryModel g = e.Item as GamesLibraryModel; if (g != null) { if (g.Game != null && g.Game.ToUpper() != "" && g.Game.ToUpper().Contains(_App.GamesLibrary.SearchText.ToUpper()) || g.Flags != null && g.Flags.ToUpper() != "" && g.Flags.ToUpper().Contains(_App.GamesLibrary.SearchText.ToUpper()) || g.Year != null && g.Year.ToUpper() != "" && g.Year.ToUpper().Contains(_App.GamesLibrary.SearchText.ToUpper()) //|| //g.DatName != null && g.DatName.ToUpper() != "" && g.DatName.ToUpper().Contains(_App.GamesLibrary.SearchText.ToUpper()) || //g.DatRom != null && g.DatRom.ToUpper() != "" && g.DatRom.ToUpper().Contains(_App.GamesLibrary.SearchText.ToUpper()) || //g.ID.ToString().ToUpper() != "" && g.ID.ToString().ToUpper().Contains(_App.GamesLibrary.SearchText.ToUpper()) ) { e.Accepted = true; } else { e.Accepted = false; } } }
public void ShowUnscraped(object sender, FilterEventArgs e) { GamesLibraryModel g = e.Item as GamesLibraryModel; if (g != null) { if (g.Coop == null && g.ESRB == null && g.Players == null) { // possibly not scraped - check for psx string system = g.System; int sysId = GSystem.GetSystemIdSubFirst(system); if (GSystem.GetSystemCode(sysId).ToLower() != "psx") { e.Accepted = true; } else { e.Accepted = false; } } else { e.Accepted = false; } } }
/* * * SYSTEM FILTERS * (Multually exclusive with each other but NOT other types of filter) * * */ public void ShowFavorites(object sender, FilterEventArgs e) { GamesLibraryModel g = e.Item as GamesLibraryModel; if (g != null) { e.Accepted = (g.Favorite) ? true : false; } }
public void ShowLynx(object sender, FilterEventArgs e) { GamesLibraryModel g = e.Item as GamesLibraryModel; if (g != null) { int sysId = GSystem.GetSystemIdSubFirst(g.System); e.Accepted = (sysId == 3) ? true : false; } }
public void AddEntries(List <Game> games) { //List<LibraryDataGDBLink> links = LibraryDataGDBLink.GetLibraryData().ToList(); foreach (var game in games) { GamesLibraryModel glm = CreateModelFromGame(game);//, links); DataCollection.Add(glm); } }
public void CountryJPN(object sender, FilterEventArgs e) { GamesLibraryModel g = e.Item as GamesLibraryModel; if (g != null) { if (g.Country != null) { e.Accepted = (g.Country.ToUpper().Contains("J")) ? true : false; } else { e.Accepted = false; } } }
public static GamesLibraryModel CreateModelFromGame(Game game)//, List<LibraryDataGDBLink> links) { /* * if (links == null) * links = LibraryDataGDBLink.GetLibraryData().ToList(); */ GamesLibraryModel d = new GamesLibraryModel(); d.ID = game.gameId; // check for subsystem if (game.subSystemId != null && game.subSystemId > 0) { string subName = GSystem.GetSubSystemName(game.subSystemId.Value); d.System = subName; } else { d.System = GSystem.GetSystemName(game.systemId); } d.LastPlayed = DbEF.FormatDate(game.gameLastPlayed); d.Favorite = game.isFavorite; d.Country = game.Country; if (game.romNameFromDAT != null) { /* * if (game.romNameFromDAT.Contains("(USA)")) * d.Country = "USA"; * if (game.romNameFromDAT.Contains("(Europe)")) * d.Country = "EUR"; * if (game.romNameFromDAT.Contains("(Japan)")) * d.Country = "JPN"; */ } d.Flags = game.OtherFlags; d.Language = game.Language; d.Publisher = game.Publisher; d.Developer = game.Developer; d.Year = game.Year; d.Coop = game.Coop; d.ESRB = game.ESRB; d.Players = game.Players; d.Year = game.Year; if (game.ManualEditSet == true) { if (game.gameNameEdited != null && game.gameNameEdited != "") { d.Game = game.gameNameEdited; } } else { if (game.gameNameFromDAT != null && game.gameNameFromDAT != "") { d.Game = game.gameNameFromDAT; } else { d.Game = game.gameName; } } //d.Game = game.gameName; /* * if (game.gameNameFromDAT != null && game.gameNameFromDAT != "") * d.Game = game.gameNameFromDAT; * else * d.Game = game.gameName; */ //d.DatName = game.gameNameFromDAT; d.DatRom = game.romNameFromDAT; /* * if (game.gdbId != null && game.gdbId > 0) * { * var link = links.Where(x => x.GDBId == game.gdbId).SingleOrDefault(); // LibraryDataGDBLink.GetLibraryData(game.gdbId.Value); * if (link != null) * { * if (link.Publisher != null && link.Publisher != "") * d.Publisher = link.Publisher; * * d.Developer = link.Developer; * * if (link.Year != null && link.Year != "") * d.Year = DbEF.ReturnYear(link.Year); * d.Players = link.Players; * d.Coop = link.Coop; * d.ESRB = link.ESRB; * } * } */ //d.Year = "2914"; // last minute region detection if ((d.Country == null || d.Country.Trim() == "") && d.Game != null) { if (d.Game.Contains("(Japan)")) { d.Country = "Japan"; } if (d.Game.Contains("(Europe)")) { d.Country = "Europe"; } if (d.Game.Contains("(USA)")) { d.Country = "USA"; } if (d.Game.Contains("(Usa, Europe)")) { d.Country = "USA, Europe"; } // goodtools if (d.Game.Contains("(W)")) { d.Country = "World"; } if (d.Game.Contains("(U)")) { d.Country = "USA"; } if (d.Game.Contains("(As)")) { d.Country = "Asia"; } if (d.Game.Contains("(E)")) { d.Country = "Europe"; } } return(d); }