Added method to show confirm dialog
This commit is contained in:
@@ -8,12 +8,15 @@ using Windows.Devices.Geolocation;
|
|||||||
using Windows.Services.Maps;
|
using Windows.Services.Maps;
|
||||||
using Windows.UI;
|
using Windows.UI;
|
||||||
using Windows.UI.Notifications;
|
using Windows.UI.Notifications;
|
||||||
|
using Windows.UI.Popups;
|
||||||
using Windows.UI.Xaml.Controls.Maps;
|
using Windows.UI.Xaml.Controls.Maps;
|
||||||
|
|
||||||
namespace NavCityBreda.Helpers
|
namespace NavCityBreda.Helpers
|
||||||
{
|
{
|
||||||
class Util
|
class Util
|
||||||
{
|
{
|
||||||
|
public enum DialogType { YESNO, OKCANCEL }
|
||||||
|
|
||||||
public static ResourceLoader Loader
|
public static ResourceLoader Loader
|
||||||
{
|
{
|
||||||
get {
|
get {
|
||||||
@@ -60,28 +63,6 @@ namespace NavCityBreda.Helpers
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<MapRoute> FindDrivingRoute(Geopoint from, Geopoint to)
|
|
||||||
{
|
|
||||||
MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync(from, to);
|
|
||||||
MapRoute b = routeResult.Route;
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async Task<MapRoute> FindDrivingRoute(List<Geopoint> points)
|
|
||||||
{
|
|
||||||
MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteFromWaypointsAsync(points);
|
|
||||||
MapRoute b = routeResult.Route;
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async Task<MapRoute> FindDrivingRoute(string from, string to, Geopoint reference)
|
|
||||||
{
|
|
||||||
Geopoint f = await FindLocation(from, reference);
|
|
||||||
Geopoint t = await FindLocation(to, reference);
|
|
||||||
MapRoute m = await FindDrivingRoute(f, t);
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static async Task<String> FindAddress(Geopoint p)
|
public static async Task<String> FindAddress(Geopoint p)
|
||||||
{
|
{
|
||||||
// Reverse geocode the specified geographic location.
|
// Reverse geocode the specified geographic location.
|
||||||
@@ -162,7 +143,7 @@ namespace NavCityBreda.Helpers
|
|||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SendToastNotification(string title, string text)
|
public static void ShowToastNotification(string title, string text)
|
||||||
{
|
{
|
||||||
ToastTemplateType toastTemplate = ToastTemplateType.ToastText02;
|
ToastTemplateType toastTemplate = ToastTemplateType.ToastText02;
|
||||||
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);
|
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);
|
||||||
@@ -182,15 +163,44 @@ namespace NavCityBreda.Helpers
|
|||||||
ToastNotificationManager.CreateToastNotifier().Show(toast);
|
ToastNotificationManager.CreateToastNotifier().Show(toast);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string TranslatedManeuver(MapRouteManeuver maneuver)
|
public static async Task<bool> ShowConfirmDialog(string title, string content, DialogType type)
|
||||||
|
{
|
||||||
|
MessageDialog dlg = new MessageDialog(content, title);
|
||||||
|
if (type == DialogType.YESNO)
|
||||||
|
{
|
||||||
|
dlg.Commands.Add(new UICommand(Util.Loader.GetString("Yes")) { Id = 0 });
|
||||||
|
dlg.Commands.Add(new UICommand(Util.Loader.GetString("No")) { Id = 1 });
|
||||||
|
}
|
||||||
|
else if(type == DialogType.OKCANCEL)
|
||||||
|
{
|
||||||
|
dlg.Commands.Add(new UICommand(Util.Loader.GetString("Ok")) { Id = 0 });
|
||||||
|
dlg.Commands.Add(new UICommand(Util.Loader.GetString("Cancel")) { Id = 1 });
|
||||||
|
}
|
||||||
|
|
||||||
|
dlg.DefaultCommandIndex = 0;
|
||||||
|
dlg.CancelCommandIndex = 1;
|
||||||
|
|
||||||
|
var result = await dlg.ShowAsync();
|
||||||
|
|
||||||
|
if ((int)result.Id == 0)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string TranslatedManeuver(MapRouteManeuver maneuver, int distance)
|
||||||
{
|
{
|
||||||
string response = "";
|
string response = "";
|
||||||
bool onstreet = false;
|
bool onstreet = false;
|
||||||
|
bool meters = true;
|
||||||
|
|
||||||
switch(maneuver.Kind)
|
distance = (int)Math.Round(distance / 5.0) * 5;
|
||||||
|
|
||||||
|
switch (maneuver.Kind)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
response = Util.Loader.GetString("RouteSeeMap");
|
response = Util.Loader.GetString("RouteSeeMap");
|
||||||
|
meters = false;
|
||||||
break;
|
break;
|
||||||
case MapRouteManeuverKind.End:
|
case MapRouteManeuverKind.End:
|
||||||
response = Util.Loader.GetString("RouteEnd");
|
response = Util.Loader.GetString("RouteEnd");
|
||||||
@@ -201,9 +211,11 @@ namespace NavCityBreda.Helpers
|
|||||||
break;
|
break;
|
||||||
case MapRouteManeuverKind.None:
|
case MapRouteManeuverKind.None:
|
||||||
response = Util.Loader.GetString("RouteNone");
|
response = Util.Loader.GetString("RouteNone");
|
||||||
|
meters = false;
|
||||||
break;
|
break;
|
||||||
case MapRouteManeuverKind.Start:
|
case MapRouteManeuverKind.Start:
|
||||||
response = Util.Loader.GetString("RouteStart");
|
response = Util.Loader.GetString("RouteStart");
|
||||||
|
meters = false;
|
||||||
break;
|
break;
|
||||||
case MapRouteManeuverKind.TurnHardLeft:
|
case MapRouteManeuverKind.TurnHardLeft:
|
||||||
case MapRouteManeuverKind.TurnLeft:
|
case MapRouteManeuverKind.TurnLeft:
|
||||||
@@ -240,9 +252,16 @@ namespace NavCityBreda.Helpers
|
|||||||
if (maneuver.StreetName == "")
|
if (maneuver.StreetName == "")
|
||||||
onstreet = false;
|
onstreet = false;
|
||||||
|
|
||||||
|
if (distance < 10)
|
||||||
|
meters = false;
|
||||||
|
|
||||||
|
|
||||||
if (onstreet)
|
if (onstreet)
|
||||||
response += " " + Util.Loader.GetString("RouteOn") + " " + maneuver.StreetName;
|
response += " " + Util.Loader.GetString("RouteOn") + " " + maneuver.StreetName;
|
||||||
|
|
||||||
|
if (meters)
|
||||||
|
response = Util.Loader.GetString("RouteIn") + " " + distance + "m" + " " + response.ToLower();
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user