Beispiel #1
0
        // constructors

        public GameListBuilder()
        {
            // instantiate new AllGames object for the first time
            AllGames = new List <DataGridGamesView>();

            // populate the object
            AllGames = GamesLibraryDataGridRefresh.Update(AllGames);

            // set initial sorting
            SortColumnName = "GAME";
            SortDirection  = ListSortDirection.Ascending;

            UpdateRequired = false;
        }
Beispiel #2
0
        public static List <DataGridGamesView> Filter(int systemId, string search)
        {
            List <DataGridGamesView> results = new List <DataGridGamesView>();
            App _App = ((App)Application.Current);

            if (_App.GamesList.UpdateRequired == true)
            {
                GamesLibraryDataGridRefresh.Update();
            }

            // system id selector
            switch (systemId)
            {
            case -1:            // favorites
                results = (from g in _App.GamesList.AllGames
                           where g.Favorite == true
                           select g).ToList();

                results = RemoveHidden(results);

                break;

            case 0:             // all games
                results = _App.GamesList.AllGames;
                results = RemoveHidden(results);


                break;

            case -100:          // unscraped games

                results = (from a in _App.GamesList.AllGames
                           where a.Coop == null &&
                           a.Developer == null &&
                           a.ESRB == null &&
                           a.Players == null
                           select a).ToList();

                results = RemoveHidden(results);


                /*
                 * var re = _App.GamesList.AllGames.ToList();
                 * List<Game> games = (from a in Game.GetGames()
                 *                  where a.isScraped != true
                 *                  select a).ToList();
                 * foreach (var ga in re)
                 * {
                 *  var i = (from b in games
                 *           where b.gameId == ga.ID
                 *           select b).ToList();
                 *  if (i.Count == 1)
                 *  {
                 *      results.Add(ga);
                 *  }
                 * }
                 */

                break;

            default:            // based on actual system id
                results = (from g in _App.GamesList.AllGames
                           where GSystem.GetSystemId(g.System) == systemId
                           select g).ToList();
                break;
            }

            // now we have results based on the system filter - process file search
            List <DataGridGamesView> srch = DoSearch(results, search);

            List <DataGridGamesView> sorted = new List <DataGridGamesView>();

            // perform sorting
            if (_App.GamesList.SortDirection == ListSortDirection.Ascending)
            {
                switch (_App.GamesList.SortColumnName.ToUpper())
                {
                case "ID":
                    sorted = srch.OrderBy(x => x.ID).ToList();
                    break;

                case "GAME":
                    sorted = srch.OrderBy(x => x.Game).ToList();
                    break;

                case "SYSTEM":
                    sorted = srch.OrderBy(x => x.System).ToList();
                    break;

                case "LASTRUN":
                    sorted = srch.OrderBy(x => x.LastPlayed).ToList();
                    break;

                case "FAV":
                    sorted = srch.OrderBy(x => x.Favorite).ToList();
                    break;

                case "YEAR":
                    sorted = srch.OrderBy(x => x.Year).ToList();
                    break;

                case "PLAYERS":
                    sorted = srch.OrderBy(x => x.Players).ToList();
                    break;

                case "CO-OP":
                    sorted = srch.OrderBy(x => x.Coop).ToList();
                    break;

                case "PUBLISHER":
                    sorted = srch.OrderBy(x => x.Publisher).ToList();
                    break;

                case "DEVELOPER":
                    sorted = srch.OrderBy(x => x.Developer).ToList();
                    break;

                case "RATING":
                    sorted = srch.OrderBy(x => x.ESRB).ToList();
                    break;

                case "COUNTRY":
                    sorted = srch.OrderBy(x => x.Country).ToList();
                    break;

                case "FLAGS":
                    sorted = srch.OrderBy(x => x.Flags).ToList();
                    break;

                case "DETECTED ROM":
                    sorted = srch.OrderBy(x => x.DatRom).ToList();
                    break;

                default:
                    sorted = srch.OrderBy(s => s.Game).ToList();
                    break;
                }
            }
            else
            {
                switch (_App.GamesList.SortColumnName.ToUpper())
                {
                case "ID":
                    sorted = srch.OrderByDescending(x => x.ID).ToList();
                    break;

                case "GAME":
                    sorted = srch.OrderByDescending(x => x.Game).ToList();
                    break;

                case "SYSTEM":
                    sorted = srch.OrderByDescending(x => x.System).ToList();
                    break;

                case "LASTRUN":
                    sorted = srch.OrderByDescending(x => x.LastPlayed).ToList();
                    break;

                case "FAV":
                    sorted = srch.OrderByDescending(x => x.Favorite).ToList();
                    break;

                case "YEAR":
                    sorted = srch.OrderByDescending(x => x.Year).ToList();
                    break;

                case "PLAYERS":
                    sorted = srch.OrderByDescending(x => x.Players).ToList();
                    break;

                case "CO-OP":
                    sorted = srch.OrderByDescending(x => x.Coop).ToList();
                    break;

                case "PUBLISHER":
                    sorted = srch.OrderByDescending(x => x.Publisher).ToList();
                    break;

                case "DEVELOPER":
                    sorted = srch.OrderByDescending(x => x.Developer).ToList();
                    break;

                case "RATING":
                    sorted = srch.OrderByDescending(x => x.ESRB).ToList();
                    break;

                case "COUNTRY":
                    sorted = srch.OrderByDescending(x => x.Country).ToList();
                    break;

                case "FLAGS":
                    sorted = srch.OrderByDescending(x => x.Flags).ToList();
                    break;

                case "DETECTED ROM":
                    sorted = srch.OrderByDescending(x => x.DatRom).ToList();
                    break;

                default:
                    sorted = srch.OrderByDescending(s => s.Game).ToList();
                    break;
                }
            }

            // trigger update in datagrid with sorting
            _App.GamesList.FilteredSet = new ObservableCollection <DataGridGamesView>(sorted);

            return(srch);
        }