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; List<string> gameFlags = db.GetFlagList( game.Id ); if( gameFlags == null ) gameFlags = new List<string>(); IEnumerable<string> categories = gameFlags.Intersect( IncludedFlags ); foreach( string catString in categories ) { Category c = games.GetCategory( GetProcessedString( catString ) ); game.AddCategory( c ); } return AutoCatResult.Success; }
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)) return AutoCatResult.NotInDatabase; string cat = game.Name.Substring(0, 1); cat = cat.ToUpper(); if (SkipThe && cat == "T" && game.Name.Substring(0, 4).ToUpper() == "THE ") cat = game.Name.Substring(4, 1).ToUpper(); if (GroupNumbers && Char.IsDigit(cat[0])) cat = "#"; if (Prefix!=null) cat = Prefix + cat; game.AddCategory(games.GetCategory(cat)); return AutoCatResult.Success; }
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 ) ) return AutoCatResult.NotInDatabase; if (!game.IncludeGame(filter)) return AutoCatResult.Filtered; int year = db.GetReleaseYear( game.Id ); if( year > 0 || IncludeUnknown ) { game.AddCategory( games.GetCategory( GetProcessedString( year ) ) ); } return AutoCatResult.Success; }
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 ) ) return AutoCatResult.NotInDatabase; if (!game.IncludeGame(filter)) return AutoCatResult.Filtered; return AutoCatResult.Success; }
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( RemoveOtherGenres && genreCategories != null ) { game.RemoveCategory( genreCategories ); } List<string> genreList = db.GetGenreList( game.Id, depth:MAX_PARENT_DEPTH, tagFallback:TagFallback ); if( genreList != null && genreList.Count > 0 ) { List<Category> categories = new List<Category>(); int max = MaxCategories; for( int i = 0; i < genreList.Count && ( MaxCategories == 0 || i < max ); i++ ) { if( !IgnoredGenres.Contains( genreList[i] ) ) { categories.Add( games.GetCategory( GetProcessedString( genreList[i] ) ) ); } else { max++; // ignored genres don't contribute to max } } game.AddCategory( categories ); } return AutoCatResult.Success; }
private void ApplyFilter(Filter f) { if (AdvancedCategoryFilter) { // reset Advanced settings advFilter = new Filter(ADVANCED_FILTER); // load new Advanced settings foreach (ListViewItem i in lstCategories.Items) { if (i.Tag.ToString() == GlobalStrings.MainForm_Uncategorized) { i.StateImageIndex = f.Uncategorized; advFilter.Uncategorized = f.Uncategorized; } else if (i.Tag.ToString() == GlobalStrings.MainForm_Hidden) { i.StateImageIndex = f.Hidden; advFilter.Hidden = f.Hidden; } else { if (f.Allow.Contains(((Category)i.Tag))) { i.StateImageIndex = (int)AdvancedFilterState.Allow; advFilter.Allow.Add((Category)i.Tag); } else if (f.Require.Contains(((Category)i.Tag))) { i.StateImageIndex = (int)AdvancedFilterState.Require; advFilter.Require.Add((Category)i.Tag); } else if (f.Exclude.Contains(((Category)i.Tag))) { i.StateImageIndex = (int)AdvancedFilterState.Exclude; advFilter.Exclude.Add((Category)i.Tag); } else { i.StateImageIndex = (int)AdvancedFilterState.None; } } } OnViewChange(); } }
/// <summary> /// Applies this autocategorization scheme to the game with the given ID. /// </summary> /// <param name="gameId">The game ID to process</param> /// <returns>False if the game was not found in database. This allows the calling function to potentially re-scrape data and reattempt.</returns> public virtual AutoCatResult CategorizeGame( int gameId, Filter filter ) { if( games.Games.ContainsKey( gameId ) ) { return CategorizeGame( games.Games[gameId], filter ); } return AutoCatResult.Failure; }
/// <summary> /// Applies this autocategorization scheme to the game with the given ID. /// </summary> /// <param name="game">The GameInfo object to process</param> /// <returns>False if the game was not found in database. This allows the calling function to potentially re-scrape data and reattempt.</returns> public abstract AutoCatResult CategorizeGame( GameInfo game, Filter filter );
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 ) ) return AutoCatResult.NotInDatabase; if (!game.IncludeGame(filter)) return AutoCatResult.Filtered; int score = db.Games[game.Id].ReviewPositivePercentage; int reviews = db.Games[game.Id].ReviewTotal; string result = null; foreach( UserScore_Rule rule in Rules ) { if( CheckRule( rule, score, reviews ) ) { result = rule.Name; break; } } if( result != null ) { result = GetProcessedString( result ); game.AddCategory( games.GetCategory( result ) ); } return AutoCatResult.Success; }
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 ) ) return AutoCatResult.NotInDatabase; if (!game.IncludeGame(filter)) return AutoCatResult.Filtered; string result = null; float hltbMain = db.Games[game.Id].HltbMain/60.0f; float hltbExtras = db.Games[game.Id].HltbExtras/60.0f; float hltbCompletionist = db.Games[game.Id].HltbCompletionist/60.0f; if (IncludeUnknown && hltbMain == 0.0f && hltbExtras == 0.0f && hltbCompletionist == 0.0f) result = UnknownText; else { foreach (Hltb_Rule rule in Rules) { if (CheckRule(rule, hltbMain, hltbExtras, hltbCompletionist)) { result = rule.Name; break; } } } if( result != null ) { result = GetProcessedString( result ); game.AddCategory( games.GetCategory( result ) ); } return AutoCatResult.Success; }
public bool IncludeGame(Filter f) { if (f == null) return true; bool isCategorized = false; bool isHidden = false; if (f.Uncategorized != (int)AdvancedFilterState.None) isCategorized = HasCategories(); if (f.Hidden != (int)AdvancedFilterState.None) isHidden = Hidden; if (f.Uncategorized == (int)AdvancedFilterState.Require && isCategorized) return false; if (f.Hidden == (int)AdvancedFilterState.Require && !isHidden) return false; if (f.Uncategorized == (int)AdvancedFilterState.Exclude && !isCategorized) return false; if (f.Hidden == (int)AdvancedFilterState.Exclude && isHidden) return false; if (f.Uncategorized == (int)AdvancedFilterState.Allow || f.Hidden == (int)AdvancedFilterState.Allow || f.Allow.Count > 0) { if (f.Uncategorized != (int)AdvancedFilterState.Allow || isCategorized) { if (f.Hidden != (int)AdvancedFilterState.Allow || !isHidden) { if (!Categories.Overlaps(f.Allow)) return false; } } } if (!Categories.IsSupersetOf(f.Require)) return false; if (Categories.Overlaps(f.Exclude)) return false; return true; }
/// <summary> /// Gets the Filter with the given name. If the Filter does not exist, creates it. /// </summary> /// <param name="name">Name to get the Filter for</param> /// <returns>A Filter with the given name. Null if any error is encountered.</returns> public Filter GetFilter(string name) { // Filters must have a name if (string.IsNullOrEmpty(name)) return null; // Look for a matching Filter in the list and return if found foreach (Filter f in Filters) { if (String.Equals(f.Name, name, StringComparison.OrdinalIgnoreCase)) return f; } // Create a new Filter and return it Filter newFilter = new Filter(name); Filters.Add(newFilter); return newFilter; }
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 ) ) return AutoCatResult.NotInDatabase; if (!game.IncludeGame(filter)) return AutoCatResult.Filtered; int score = db.Games[game.Id].ReviewPositivePercentage; int reviews = db.Games[game.Id].ReviewTotal; if( UseWilsonScore && reviews > 0 ) { // calculate the lower bound of the Wilson interval for 95 % confidence // see http://www.evanmiller.org/how-not-to-sort-by-average-rating.html // $$ w^\pm = \frac{1}{1+\frac{z^2}{n}} // \left( \hat p + \frac{z^2}{2n} \pm z \sqrt{ \frac{\hat p (1 - \hat p)}{n} + \frac{z^2}{4n^2} } \right)$$ // where // $\hat p$ is the observed fraction of positive ratings (proportion of successes), // $n$ is the total number of ratings (the sample size), and // $z$ is the $1-{\frac {\alpha}{2}}$ quantile of a standard normal distribution // for 95% confidence, the $z = 1.96$ double z = 1.96; // normal distribution of (1-(1-confidence)/2), i.e. normal distribution of 0.975 for 95% confidence double p = score / 100.0; double n = reviews; p = Math.Round( 100 * ( (p + z*z/(2*n) - z * Math.Sqrt((p*(1-p) + z*z/(4*n)) / n)) / (1 + z*z/n) ) ); // debug: System.Windows.Forms.MessageBox.Show("score " + score + " of " + reviews + " is\tp = " + p + "\n"); score = Convert.ToInt32( p ); } string result = null; foreach( UserScore_Rule rule in Rules ) { if( CheckRule( rule, score, reviews ) ) { result = rule.Name; break; } } if( result != null ) { result = GetProcessedString( result ); game.AddCategory( games.GetCategory( result ) ); } return AutoCatResult.Success; }
private void RenameFilter(Filter f) { if (AdvancedCategoryFilter) { GetStringDlg dlg = new GetStringDlg(f.Name, string.Format(GlobalStrings.MainForm_RenameFilter, f.Name), GlobalStrings.MainForm_EnterNewName, GlobalStrings.MainForm_Rename); if (dlg.ShowDialog() == DialogResult.OK && f.Name != dlg.Value) { if (currentProfile.GameData.FilterExists(dlg.Value)) { MessageBox.Show(GlobalStrings.MainForm_FilterExists, GlobalStrings.Gen_Warning, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } f.Name = dlg.Value; RefreshFilters(); cboFilter.SelectedItem = f; cboFilter.Text = f.Name; } } }
void DeleteFilter(Filter f) { if ((!ProfileLoaded) || (!AdvancedCategoryFilter)) return; DialogResult res; res = MessageBox.Show(string.Format(GlobalStrings.MainForm_DeleteFilter, f.Name), GlobalStrings.DBEditDlg_Confirm, MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (res == DialogResult.Yes) { try { currentProfile.GameData.Filters.Remove(f); AddStatus(string.Format(GlobalStrings.MainForm_FilterDeleted, f.Name)); RefreshFilters(); } catch { MessageBox.Show(string.Format(GlobalStrings.MainForm_CouldNotDeleteFilter), GlobalStrings.Gen_Warning, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
public override AutoCatResult CategorizeGame(GameInfo game, Filter filter) { if (games == null) { Logger.Instance.Error(GlobalStrings.Log_AutoCat_GamelistNull); throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameList); } if (db == null) { Logger.Instance.Error(GlobalStrings.Log_AutoCat_DBNull); throw new ApplicationException(GlobalStrings.AutoCatGenre_Exception_NoGameDB); } if (game == null) { Logger.Instance.Error(GlobalStrings.Log_AutoCat_GameNull); return(AutoCatResult.Failure); } if (!db.Contains(game.Id)) { return(AutoCatResult.NotInDatabase); } if (!game.IncludeGame(filter)) { return(AutoCatResult.Filtered); } int score = db.Games[game.Id].ReviewPositivePercentage; int reviews = db.Games[game.Id].ReviewTotal; if (UseWilsonScore && reviews > 0) { // calculate the lower bound of the Wilson interval for 95 % confidence // see http://www.evanmiller.org/how-not-to-sort-by-average-rating.html // $$ w^\pm = \frac{1}{1+\frac{z^2}{n}} // \left( \hat p + \frac{z^2}{2n} \pm z \sqrt{ \frac{\hat p (1 - \hat p)}{n} + \frac{z^2}{4n^2} } \right)$$ // where // $\hat p$ is the observed fraction of positive ratings (proportion of successes), // $n$ is the total number of ratings (the sample size), and // $z$ is the $1-{\frac {\alpha}{2}}$ quantile of a standard normal distribution // for 95% confidence, the $z = 1.96$ double z = 1.96; // normal distribution of (1-(1-confidence)/2), i.e. normal distribution of 0.975 for 95% confidence double p = score / 100.0; double n = reviews; p = Math.Round(100 * ((p + z * z / (2 * n) - z * Math.Sqrt((p * (1 - p) + z * z / (4 * n)) / n)) / (1 + z * z / n))); // debug: System.Windows.Forms.MessageBox.Show("score " + score + " of " + reviews + " is\tp = " + p + "\n"); score = Convert.ToInt32(p); } string result = null; foreach (UserScore_Rule rule in Rules) { if (CheckRule(rule, score, reviews)) { result = rule.Name; break; } } if (result != null) { result = GetProcessedString(result); game.AddCategory(games.GetCategory(result)); } return(AutoCatResult.Success); }
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; }
/// <summary> /// Removes the given Filter. /// </summary> /// <param name="f">Filter to remove.</param> /// <returns>True if removal was successful, false if it was not in the list anyway</returns> public bool RemoveFilter(Filter f) { if (Filters.Remove(f)) { return true; } return false; }
private void SetAdvancedMode(bool enabled) { Cursor.Current = Cursors.WaitCursor; if (enabled) { splitCategories.Panel1Collapsed = false; lstCategories.StateImageList = imglistFilter; advFilter = new Filter(ADVANCED_FILTER); cboFilter.Text = string.Empty; mbtnClearFilters.Visible = true; contextCat_SetAdvanced.Visible = true; } else { splitCategories.Panel1Collapsed = true; lstCategories.StateImageList = null; mbtnClearFilters.Visible = false; contextCat_SetAdvanced.Visible = false; } // allow the form to refresh before the time-consuming stuff happens Application.DoEvents(); FillCategoryList(false); OnViewChange(); Cursor.Current = Cursors.Default; }
/// <summary> /// Adds a new Filter to the list. /// </summary> /// <param name="name">Name of the Filter to add</param> /// <returns>The added Filter. Returns null if the Filter already exists.</returns> public Filter AddFilter(string name) { if (string.IsNullOrEmpty(name) || FilterExists(name)) { return null; } else { Filter newFilter = new Filter(name); Filters.Add(newFilter); return newFilter; } }
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; List<string> devs = db.GetDevelopers(game.Id); if (devs != null) { for (int index = 0; index < devs.Count; index++) { if (Developers.Contains(devs[index]) || AllDevelopers) { if (DevCount(devs[index]) >= MinCount) game.AddCategory(games.GetCategory(GetProcessedString(devs[index]))); } } } List<string> pubs = db.GetPublishers(game.Id); if (pubs != null) { for (int index = 0; index < pubs.Count; index++) { if (Publishers.Contains(pubs[index]) || AllPublishers) { if (PubCount(pubs[index]) >= MinCount) game.AddCategory(games.GetCategory(GetProcessedString(pubs[index]))); } } } return AutoCatResult.Success; }
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; List<string> gameTags = db.GetTagList( game.Id ); if( gameTags != null ) { int added = 0; for( int index = 0; index < gameTags.Count && ( MaxTags == 0 || added < MaxTags ); index++ ) { if( IncludedTags.Contains( gameTags[index] ) ) { game.AddCategory( games.GetCategory( GetProcessedString( gameTags[index] ) ) ); added++; } } } return AutoCatResult.Success; }
// using a list of AutoCat names (strings), return a cloned list of AutoCats replacing the filter with a new one if a new filter is provided. // This is used to help process AutoCatGroup. public List<AutoCat> CloneAutoCatList(List<string> acList, Filter filter) { List<AutoCat> newList = new List<AutoCat>(); foreach (string s in acList) { // find the AutoCat based on name AutoCat ac = GetAutoCat(s); if (ac != null) { // add a cloned copy of the Autocat and replace the filter if one is provided. // a cloned copy is used so that the selected property can be assigned without effecting lvAutoCatType on the Main form. AutoCat clone = ac.Clone(); if (filter != null) clone.Filter = filter.Name; newList.Add(clone); } } return newList; }