private async Task UpdateGraph(object sender, EventArgs e) { try { //fetch latest UV data from service and then update model int?LocIndex = this.arpansaModel.LocIndexValue; if (LocIndex == null) { //no location has been selected. Nothing to paint. return; } MeasuredLocation curLocation = this.arpansaModel.MeasureLocations[LocIndex.Value]; CurrentLocName.Text = curLocation.SiteName; ArpansaUVResponse arpansaUV = await this.arpansaService.GetUVData(curLocation.SiteLongitude.Value, curLocation.SiteLatitude.Value); List <UVIndex> uvIndexes = arpansaService.GenerateUVIndexs(); //update model ArpansaUVData graphData = new ArpansaUVData(arpansaUV); graphData.ReferenceUVs = uvIndexes; this.arpansaModel.ArpansaUVData = graphData; } catch (Exception e1) { await DisplayAlert("Error", e1.Message, "Ok"); } }
private void ArpansaModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "MeasureLocations") { this.locPicker.IsEnabled = true; this.loadingLabel.IsVisible = false; } else if (e.PropertyName == "LocIndexValue" && this.arpansaModel.MeasureLocations != null) { if (arpansaModel.LocIndexValue < 0 || arpansaModel.LocIndexValue >= arpansaModel.MeasureLocations.Count) { Console.WriteLine("Invalid location selected"); return; } //save the new selected location Preferences.Set("LocIndexValue", arpansaModel.LocIndexValue.Value); MeasuredLocation selectedLoc = arpansaModel.MeasureLocations[arpansaModel.LocIndexValue.Value]; //update state field this.state.Text = selectedLoc.CategoryName; this.stateStack.IsVisible = true; //update latitude field this.lat.Text = selectedLoc.SiteLatitude.ToString(); this.latStack.IsVisible = true; //update longitude field this.longitude.Text = selectedLoc.SiteLongitude.ToString(); this.longStack.IsVisible = true; } }