//Függvény, ami meghívódik, ha a MainPage lesz az aktív View public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { //A visszagomb letiltása, hiszen a főoldalról nem tudunk visszább menni SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Disabled; //Új service indítása, colletion-ök feltöltése var service = new GoTService(); var books = await service.GetBooksAsync(); foreach (var b in books) { Books.Add(b); } var characters = await service.GetCharactersAsync(); foreach (var c in characters) { Characters.Add(c); } var houses = await service.GetHousesAsync(); foreach (var h in houses) { Houses.Add(h); } await base.OnNavigatedToAsync(parameter, mode, state); }
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { //gets the requested character string url = (string)parameter; var client = new GoTService(); CurrentCharacter = await client.GetCharacterByUrlAsync(url); //First we need to check if the father data exists, if yes, the app makes a new call to the API to get the father's name if (CurrentCharacter.Father != "") { Character father = await client.GetCharacterByUrlAsync(CurrentCharacter.Father); FatherName = father.Name; } if (CurrentCharacter.Mother != "") { Character mother = await client.GetCharacterByUrlAsync(CurrentCharacter.Mother); MotherName = mother.Name; } if (CurrentCharacter.Spouse != "") { Character spouse = await client.GetCharacterByUrlAsync(CurrentCharacter.Spouse); SpouseName = spouse.Name; } foreach (var house in CurrentCharacter.Allegiances) { House h = await client.GetHouseByUrlAsync(house); //types are needed for navigation _allegiances.Add(h); //name is shown on the UI Allegiances.Add(h.Name); } foreach (var bookName in CurrentCharacter.Books) { Book b = await client.GetBookByUrlAsync(bookName); _books.Add(b); BookNames.Add(b.Name); } foreach (var povBookName in CurrentCharacter.PovBooks) { Book b = await client.GetBookByUrlAsync(povBookName); _povBooks.Add(b); PovBookNames.Add(b.Name); } await base.OnNavigatedToAsync(parameter, mode, state); }
private async Task GetHouses() { var service = new GoTService(); var houses = await service.GetHousesAsync(PageCount); Houses.Clear(); foreach (var h in houses) { Houses.Add(h); } }
//On navigation, fills up the collection with books public async override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { var service = new GoTService(); var books = await service.GetBooksAsync(); foreach (var b in books) { Books.Add(b); } await base.OnNavigatedToAsync(parameter, mode, state); }
//Gets a list of characters from the requested pagenumber private async Task GetCharacters() { var service = new GoTService(); var characters = await service.GetCharactersAsync(PageCount); Characters.Clear(); foreach (Character c in characters) { Characters.Add(c); } }
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { string url = (string)parameter; var client = new GoTService(); CurrentHouse = await client.GetHouseByUrlAsync(url); //Only request the name of the current lord if their Uri was given by the web API if (CurrentHouse.CurrentLord != "") { Character lord = await client.GetCharacterByUrlAsync(CurrentHouse.CurrentLord); CurrentLord = lord.Name; } //Only request the name of the heir if their Uri was given by the web API if (CurrentHouse.Heir != "") { Character heir = await client.GetCharacterByUrlAsync(CurrentHouse.Heir); Heir = heir.Name; } //Only request the name of the founder if their Uri was given by the web API if (CurrentHouse.Founder != "") { Character founder = await client.GetCharacterByUrlAsync(CurrentHouse.Founder); Founder = founder.Name; } foreach (var member in CurrentHouse.SwornMembers) { Character c = await client.GetCharacterByUrlAsync(member); //saves the character object, needed for navigation _members.Add(c); //saves the character's name separately, needed so it can be shown on the UI SwornMembers.Add(c.Name); } foreach (var house in CurrentHouse.CadetBranches) { House h = await client.GetHouseByUrlAsync(house); _branches.Add(h); CadetBranches.Add(h.Name); } await base.OnNavigatedToAsync(parameter, mode, state); }
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { //gets the book from the passed parameter string url = (string)parameter; var client = new GoTService(); CurrentBook = await client.GetBookByUrlAsync(url); foreach (var povCharacter in CurrentBook.PovCharacters) { Character c = await client.GetCharacterByUrlAsync(povCharacter); //Saves the name field to a collection that is shown on the UI PovCharacterNames.Add(c.Name); //Saves the entire type, needed for navigation _povCharacters.Add(c); } //sets a specific limit, so the app wont get overwhelmed with too much data int limit = 20; int i = 0; foreach (var character in CurrentBook.Characters) { if (i >= limit) { break; } Character c = await client.GetCharacterByUrlAsync(character); if (c.Name != "") { //Saves the name field to a collection that is shown on the UI CharacterNames.Add(c.Name); //Saves the entire type, needed for navigation _characters.Add(c); } i++; } await base.OnNavigatedToAsync(parameter, mode, state); }
//Show the information private async void showBookInfo(Book selected) { //Texblocks NameTextBox.Text = selected.name; CountryTextBox.Text = selected.country; ISBNTextBox.Text = selected.isbn; MediaTypeTextBox.Text = selected.mediaType; ReleasedTextBox.Text = selected.released.Substring(0, 10); PublisherTextBox.Text = selected.publisher; NumberOfPagesTextBox.Text = selected.numberOfPages.ToString(); //ListBoxes AuthorsListBox.ItemsSource = selected.authors; /**Links to Characters**/ var service = new GoTService(); foreach (var item in selected.povCharacters) { if (item != "") { var tmp = await service.GetCharacterAsync(item); if (tmp.name != "") { povCharactersListBox.Items.Add(tmp); } } } foreach (var item in selected.characters) { if (item != "") { var tmp = await service.GetCharacterAsync(item); if (tmp.name != "") { CharactersListBox.Items.Add(tmp); } } } }
//Load the parameter, if there is one. Else, load the whole list. protected override async void OnNavigatedTo(NavigationEventArgs e) { var arg = e.Parameter as Character; //If we have to load a character if (arg != null) { LoadingRing.IsActive = true; showCharacterInfo(arg); LoadingRing.IsActive = false; } //After loading the character, we proceed to load the list if we have to if (CharactersList.Count() == 0) { Characters_Searchbox.IsEnabled = false; var service = new GoTService(); LoadingRing.IsActive = true; //We need to take all the pages var characters = await service.GetCharactersAsync(1); int page = 2; while (characters.Count != 0) { foreach (var item in characters) { if (item.name != "") { CharactersList.Add(item); } } characters = await service.GetCharactersAsync(page); page++; } LoadingRing.IsActive = false; Characters_Searchbox.IsEnabled = true; } CharactersListBox.ItemsSource = CharactersList; }
private async void Search() { if (SearchText == "") { await new MessageDialog("Please give a name!").ShowAsync(); return; } List <Character> chars = new List <Character>(); var service = new GoTService(); chars = await service.GetCharactersByNameAsync(SearchText); if (chars.Count == 0) { await new MessageDialog("No character found with this name!").ShowAsync(); return; } //If there are more characters returned by the API, jumps to the last character's detailed page await NavigationService.NavigateAsync(typeof(CharacterDetailsPage), chars.LastOrDefault().Url); }
//If a parameter is given, show it. Else, load all the view. protected override async void OnNavigatedTo(NavigationEventArgs e) { var arg = e.Parameter as House; //If we have to load a house if (arg != null) { LoadingRing.IsActive = true; showHouseInfo(arg); LoadingRing.IsActive = false; } //After loading the character, we proceed to load the list if necessary if (HousesList.Count() == 0) { Houses_Searchbox.IsEnabled = false; var service = new GoTService(); LoadingRing.IsActive = true; var houses = await service.GetHousesAsync(1); int page = 2; while (houses.Count() != 0) { foreach (var item in houses) { if (item.name != "") { HousesList.Add(item); } } houses = await service.GetHousesAsync(page); page++; } LoadingRing.IsActive = false; Houses_Searchbox.IsEnabled = true; } HousesListBox.ItemsSource = HousesList; }
//Load the parameter and/or the whole list. protected override async void OnNavigatedTo(NavigationEventArgs e) { var arg = e.Parameter as Book; //If we have to load a book if (arg != null) { LoadingRing.IsActive = true; showBookInfo(arg); LoadingRing.IsActive = false; } //After that, load the whole list if has not been loaded yet if (BooksList.Count() == 0) { Books_Searchbox.IsEnabled = false; var service = new GoTService(); LoadingRing.IsActive = true; var books = await service.GetBooksAsync(1); int page = 2; while (books.Count() != 0) { foreach (var item in books) { if (item.name != "") { BooksList.Add(item); } } books = await service.GetBooksAsync(page); page++; } LoadingRing.IsActive = false; Books_Searchbox.IsEnabled = true; } BooksListBox.ItemsSource = BooksList; }
//Függvény, ami meghívódik, ha a CharacterDetailsPage lesz az aktív View public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { //Egy új service indítása, a paraméterben kapott karakter adatainak betöltése string url = (string)parameter; GoTService service = new GoTService(); Character = await service.GetAsync <Character>(new Uri(url)); if (!Character.Father.Equals("")) { var father = await service.GetAsync <Character>(new Uri(Character.Father)); Father = father.Name; } if (!Character.Mother.Equals("")) { var mother = await service.GetAsync <Character>(new Uri(Character.Mother)); Mother = mother.Name; } if (Character.Spouse.Length > 0) { var spouse = await service.GetAsync <Character>(new Uri(Character.Spouse)); Spouse = spouse.Name; } if (!Character.Titles[0].Equals("")) { string titles = ""; foreach (string title in Character.Titles) { titles += title + ", "; } Titles = DeleteLastComa(titles); } if (!Character.Aliases[0].Equals("")) { string aliases = ""; foreach (string alias in Character.Aliases) { aliases += alias + ", "; } Aliases = DeleteLastComa(aliases); } if (Character.Books.Length > 0) { foreach (var bookURL in Character.Books) { var book = await service.GetAsync <Book>(new Uri(bookURL)); this.BookArray.Add(book); } } else { BookArray.Add(new Book { Name = "N/A" }); } if (Character.PovBooks.Length > 0) { foreach (var povBookURL in Character.PovBooks) { var povBook = await service.GetAsync <Book>(new Uri(povBookURL)); this.PovBookArray.Add(povBook); } } else { PovBookArray.Add(new Book { Name = "N/A" }); } if (Character.Allegiances.Length > 0) { foreach (var houseURL in Character.Allegiances) { var house = await service.GetAsync <House>(new Uri(houseURL)); this.Allegiances.Add(house); } } else { Allegiances.Add(new House { Name = "N/A" }); } if (!Character.TvSeries[0].Equals("")) { string series = ""; foreach (var season in Character.TvSeries) { series += season + "\n"; } TvSeries = series; } if (!Character.Playedby[0].Equals("")) { string playedBy = ""; foreach (var actor in Character.Playedby) { playedBy += actor + ", "; } PlayedBy = DeleteLastComa(playedBy); } await base.OnNavigatedToAsync(parameter, mode, state); }
//Fill in the boxes private async void showCharacterInfo(Character selected) { //Texblocks NameTextBox.Text = selected.name; GenderTextBox.Text = selected.gender; CultureTextBox.Text = selected.culture; BornTextBox.Text = selected.born; DiedTextBox.Text = selected.died; //ListBoxes TVSeriesListBox.ItemsSource = selected.tvSeries; TitlesListBox.ItemsSource = selected.titles; AliasesListBox.ItemsSource = selected.aliases; PlayedByListBox.ItemsSource = selected.playedBy; /**Links**/ //Character var father = CharactersList.Find(x => x.url == selected.father); FatherListBox.Items.Clear(); if (father != null) { if (father.name != "") { FatherListBox.Items.Add(father); } } var mother = CharactersList.Find(x => x.url == selected.mother); MotherListBox.Items.Clear(); if (mother != null) { if (mother.name != "") { MotherListBox.Items.Add(mother); } } var spouse = CharactersList.Find(x => x.url == selected.spouse); SpouseListBox.Items.Clear(); if (spouse != null) { if (spouse.name != "") { SpouseListBox.Items.Add(spouse); } } //House var service = new GoTService(); AllegiancesListBox.Items.Clear(); foreach (var item in selected.allegiances) { if (item != "") { var tmp = await service.GetHouseAsync(item); if (tmp.name != "") { AllegiancesListBox.Items.Add(tmp); } } } //Book BooksListBox.Items.Clear(); foreach (var item in selected.books) { if (item != "") { var tmp = await service.GetBookAsync(item); if (tmp.name != "") { BooksListBox.Items.Add(tmp); } } } POVBooksListBox.Items.Clear(); foreach (var item in selected.povBooks) { if (item != "") { var tmp = await service.GetBookAsync(item); if (tmp.name != "") { POVBooksListBox.Items.Add(tmp); } } } }
//Fill the boxes with the information of the house private async void showHouseInfo(House selected) { //Textblocks DiedOutTextBox.Text = selected.diedOut; FoundedTextBox.Text = selected.founded; WordsTextBox.Text = selected.words; CoatOfArmsTextBox.Text = selected.coatOfArms; RegionTextBox.Text = selected.region; NameTextBox.Text = selected.name; //ListBoxes AncestralWeaponsListBox.ItemsSource = selected.ancestralWeapons; SeatsListBox.ItemsSource = selected.seats; TitlesListBox.ItemsSource = selected.titles; /**Links***/ //House CurrentLordListBox.Items.Clear(); CadetBranchesListBox.Items.Clear(); HeirListBox.Items.Clear(); FounderListBox.Items.Clear(); SwornMembersListBox.Items.Clear(); foreach (var item in selected.cadetBranches) { var tmp = HousesList.Find(x => x.url == item); if (tmp != null) { CadetBranchesListBox.Items.Add(tmp); } } OverlordListBox.Items.Clear(); var overlord = HousesList.Find(x => x.url == selected.overlord); OverlordListBox.Items.Clear(); if (overlord != null) { OverlordListBox.Items.Add(overlord); } //Character var service = new GoTService(); foreach (var item in selected.swornMembers) { if (item != "") { SwornMembersListBox.Items.Add(await service.GetCharacterAsync(item)); } } if (selected.founder != "") { FounderListBox.Items.Add(await service.GetCharacterAsync(selected.founder)); } if (selected.heir != "") { HeirListBox.Items.Add(service.GetCharacterAsync(selected.heir)); } if (selected.currentLord != "") { CurrentLordListBox.Items.Add(await service.GetCharacterAsync(selected.currentLord)); } }
//Függvény, ami meghívódik, ha a HouseDetailsPage lesz az aktív View public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { //Egy új service indítása, a paraméterben kapott ház adatainak betöltése string url = (string)parameter; GoTService service = new GoTService(); House = await service.GetAsync <House>(new Uri(url)); if (House.Titles[0] != "") { string titles = ""; foreach (var title in House.Titles) { titles += title + ", "; } Titles = DeleteLastComa(titles); } if (House.Seats[0] != "") { string seats = ""; foreach (var seat in House.Seats) { seats += seat + ", "; } Seats = DeleteLastComa(seats); } if (House.CurrentLord != "") { var lord = await service.GetAsync <Character>(new Uri(House.CurrentLord)); CurrentLord = lord.Name; } if (House.Heir != "") { var heir = await service.GetAsync <Character>(new Uri(House.Heir)); Heir = heir.Name; } if (House.Overlord != "") { var ol = await service.GetAsync <House>(new Uri(House.Overlord)); Overlord = ol.Name; } if (House.Founder != "") { var fr = await service.GetAsync <Character>(new Uri(House.Founder)); Founder = fr.Name; } if (House.AncestralWeapons[0] != "") { string aw = ""; foreach (var weapon in House.AncestralWeapons) { aw += weapon + ", "; } AncestralWeapons = DeleteLastComa(aw); } if (House.CadetBranches.Length > 0) { foreach (var branchURL in House.CadetBranches) { var house = await service.GetAsync <House>(new Uri(branchURL)); CadetBranches.Add(house); } } else { CadetBranches.Add(new House { Name = "N/A" }); } if (House.SwornMembers.Length > 0) { foreach (var charURL in House.SwornMembers) { var character = await service.GetAsync <Character>(new Uri(charURL)); SwornMembers.Add(character); } } else { SwornMembers.Add(new Character { Name = "N/A" }); } await base.OnNavigatedToAsync(parameter, mode, state); }