private void SetLocation() { IGeolocator locator = DependencyService.Get <IGeolocator>(); locator.locationObtained += (sender, e) => { UserLatitude = e.lat; UserLatitude = Math.Round(UserLatitude * 100000.00) / 100000.00; userLatitude = UserLatitude; UserLongitude = e.lng; UserLongitude = Math.Round(userLongitude * 100000.00) / 100000.00; userLongitude = UserLongitude; }; locator.ObtainMyLocation(); Debug.WriteLine("userLatitude: " + userLatitude + ", userLongitude: " + userLongitude); userOffset = new DateTimeOffset(DateTime.Now).Offset.Hours; DateLocation defaultSettings = new DateLocation { myDate = DateTime.Now, myLatitude = userLatitude, myLongitude = userLongitude, myOffset = userOffset }; Application.Current.Properties["Default"] = defaultSettings; }
protected override void OnAppearing() { base.OnAppearing(); if (Application.Current.Properties.ContainsKey("MyPreferences")) { DateLocation preferences = Application.Current.Properties["MyPreferences"] as DateLocation; latitudeEntry.Text = preferences.myLatitude.ToString(); longitudeEntry.Text = preferences.myLongitude.ToString(); offsetEntry.Text = preferences.myOffset.ToString(); datePicker.Date = preferences.myDate; CheckDate(); CheckLocation(); } }
private void OnDoneClicked(object sender, EventArgs e) { DateTime dateTime = new DateTime(datePicker.Date.Year, datePicker.Date.Month, datePicker.Date.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); DateLocation dl = new DateLocation { myDate = dateTime, myLatitude = Double.Parse(latitudeEntry.Text), myLongitude = Double.Parse(longitudeEntry.Text), myOffset = Double.Parse(offsetEntry.Text) }; Application.Current.Properties["MyPreferences"] = dl; OnPreviousPageButtonClicked(sender, e); }
private void ResetLocation() { DateLocation dl = Application.Current.Properties["MyPreferences"] as DateLocation; isLocationChanged = CheckLocation(dl.myLatitude, dl.myLongitude, dl.myOffset); if (isLocationChanged) { useCurrentOrConfigured.Text = "Using configured date and location"; userLatitude = dl.myLatitude; userLongitude = dl.myLongitude; userOffset = dl.myOffset; } else if (isToday) { useCurrentOrConfigured.Text = "Using current date and location"; } }
private void ReInit() { if (!Application.Current.Properties.ContainsKey("MyPreferences")) { return; } DateLocation dl = Application.Current.Properties["MyPreferences"] as DateLocation; dateTimeTitle.Text = dl.myDate.ToString("yyyy-MMM-dd h:mm tt"); if (dl.myDate.DayOfYear != DateTime.Now.DayOfYear) { isToday = false; useCurrentOrConfigured.Text = "Using configured date and location"; } else { isToday = true; } userDate = dl.myDate; ResetLocation(); CalculateTimeSequence(); SetSequence(); }