Esempio n. 1
0
        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;
        }
Esempio n. 2
0
 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();
     }
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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";
            }
        }
Esempio n. 5
0
        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();
        }