private async void GenerateTalentListAsync(List <ITalent> list) { if (list == null || list.Count == 0) { return; } if (Game.Settings.OrderTalentAlphabetic) { list = list.OrderBy(x => x.ToString()).ToList(); } else { list = list.OrderBy(x => x.OrginalPosition).ToList(); } DiceChanger helper = viewModel.DiceChanger; talentList = new List <TalentViewModel>(); var obList = new ObservableCollection <TalentViewModel>(); //Dieser Code ist verbesserbar, aktuell nur funktional wenn die liste nur einen typen enthält if (typeof(AbstractTalentFighting).IsAssignableFrom(list[0].GetType())) { viewModel.Header.ATVisibility = true; viewModel.Header.PABLVisibility = true; viewModel.Header.ProbeTextVisibility = false; if (typeof(TalentRange).IsAssignableFrom(list[0].GetType())) { viewModel.Header.PABLVisibility = false; } } if (typeof(AbstractTalentGeneral).IsAssignableFrom(list[0].GetType())) { viewModel.Header.ATVisibility = false; viewModel.Header.PABLVisibility = false; viewModel.Header.ProbeTextVisibility = true; } foreach (var item in list) { var innerItem = new TalentViewModel(helper) { Talent = item }; talentList.Add(innerItem); obList.Add(innerItem); } await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { viewModel.TalentList = obList; viewModel.IsLoading = false; }); }
public void SetAllLanguageFamiliesAsync() { new Task(async() => { var diceChanger = new DiceChanger(); languageViewModelList = new List <LanguageViewModel>(); viewModel.DiceChanger = diceChanger; foreach (var family in Game.LanguageFamilyList) { languageViewModelList.Add(new LanguageViewModel { LanguageFamilyName = family.Name }); var max = family.GetHighestPosition(); for (int i = 0; i <= max; i++) { var x = new LanguageViewModel(diceChanger) { LanguageFamilyName = family.Name }; if (family.Languages.TryGetValue(i, out TalentSpeaking language)) { x.SpeakingTalent = language; } if (family.Writings.TryGetValue(i, out TalentWriting writing)) { x.WritingTalent = writing; } languageViewModelList.Add(x); } languageViewModelList.Add(new LanguageViewModel()); } await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { viewModel.TalentList = new ObservableCollection <LanguageViewModel>(languageViewModelList); viewModel.IsLoading = false; }); }).Start(); }