コード例 #1
0
 public void CheckAndReloadElevationProfile(Context appContext, int maxDistance, IAppContext context)
 {
     if (context.Settings.ShowElevationProfile)
     {
         if (GpsUtils.HasAltitude(context.MyLocation))
         {
             if (_elevationProfileBeingGenerated == false)
             {
                 if (context.ElevationProfileData == null || !context.ElevationProfileData.IsValid(context.MyLocation, context.Settings.MaxDistance))
                 {
                     GenerateElevationProfile(appContext, maxDistance, context.MyLocation);
                 }
                 else
                 {
                     RefreshElevationProfile(context.ElevationProfileData);
                 }
             }
         }
     }
 }
コード例 #2
0
        private void GenerateElevationProfile(Context appContext, int maxDistance, GpsLocation myLocation)
        {
            try
            {
                if (!GpsUtils.HasAltitude(myLocation))
                {
                    PopupHelper.ErrorDialog(appContext, Resource.String.Main_ErrorUnknownAltitude);
                    return;
                }

                _elevationProfileBeingGenerated = true;

                var ec = new ElevationCalculation(myLocation, maxDistance);

                var size = ec.GetSizeToDownload();
                if (size == 0)
                {
                    StartDownloadAndCalculate(appContext, ec);
                    return;
                }

                using (var builder = new AlertDialog.Builder(appContext))
                {
                    builder.SetCancelable(false);
                    builder.SetTitle(appContext.Resources.GetText(Resource.String.Common_Question));
                    builder.SetMessage(String.Format(appContext.Resources.GetText(Resource.String.Download_Confirmation), size));
                    builder.SetIcon(Android.Resource.Drawable.IcMenuHelp);
                    builder.SetPositiveButton(appContext.Resources.GetText(Resource.String.Common_Yes), (senderAlert, args) => { StartDownloadAndCalculateAsync(appContext, ec); });
                    builder.SetNegativeButton(appContext.Resources.GetText(Resource.String.Common_No), (senderAlert, args) => { _elevationProfileBeingGenerated = false; });

                    var myCustomDialog = builder.Create();

                    myCustomDialog.Show();
                }
            }
            catch (Exception ex)
            {
                PopupHelper.ErrorDialog(appContext, Resource.String.Main_ErrorGeneratingElevationProfile, ex.Message);
            }
        }