Beispiel #1
0
        /// <summary>
        /// Saves current position
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        async void SaveGpsClicked(object sender, EventArgs e)
        {
            try
            {
                buttonSave.IsEnabled = false;
                label.Text           = "Aan het ophalen...";
                await geo.GetLocation();

                var Address = await geo.GetAddress();

                IFile file = await rootFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);

                await file.WriteAllTextAsync(Address);

                label.Text = "Fietslocatie: " + Address + " is successvol opgeslagen!";
                ChangeButtonsVisibility(true);
            }
            catch (Exception ex)
            {
                label.Text = "Je locatie kan niet gevonden worden, probeer het later nog eens.";
            }
            finally
            {
                buttonSave.IsEnabled = true;
            };
        }
Beispiel #2
0
        /// <summary>
        /// Method that is triggerd when the SaveButton is clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SaveButtonClicked(object sender, EventArgs e)
        {
            if (picker.SelectedIndex != -1)
            {
                try
                {
                    var agenda = calendars.ElementAt(picker.SelectedIndex);
                    Geo geo    = new Geo();
                    await geo.GetLocation();

                    string address = await geo.GetAddress();

                    string location = $"{geo.Location.Item1}, {geo.Location.Item2}";

                    if (await DependencyService.Get <ICalendarHandler>().SaveAppointment(agenda, datePicker.Date.Date + timePicker.Time, "Fiets ophalen", address, location))
                    {
                        await DisplayAlert("info", "de afspraak is succesvol ingeland", "ok");
                    }
                }
                catch
                {
                    if (PlanCounter >= 3)
                    {
                        await DisplayAlert("info", "er is een fout opgetreden, controleer uw internet verbinding.", "ok");
                    }
                    else
                    {
                        PlanCounter++;
                        SaveButtonClicked(sender, e);
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Click event that gets the closest bike container and opens the maps api in order to navigate.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        async void ClosestContainersClicked(object sender, EventArgs e)
        {
            var location = await geo.GetLocation();

            try
            {
                using (var client = new HttpClient())
                {
                    button.IsEnabled = false;
                    string download = await client.GetStringAsync($"http://145.24.222.220/v2/questions/NearestContainer?x=" + location.Item1 + "&y=" + location.Item2 + "");

                    var addressContainer = JsonConvert.DeserializeObject <IEnumerable <BikeDataModels.BikeContainer> >(download).Last();

                    var navloc1 = WebUtility.UrlEncode(await geo.GetAddress());
                    var navloc2 = WebUtility.UrlEncode(await geo.GetAddress(addressContainer.XLocation, addressContainer.YLocation));

                    Device.OpenUri(
                        new Uri(geo.generateNavigation(navloc1, navloc2)));
                }
            }
            catch (Exception ex)
            {
                Log.Debug("test", ex.ToString());
            }
            finally
            {
                button.IsEnabled = true;
            }
        }
Beispiel #4
0
        /// <summary>
        /// this event handler handles the event of the sharebutton being pressed and then shows the share dialog
        /// </summary>
        async void onShareButton(object sender, EventArgs e)
        {
            try {
                var location = await geo.GetLocation();

                var address = await geo.GetAddress();

                try {
                    await CrossShare.Current.Share("Help mijn fiets terug te vinden, voor het laatst gezien bij " + address + ".", "Help: mijn fiets is gestolen.");
                }
                catch { }
            }
            catch { }
        }