public BattleTiersViewModel(BattleTierSpan battleTiers) { this.From = battleTiers.From; this.To = battleTiers.To; if (battleTiers.To - battleTiers.From > 2) { _toStringResult = $"{RomanNumberService.GetRomanNumber(battleTiers.From)}-{RomanNumberService.GetRomanNumber(battleTiers.To)}"; } else { var builder = new StringBuilder(); for (int i = battleTiers.From; i <= battleTiers.To; ++i) { if (i != battleTiers.From) { builder.Append(' '); } builder.Append(RomanNumberService.GetRomanNumber(i)); } _toStringResult = builder.ToString(); } }
private void UpdateFilters() { var tanks = _allTanks.SelectMany(t => t).Select(t => t.Model); var anyClient = RepositoryManager.Instance.Repositories.OfType <LocalGameClient>().FirstOrDefault(); var repositories = RepositoryManager.Instance.Repositories.OrderBy(r => r.Version).ToArray(); var repositoryFilters = new ComboBoxItemVM <IRepository> [repositories.Length + 1]; repositoryFilters[0] = s_allRepositoriesVm; for (var i = 0; i < repositories.Length; ++i) { var repository = repositories[i]; repositoryFilters[i + 1] = new RepositoryComboBoxItemVM(repository); } this.RepositoryFilters = repositoryFilters; this.RaisePropertyChanged(() => this.SelectedRepositoryFilter); var tiers = tanks.Select(t => t.Tier).Distinct().OrderBy(t => t).ToArray(); var tierFilters = new ComboBoxItemVM <int> [tiers.Length + 1]; tierFilters[0] = s_allTiersVm; for (var i = 0; i < tiers.Length; ++i) { var tier = tiers[i]; tierFilters[i + 1] = new ComboBoxItemVM <int>(tier, RomanNumberService.GetRomanNumber(tier), null); } this.TierFilters = tierFilters; this.RaisePropertyChanged(() => this.SelectedTierFilter); var classKeys = tanks.Select(t => t.ClassKey).Distinct().OrderBy(TankClassComparer.GetClassSortIndex).ToArray(); var classFilters = new ComboBoxItemVM <string> [classKeys.Length + 1]; classFilters[0] = s_allClassesVm; for (var i = 0; i < classKeys.Length; ++i) { var classKey = classKeys[i]; classFilters[i + 1] = new ComboBoxItemVM <string>(classKey, this.GetCompositeLocalization(r => r.GetLocalizedClassName(classKey)), anyClient == null ? null : anyClient.PackageImages.GetClassSmallIcon(classKey)); } this.ClassFilters = classFilters; this.RaisePropertyChanged(() => this.SelectedClassFilter); var nations = tanks.Select(t => t.NationKey).Distinct().OrderBy(n => n).ToArray(); var nationFilters = new ComboBoxItemVM <string> [nations.Length + 1]; nationFilters[0] = s_allNationsVm; for (var i = 0; i < nations.Length; ++i) { var @nation = nations[i]; nationFilters[i + 1] = new ComboBoxItemVM <string>(@nation, this.GetCompositeLocalization(r => r.GetLocalizedNationName(@nation)), anyClient == null ? null : anyClient.PackageImages.GetNationSmallIcon(@nation)); } this.NationFilters = nationFilters; this.RaisePropertyChanged(() => this.SelectedNationFilter); }
public TankVM(RepositoryVM repository, Tank tank) { this.Repository = repository; this.Model = tank; this.TankUnikey = new TankUnikey(repository.Model, tank); this.Name = tank.Name; this.ShortName = tank.ShortName; this.Tier = RomanNumberService.GetRomanNumber(tank.Tier); this.ClassSortIndex = TankClassComparer.GetClassSortIndex(tank.ClassKey); this.Nation = tank.NationKey; var gameClient = repository.Model as LocalGameClient; if (gameClient != null) { App.BeginInvokeBackground(() => this.SmallIcon = gameClient.PackageImages.GetTankSmallIcon(tank.IconKey)); this.NationIcon = gameClient.PackageImages.GetNationSmallIcon(tank.NationKey); this.ClassIcon = gameClient.PackageImages.GetClassSmallIcon(tank.ClassKey); } }