Esempio n. 1
0
        public async void OnLocationChanged(object sender, GeoPositionChangedEventArgs <GeoCoordinate> e)
        {
            Location MyLocation = null;

            location.Latitude  = StrProcessorHelper.CorrectLatitude(e.Position.Location.Latitude.ToString());
            location.Longitude = StrProcessorHelper.CorrectLongitude(e.Position.Location.Longitude.ToString());


            try
            {
                MyLocation = await this.GetLocation();

                LocationDetected = true;

                // Set Location
                Properties.Settings.Default.Locality      = MyLocation.Locality;
                Properties.Settings.Default.Address       = MyLocation.FormattedAddress;
                Properties.Settings.Default.AdminDistrict = MyLocation.AdminDistrict;
                Page3.LocationDetected = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Tidak bisa mendapatkan lokasi, pastikan Internet menyala", "An error occured", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Page3.Problem = true;
            }
        }
Esempio n. 2
0
        public async Task <int> GetCityCode()
        {
            string CityName        = StrProcessorHelper.CityName(Properties.Settings.Default.AdminDistrict);
            Uri    RequestCityCode = new Uri($"https://api.banghasan.com/sholat/format/json/kota/nama/{CityName}");

            int resultId = 0;

            HttpResponseMessage response = await APIHttpHandler.GetResponse(RequestCityCode);

            var data = await response.Content.ReadAsStringAsync();

            var    obj    = JObject.Parse(data);
            JArray Arr    = (JArray)obj["kota"];
            var    cities = JArray.FromObject(Arr);

            foreach (JObject city in cities)
            {
                resultId = (int)city["id"];
            }

            return(resultId);
        }