ContainsCategory() public méthode

Check whether the game includes the given category
public ContainsCategory ( Category c ) : bool
c Category Category to look for
Résultat bool
 void AddGameToMultiCatCheckStates( GameInfo game, bool first )
 {
     foreach( ListViewItem catItem in lstMultiCat.Items ) {
         if( catItem.StateImageIndex != 2 ) {
             Category cat = catItem.Tag as Category;
             if( cat != null ) {
                 if( first ) {
                     catItem.StateImageIndex = game.ContainsCategory( cat ) ? 1 : 0;
                 } else {
                     if( game.ContainsCategory( cat ) ) {
                         if( catItem.StateImageIndex == 0 ) catItem.StateImageIndex = 2;
                     } else {
                         if( catItem.StateImageIndex == 1 ) catItem.StateImageIndex = 2;
                     }
                 }
             }
         }
     }
 }
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (games == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }

            if (db == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_DBNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameDB);
            }

            if (game == null)
            {
                Logger.Error(GlobalStrings.Log_AutoCat_GameNull);
                return(AutoCatResult.Failure);
            }

            if (!db.Contains(game.Id, out DatabaseEntry entry) || entry.LastStoreScrape == 0)
            {
                return(AutoCatResult.NotInDatabase);
            }

            if (!game.IncludeGame(filter))
            {
                return(AutoCatResult.Filtered);
            }

            if (RemoveAllCategories)
            {
                game.ClearCategories();
            }
            else if (RemoveCategories != null)
            {
                List <Category> removed = new List <Category>();

                foreach (string category in RemoveCategories)
                {
                    Category c = gamelist.GetCategory(category);
                    if (game.ContainsCategory(c))
                    {
                        game.RemoveCategory(c);
                        removed.Add(c);
                    }
                }

                foreach (Category c in removed)
                {
                    if (c.Count == 0)
                    {
                        gamelist.RemoveCategory(c);
                    }
                }
            }

            if (AddCategories != null)
            {
                foreach (string category in AddCategories)
                // add Category, or create it if it doesn't exist
                {
                    game.AddCategory(gamelist.GetCategory(GetProcessedString(category)));
                }
            }

            return(AutoCatResult.Success);
        }
        /// <summary>
        /// Adds an entry to the game list representing the given game.
        /// </summary>
        /// <param name="g">The game the new entry should represent.</param>
        private void AddGameToList( GameInfo g )
        {
            string catName = g.GetCatStringExcept( gameData.FavoriteCategory, GlobalStrings.MainForm_Uncategorized );

            ListViewItem item;

            // Shortcut games do not show internal identifier
            string strId = ( g.Id < 0 ) ? GlobalStrings.MainForm_External : g.Id.ToString();

            item = new ListViewItem( new string[] { strId, g.Name, catName, g.ContainsCategory( gameData.FavoriteCategory ) ? "X" : String.Empty, g.Hidden ? "X" : String.Empty } );

            item.Tag = g;

            // Shortcut games show with italic font.
            if( g.Id < 0 )
                item.Font = new Font( item.Font, item.Font.Style | FontStyle.Italic );
            lstGames.Items.Add( item );
        }
 /// <summary>
 /// Checks to see if a game should currently be displayed, based on the state of the category list.
 /// </summary>
 /// <param name="g">Game to check</param>
 /// <returns>True if it should be displayed, false otherwise</returns>
 bool ShouldDisplayGame( GameInfo g )
 {
     if( !gameData.Games.ContainsKey( g.Id ) ) {
         return false;
     }
     if( lstCategories.SelectedItem == null ) {
         return false;
     }
     if( lstCategories.SelectedItem is string ) {
         if( (string)lstCategories.SelectedItem == GlobalStrings.MainForm_All ) {
             return true;
         }
         if( (string)lstCategories.SelectedItem == GlobalStrings.MainForm_Uncategorized ) {
             return !g.HasCategoriesExcept( gameData.FavoriteCategory );
         }
     } else if( lstCategories.SelectedItem is Category ) {
         return g.ContainsCategory( lstCategories.SelectedItem as Category );
     }
     return false;
 }
 void AddGameToCheckboxStates( GameInfo game, bool first )
 {
     ignoreCheckChanges = true;
     if( first ) {
         chkFavorite.CheckState = game.ContainsCategory( gameData.FavoriteCategory ) ? CheckState.Checked : CheckState.Unchecked;
         chkHidden.CheckState = game.Hidden ? CheckState.Checked : CheckState.Unchecked;
     } else {
         if( chkFavorite.CheckState != CheckState.Indeterminate ) {
             if( game.ContainsCategory( gameData.FavoriteCategory ) ) {
                 if( chkFavorite.CheckState == CheckState.Unchecked ) chkFavorite.CheckState = CheckState.Indeterminate;
             } else {
                 if( chkFavorite.CheckState == CheckState.Checked ) chkFavorite.CheckState = CheckState.Indeterminate;
             }
         }
         if( game.Hidden ) {
             if( chkHidden.CheckState == CheckState.Unchecked ) chkHidden.CheckState = CheckState.Indeterminate;
         } else {
             if( chkHidden.CheckState == CheckState.Checked ) chkHidden.CheckState = CheckState.Indeterminate;
         }
     }
     ignoreCheckChanges = false;
 }
        /// <summary>
        /// Checks to see if a game should currently be displayed, based on the state of the category list.
        /// </summary>
        /// <param name="g">Game to check</param>
        /// <returns>True if it should be displayed, false otherwise</returns>
        bool ShouldDisplayGame( GameInfo g ) {
            if( currentProfile == null ) return false;
            if( txtSearch.Text != string.Empty && g.Name.IndexOf( txtSearch.Text, StringComparison.CurrentCultureIgnoreCase ) == -1 ) return false;
            if( !currentProfile.GameData.Games.ContainsKey( g.Id ) ) return false;
            if( g.Id < 0 && !currentProfile.IncludeShortcuts ) return false;

            if( lstCategories.SelectedItems.Count == 0 ) return false;


            if( AdvancedCategoryFilter ) {
                return ShouldDisplayGameAdvanced( g );
            }

            if (g.Hidden)
            {
                return (lstCategories.SelectedItems[0].Tag.ToString() == GlobalStrings.MainForm_Hidden);
            }


            if( lstCategories.SelectedItems[0].Tag is Category ) {
                return g.ContainsCategory( lstCategories.SelectedItems[0].Tag as Category );
            } else {
                if( lstCategories.SelectedItems[0].Tag.ToString() == GlobalStrings.MainForm_All ) {
                    return true;
                }
                if( lstCategories.SelectedItems[0].Tag.ToString() == GlobalStrings.MainForm_Uncategorized ) {
                    return !g.HasCategories();
                }
            }

            return false;
        }
        public override AutoCatResult CategorizeGame(GameInfo game, Filter filter)
        {
            if (games == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_GamelistNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList);
            }
            if (db == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_DBNull);
                throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameDB);
            }
            if (game == null)
            {
                Program.Logger.Write(LoggerLevel.Error, GlobalStrings.Log_AutoCat_GameNull);
                return AutoCatResult.Failure;
            }

            if (!db.Contains(game.Id) || db.Games[game.Id].LastStoreScrape == 0) return AutoCatResult.NotInDatabase;

            if (!game.IncludeGame(filter)) return AutoCatResult.Filtered;

            if (RemoveAllCategories) game.ClearCategories();
            else if (RemoveCategories != null)
            {
                List<Category> removed = new List<Category>();

                foreach (string category in RemoveCategories)
                {
                    Category c = gamelist.GetCategory(category);
                    if (game.ContainsCategory(c))
                    {
                        game.RemoveCategory(c);
                        removed.Add(c);
                    }
                }

                foreach (Category c in removed)
                {
                    if (c.Count == 0)
                    {
                        gamelist.RemoveCategory(c);
                    }
                }
            } 

            if (AddCategories != null)
            {
                foreach (string category in AddCategories)
                {
                    // add Category, or create it if it doesn't exist
                    game.AddCategory(gamelist.GetCategory(GetProcessedString(category)));
                }
            }

            return AutoCatResult.Success;
        }