public PagedSpeciesViewModel(string url) { Title = "Species"; var speciesApi = ConnectToApi.GetDatasFromUrlAsync <PagedSpecies>(url).Result; SetIsVisible(speciesApi); PreviousUrl = speciesApi.PreviousPage; NextUrl = speciesApi.NextPage; PagedSpecies = new ObservableCollection <Specie>(speciesApi.Species); }
public PagedFilmsViewModel(string url) { Title = "Films"; var filmsApi = ConnectToApi.GetDatasFromUrlAsync <PagedFilms>(url).Result; SetIsVisible(filmsApi); PreviousUrl = filmsApi.PreviousPage; NextUrl = filmsApi.NextPage; PagedFilms = new ObservableCollection <Film>(filmsApi.Films); }
public PagedPlanetsViewModel(string url) { Title = "Planets"; var planetsApi = ConnectToApi.GetDatasFromUrlAsync <PagedPlanets>(url).Result; SetIsVisible(planetsApi); PreviousUrl = planetsApi.PreviousPage; NextUrl = planetsApi.NextPage; PagedPlanets = new ObservableCollection <Planet>(planetsApi.Planets); }
public PagedStarshipsViewModel(string url) { Title = "Starships"; var starshipsApi = ConnectToApi.GetDatasFromUrlAsync <PagedStarships>(url).Result; SetIsVisible(starshipsApi); PreviousUrl = starshipsApi.PreviousPage; NextUrl = starshipsApi.NextPage; PagedStarships = new ObservableCollection <Starship>(starshipsApi.Starships); }
public PagedVehiclesViewModel(string url) { Title = "Vehicles"; var vehiclesApi = ConnectToApi.GetDatasFromUrlAsync <PagedVehicles>(url).Result; SetIsVisible(vehiclesApi); PreviousUrl = vehiclesApi.PreviousPage; NextUrl = vehiclesApi.NextPage; PagedVehicles = new ObservableCollection <Vehicle>(vehiclesApi.Vehicles); }
public PagedPeopleViewModel(string url) { Title = "People"; var peopleApi = ConnectToApi.GetDatasFromUrlAsync <PagedPeople>(url).Result; SetIsVisible(peopleApi); PreviousUrl = peopleApi.PreviousPage; NextUrl = peopleApi.NextPage; PagedPeople = new ObservableCollection <People>(peopleApi.People); }
//Find the number generated //Each time we call the API, we put a number into min if it is bigger, max if it is smaller //Like this we reduce the gap between min and max //By dividing by 2, we can find each time the number under 16 tries. It allow us to climb the max number to 2^16 = 65536. public void FindTheNumber() { int numberToCheck; bool isNumberFind = true; do { numberToCheck = (min + max) / 2; Number = ConnectToApi.GetResultFromNumber(numberToCheck).Result; if (Number.Result == "Smaller") { max = numberToCheck; } else if (Number.Result == "Bigger") { min = numberToCheck; } else { isNumberFind = false; GoodNumber = numberToCheck; } }while (isNumberFind); }
public MasterViewModel() { Title = "Menu"; Root Urls = ConnectToApi.GetRootUrlAsync().Result; MenuItems = new ObservableCollection <MasterMenuItem>(); //Generate our Menu MenuItems.Add(new MasterMenuItem { Text = "Films", Detail = "All the films saga", ImagePath = "icon.png", TargetPage = Urls.FilmsUrl, TargetType = typeof(PagedFilmsPage) }); MenuItems.Add(new MasterMenuItem { Text = "People", Detail = "All the people in the saga", ImagePath = "icon.png", TargetPage = Urls.PeopleUrl, TargetType = typeof(PagedPeoplePage) }); MenuItems.Add(new MasterMenuItem { Text = "Planets", Detail = "All the planets in the saga", ImagePath = "icon.png", TargetPage = Urls.PlanetsUrl, TargetType = typeof(PagedPlanetsPage) }); MenuItems.Add(new MasterMenuItem { Text = "Species", Detail = "All the species in the saga", ImagePath = "icon.png", TargetPage = Urls.SpeciesUrl, TargetType = typeof(PagedSpeciesPage) }); MenuItems.Add(new MasterMenuItem { Text = "Starships", Detail = "All the starships in the saga", ImagePath = "icon.png", TargetPage = Urls.StarshipsUrl, TargetType = typeof(PagedStarshipsPage) }); MenuItems.Add(new MasterMenuItem { Text = "Vehicles", Detail = "All the vehicles in the saga", ImagePath = "icon.png", TargetPage = Urls.VehiclesUrl, TargetType = typeof(PagedVehiclesPage) }); MenuItems.Add(new MasterMenuItem { Text = "Find a Number", Detail = "Find a number between 1 and 50000", ImagePath = "icon.png", TargetType = typeof(FindNumberPage) }); }
private void button2_Click(object sender, EventArgs e) { ConnectToApi cta = new ConnectToApi(); cta.Show(this); }