private async void downloadAllBuildings() { try { Dispatcher.BeginInvoke(() => { txt_download.Text = "Download building data.."; }); WorldBuilding worldbuildings1 = await CustomPushpinWp8APIClient.GetWorldBuildings(); foreach (var obj in worldbuildings1.buildings) { PoisByBuilding building = await CustomPushpinWp8APIClient.GetPoisByBuilding(obj.buid); AllBuildingFloors allbuildingfloors = await CustomPushpinWp8APIClient.GetAllBuildingFloors(obj.buid); writePoisByBuildingToIsolatedStorage(building, obj.buid); writeAllBuildingFloorsToIsolatedStorage(allbuildingfloors, obj.buid); for (int i = 0; i < allbuildingfloors.floors.Count; i++) { Dispatcher.BeginInvoke(() => { txt_download.Text = "Download floor " + (i + 1) + " of " + allbuildingfloors.floors.Count; }); foreach (var obj1 in allbuildingfloors.floors) { await CustomPushpinWp8APIClient.GetTiles(obj1.buid, obj1.floor_number); } } } Dispatcher.BeginInvoke(() => { txt_download.Text = "Saving data.."; }); writeWorldBuildingsToIsolatedStorage(worldbuildings1); Helper.worldbuildings = worldbuildings1; //Helper.allbuildingfloors = allbuildingfloors1; createListPickerItem(); } catch { downloading.Visibility = Visibility.Collapsed; MessageBox.Show("Can not download all buildings. Please check your connection and try again!"); } downloading.Visibility = Visibility.Collapsed; }
private async void listpicker_selection_change(object sender, SelectionChangedEventArgs e) { if (listpicker != null) { if (listpicker.SelectedItem != null) { string selected = listpicker.SelectedItem.ToString(); string buid = ""; if (selected.Equals("None") || selected.Equals("No Buildings to show")) { return; } else { bool isNetwork = NetworkInterface.GetIsNetworkAvailable(); if (isNetwork) { downloading.Visibility = Visibility.Visible; try { foreach (var obj in Helper.worldbuildings.buildings) { if (obj.name.Equals(selected)) { buid = obj.buid; break; } } PoisByBuilding building = await CustomPushpinWp8APIClient.GetPoisByBuilding(buid); AllBuildingFloors allbuildingfloors = await CustomPushpinWp8APIClient.GetAllBuildingFloors(buid); writePoisByBuildingToIsolatedStorage(building, buid); writeAllBuildingFloorsToIsolatedStorage(allbuildingfloors, buid); for (int i = 0; i < allbuildingfloors.floors.Count; i++) { Dispatcher.BeginInvoke(() => { txt_download.Text = "Download floor " + (i + 1) + " of " + allbuildingfloors.floors.Count; }); foreach (var obj1 in allbuildingfloors.floors) { await CustomPushpinWp8APIClient.GetTiles(obj1.buid, obj1.floor_number); } } } catch { downloading.Visibility = Visibility.Collapsed; MessageBox.Show("Can not download selected building. Please check your connection and try again!"); } downloading.Visibility = Visibility.Collapsed; } else { MessageBox.Show("No internet connection found. Please check your internet connection and try again later!", "No Internet Connection", MessageBoxButton.OK); downloading.Visibility = Visibility.Collapsed; } } } } }