private async void check_click(object sender, RoutedEventArgs e) { bool isNetwork = NetworkInterface.GetIsNetworkAvailable(); if (isNetwork) { try { WorldBuilding worldbuildings1 = await CustomPushpinWp8APIClient.GetWorldBuildings(); if (worldbuildings1.buildings.Count > Helper.worldbuildings.buildings.Count) { CustomMessageBox messageBox = new CustomMessageBox() { Caption = "Buildings", Message = "New Buildings found. Do you want to download them?", LeftButtonContent = "yes", RightButtonContent = "no" }; messageBox.Dismissed += (s1, e1) => { switch (e1.Result) { case CustomMessageBoxResult.LeftButton: downloading.Visibility = Visibility.Visible; downloaded = true; downloadData(); break; case CustomMessageBoxResult.RightButton: // Do something. break; case CustomMessageBoxResult.None: // Do something. break; default: break; } }; messageBox.Show(); } else { MessageBox.Show("No new Buildings found!"); } } catch { MessageBox.Show("Can not check for update. Please check your connection and try again!"); } } else { MessageBox.Show("No internet connection found. Please check your internet connection and try again later!", "No Internet Connection", MessageBoxButton.OK); } }
async void downloadData() { WorldBuilding worldbuildings1 = await CustomPushpinWp8APIClient.GetWorldBuildings(); Helper.worldbuildings = worldbuildings1; writeWorldBuildingsToIsolatedStorage(worldbuildings1); createListPickerItem(); downloading.Visibility = Visibility.Collapsed; }
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; }