コード例 #1
0
        private void FilterHeroes()
        {
            if (string.IsNullOrWhiteSpace(_filter))
            {
                _filter = string.Empty;
            }

            var lowerCaseFilter = Filter.ToLowerInvariant().Trim();

            var result = _heroList.Where(d => d.Localized_Name.ToLowerInvariant()
                                         .StartsWith(lowerCaseFilter))
                         .ToList();

            var toRemove = HeroList.Except(result).ToList();

            foreach (var x in toRemove)
            {
                HeroList.Remove(x);
            }

            var resultCount = result.Count;

            for (int i = 0; i < resultCount; i++)
            {
                var resultItem = result[i];
                if (i + 1 > HeroList.Count || !HeroList[i].Equals(resultItem))
                {
                    HeroList.Insert(i, resultItem);
                }
            }
        }
コード例 #2
0
 public void DeleteCharacter(Character character)
 {
     foreach (var item in character.Items)
     {
         DeleteItem(item);
     }
     foreach (var perk in character.Perks)
     {
         DeletePerk(perk.perk);
     }
     HeroList.Remove(character.hero);
     CharacterList.Remove(character);
     database.Delete(character.hero);
 }