Example #1
0
        private async void SendMail_Tapped(object sender, EventArgs e)
        {
            Label         lbl    = sender as Label;
            List <string> toList = new List <string>();

            toList.Add(lbl.Text);
            try
            {
                var message = new EmailMessage
                {
                    Subject = "Nachricht aus Golfclub App",
                    Body    = "",
                    To      = toList
                };
                await Email.ComposeAsync(message);
            }
            catch (FeatureNotSupportedException fbsEx)
            {
                CrashTracker.Track(fbsEx);
                // Email is not supported on this device
            }
            catch (Exception ex)
            {
                CrashTracker.Track(ex);
                // Some other exception occurred
            }
        }
Example #2
0
        private void PhoneNumer_Tapped(object sender, EventArgs e)
        {
            // get phone numer
            Label lbl = sender as Label;

            try
            {
                PhoneDialer.Open(lbl.Text);
            }
            catch (ArgumentNullException anEx)
            {
                CrashTracker.Track(anEx);
                // Number was null or white space
            }
            catch (FeatureNotSupportedException ex)
            {
                CrashTracker.Track(ex);
                // Phone Dialer is not supported on this device.
            }
            catch (Exception ex)
            {
                CrashTracker.Track(ex);
                // Other error has occurred.
            }
        }
Example #3
0
        public async Task <List <string> > GetTeeNameList()
        {
            try
            {
                IDataStore <TeeInfo> DataStore = DependencyService.Get <IDataStore <TeeInfo> >();
                List <TeeInfo>       teeinfos  = (await DataStore.GetItemsAsync()).ToList();

                var tees = teeinfos.Where(x => x.GolfClubId == GolfclubId).OrderBy(n => n.TeeNummer).Select(y => new { y.TeeName, y.TeeNummer }).Distinct();

                if (tees == null || tees?.Count() == 0)
                {
                    return(null);
                }

                List <string> result = new List <string>();

                foreach (var t in tees)
                {
                    string teename = string.Concat(t.TeeNummer, ": ", t.TeeName);
                    result.Add(teename);
                }

                return(result);
            }
            catch (Exception ex)
            {
                CrashTracker.Track(ex);
                return(null);
            }
        }
Example #4
0
        public async Task <bool> LoadAllPlaces()
        {
            // get current location, 2 times as result is better ???
            try
            {
                //var request = new GeolocationRequest(GeolocationAccuracy.High, new TimeSpan(0, 0, 4));
                //var location = await Geolocation.GetLocationAsync(request);
                //await Task.Delay(1000);

                List <TeePlace> TPList = new List <TeePlace>();
                CrossGeolocator.Current.DesiredAccuracy = 1;
                if (IsLocationAvailable())
                {
                    //var request = new GeolocationRequest(GeolocationAccuracy.Best, new TimeSpan(0, 0, 30));
                    //var location = await Geolocation.GetLocationAsync(request);
                    Plugin.Geolocator.Abstractions.Position location = null;
                    try
                    {
                        location = await CrossGeolocator.Current.GetPositionAsync(new TimeSpan(0, 0, 2));
                    }
                    catch (Exception ex)
                    {
                        location = null;
                    }

                    if (location != null)
                    {
                        // fill teeplaces list
                        foreach (TeeInfo ti in TeeInfos)
                        {
                            TeePlace tp = new TeePlace();
                            tp.Text = ti.TeeInfoName;
                            tp.Type = ti.TeeInfoType;
                            // calculate distance from current location
                            double DistanceKM = Location.CalculateDistance(location.Latitude, location.Longitude, ti.Latitude, ti.Longitude, DistanceUnits.Kilometers);
                            tp.Distance = (int)(DistanceKM * 1000);
                            //if (tp.Distance < 600)
                            TPList.Add(tp);
                        }
                    }
                }
                TeePlaces = new ObservableCollection <TeePlace>(TPList.OrderBy(x => x.Text));
            }
            catch (Exception ex)
            {
                CrashTracker.Track(ex);
                return(await Task.FromResult(false));
            }

            return(await Task.FromResult(true));
        }
Example #5
0
 async Task ExecuteLoadAllPlacesCommand()
 {
     IsRefreshingAllPlaces = true;
     try
     {
         TeePlaces.Clear();
         await LoadAllPlaces();
     }
     catch (Exception ex)
     {
         CrashTracker.Track(ex);
         Debug.WriteLine(ex);
     }
     finally
     {
         IsRefreshingAllPlaces = false;
     }
 }
Example #6
0
        private async void InitTeePicker()
        {
            try
            {
                if (teeInfoViewModel == null)
                {
                    return;
                }

                var teeNames = await teeInfoViewModel.GetTeeNameList();

                if (teeNames == null)
                {
                    TeePicker.IsEnabled = false;
                    return;
                }

                TeePicker.ItemsSource = teeNames;

                TeePicker.SelectedIndexChanged += TeePicker_SelectedIndexChanged;

                if (!openedModal)
                {
                    TeePicker.SelectedItem = teeNames.FirstOrDefault();
                    TeePicker.IsEnabled    = true;
                }
                else
                {
                    var tee = teeNames.Where(t => t.StartsWith(teeNumber.ToString() + ":")).FirstOrDefault();
                    TeePicker.SelectedItem = tee;
                }
            }
            catch (Exception ex)
            {
                CrashTracker.Track(ex);
                throw;
            }
        }