/// <summary> /// Shows the context menu /// </summary> /// <param name="point">map point where the long-tap occurred</param> /// <param name="appSettings">app settings</param> /// <returns>task to wait on</returns> public static async ValueTask <Result> ShowAsync(MapPoint point, AppSettings appSettings) { string latitudeText = GeoDataFormatter.FormatLatLong(point.Latitude, appSettings.CoordinateDisplayFormat); string longitudeText = GeoDataFormatter.FormatLatLong(point.Longitude, appSettings.CoordinateDisplayFormat); string caption = $"Selected point at Latitude: {latitudeText}, Longitude: {longitudeText}, Altitude {point.Altitude.GetValueOrDefault(0.0)} m"; var tcs = new TaskCompletionSource <Result>(); var items = new List <MenuItem> { new MenuItem { Text = "Add new waypoint", IconImageSource = SvgImageCache.GetImageSource("info/images/playlist-plus.svg"), Command = new Command(() => tcs.TrySetResult(Result.AddNewWaypoint)), }, new MenuItem { Text = "Navigate here", IconImageSource = SvgImageCache.GetImageSource("info/images/directions.svg"), Command = new Command(() => tcs.TrySetResult(Result.NavigateHere)), }, new MenuItem { Text = "Show flying range", IconImageSource = SvgImageCache.GetImageSource("info/images/arrow-expand-horizontal.svg"), Command = new Command(() => tcs.TrySetResult(Result.ShowFlyingRange)), }, }; ContextMenuPopupPage popupPage = null; EventHandler backgroundClicked = (sender, args) => tcs.TrySetResult(Result.Cancel); var viewModel = new ContextMenuPopupViewModel( caption, items, () => { popupPage.Navigation.PopPopupAsync(true); popupPage.BackgroundClicked -= backgroundClicked; }); popupPage = new ContextMenuPopupPage(viewModel); popupPage.BackgroundClicked += backgroundClicked; await popupPage.Navigation.PushPopupAsync(popupPage, true); return(await tcs.Task); }
public void TestFormatNegativeLatLong() { // set up double latLong = -47.6764385; // run string text1 = GeoDataFormatter.FormatLatLong(latLong, CoordinateDisplayFormat.Format_dd_dddddd); string text2 = GeoDataFormatter.FormatLatLong(latLong, CoordinateDisplayFormat.Format_dd_mm_mmm); string text3 = GeoDataFormatter.FormatLatLong(latLong, CoordinateDisplayFormat.Format_dd_mm_sss); // check Assert.AreEqual("-47.676439", text1, "formatted text must match"); Assert.AreEqual("-47° 40.586'", text2, "formatted text must match"); Assert.AreEqual("-47° 40' 35\"", text3, "formatted text must match"); }