public async Task TestMethod_page_success() { var camelSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; var json = JsonConvert.SerializeObject( new PageQuery() { Offset = 0, Count = 100 }, camelSettings); var routeQuery = new RouteQuery() { Body = new PageQuery() { Offset = 0, Count = 100 }, Method = "GET", Route = "v1/programs/page" }; var runResult = await(new CommandRunner()).RunViaRouteAsync(routeQuery); var items = runResult.Value as InstalledApp[]; Assert.AreEqual(100, items.Length); }
/// <summary> /// 添加途经点 /// </summary> private void menuBeginRoute_Click(object sender, EventArgs e) { //声明并初始化 pPathFinder = new RouteQuery(this.axMapControl1); //关联MapControl pPathFinder.OnCreate(this.axMapControl1.Object); }
static private async void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { var query = new RouteQuery(); var data = e.Result; var json = JsonConvert.DeserializeObject<Maproute>(data); if (json.elements.Count > 0) { int i = 0; GeoCoordinate[] geo = new GeoCoordinate[json.elements.Count]; String[] busstops = new String[json.elements.Count]; while (i < json.elements.Count) { geo[i] = new GeoCoordinate(json.elements[i].lat, json.elements[i].lon); i++; } query.Waypoints = geo; query.TravelMode = TravelMode.Driving; var result = await query.GetRouteAsync(); Route myroute = result; maproute = new MapRoute(myroute); maproute.Color = Colors.Red; // kmap.AddRoute(maproute); query.Dispose(); } }
private void Navigate(List <GeoCoordinate> geolist) { Geolocator MyGeolocator = new Geolocator(); MyGeolocator.DesiredAccuracyInMeters = 5; try { MyQuery = new RouteQuery(); MyQuery.Waypoints = geolist; MyQuery.QueryCompleted += QueryCompleted; //MyQuery.QueryCompleted += ((sender, e) => // { // if (e.Error == null) // { // MyQuery = new RouteQuery(); // MyQuery.Waypoints = geolist; // MyQuery.QueryCompleted += QueryCompleted; // } // }); MyQuery.QueryAsync(); } catch (UnauthorizedAccessException) { MessageBox.Show("Location is disabled in phone settings or capabilities are not checked."); } }
/// <summary> /// Get the route from me to a friend /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void FriendList_Route(object sender, RoutedEventArgs e) { try { //get index int selectedIndex = App.ViewModel.Friends.IndexOf((sender as MenuItem).DataContext as Friend); Friend friend = App.ViewModel.Friends[selectedIndex]; //Add start and end points List <GeoCoordinate> MyCoordinates = new List <GeoCoordinate>(); MyCoordinates.Add(new GeoCoordinate(Me.Latitude, Me.Longitude)); MyCoordinates.Add(new GeoCoordinate(friend.Latitude, friend.Longitude)); //send the query MyQuery = new RouteQuery(); MyQuery.Waypoints = MyCoordinates; MyQuery.QueryCompleted += MyQuery_QueryCompleted; try { MyQuery.QueryAsync(); } catch (Exception) { } } catch (Exception) { MessageBox.Show("Something gotta wrong."); } }
private async void GetCoordinates() { Geolocator MyGeolocator = new Geolocator(); MyGeolocator.DesiredAccuracyInMeters = 5; Geoposition MyGeoPosition = null; try { MyGeoPosition = await MyGeolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(10)); currentGeoCoordinate = ConvertGeocoordinate(MyGeoPosition.Coordinate); myMap.Center = currentGeoCoordinate; myMap.ZoomLevel = 15; if (!comeinGeoCoordinate.IsUnknown) { List<GeoCoordinate> geoCoordinates = new List<GeoCoordinate>(); geoCoordinates.Add(currentGeoCoordinate); geoCoordinates.Add(comeinGeoCoordinate); RouteQuery routeQuery = new RouteQuery(); routeQuery.Waypoints = geoCoordinates; routeQuery.QueryCompleted += routeQuery_QueryCompleted; routeQuery.QueryAsync(); } } catch (UnauthorizedAccessException) { MessageBox.Show("Location is disabled in phone settings"); } catch (Exception ex) { } }
void GenerarMap() { //double lat = 13.3039361; //double longi = -87.1818977; //double myLat = 13.309102541101671; //double myLongi = -87.18679750841795; myCoordinates.Add(new System.Device.Location.GeoCoordinate(lat, longi)); myCoordinates.Add(new System.Device.Location.GeoCoordinate(myLat, myLongi)); //myGeocode = new GeocodeQuery(); //myGeocode.GeoCoordinate = new System.Device.Location.GeoCoordinate(myLat, myLongi); //myGeocode.QueryCompleted += myGeocode_QueryCompleted; //myGeocode.QueryAsync(); myQuery = new RouteQuery(); myQuery.Waypoints = myCoordinates; myQuery.QueryCompleted += myQuery_QueryCompleted; myQuery.QueryAsync(); mapPlace.Center = new System.Device.Location.GeoCoordinate(myLat, myLongi); MapLayer myLayer = new MapLayer(); Pushpin myPushpin = new Pushpin(); MapOverlay myOverlay = new MapOverlay(); myPushpin.GeoCoordinate = new System.Device.Location.GeoCoordinate(myLat, myLongi); myPushpin.Content = "I'm Here"; myOverlay.Content = myPushpin; myOverlay.GeoCoordinate = new System.Device.Location.GeoCoordinate(myLat, myLongi); myLayer.Add(myOverlay); Pushpin pushpin = new Pushpin(); MapOverlay overlay = new MapOverlay(); pushpin.GeoCoordinate = new System.Device.Location.GeoCoordinate(lat, longi); pushpin.Content = PlaceName; overlay.Content = pushpin; overlay.GeoCoordinate = new System.Device.Location.GeoCoordinate(lat, longi); myLayer.Add(overlay); mapPlace.Layers.Add(myLayer); //Animacion del mapa mapPlace.SetView(new System.Device.Location.GeoCoordinate() { Latitude = lat, Longitude = longi }, 16, Microsoft.Phone.Maps.Controls.MapAnimationKind.Parabolic); }
/// <summary> /// add direction points to show direction /// </summary> /// <param name="fromLocation"></param> /// <param name="toLocation"></param> /// <returns></returns> public void Direction(System.Device.Location.GeoCoordinate fromLocation, System.Device.Location.GeoCoordinate toLocation) { RouteQuery routeQuery = new RouteQuery(); routeQuery.Waypoints = new List<System.Device.Location.GeoCoordinate>() { fromLocation, toLocation }; routeQuery.QueryCompleted += routeQuery_QueryCompleted; routeQuery.TravelMode = TravelMode.Driving; routeQuery.QueryAsync(); }
/// <summary> /// Method to initiate a route query. /// </summary> /// <param name="route">List of geocoordinates representing the route</param> private void CalculateRoute(List <GeoCoordinate> route) { ShowProgressIndicator(AppResources.CalculatingRouteProgressText); MyRouteQuery = new RouteQuery(); MyRouteQuery.TravelMode = _travelMode; MyRouteQuery.Waypoints = route; MyRouteQuery.QueryCompleted += RouteQuery_QueryCompleted; MyRouteQuery.QueryAsync(); }
// Constructor. public MapPage() { InitializeComponent(); StartMap(); routeQuery = new RouteQuery(); routeQuery.QueryCompleted += routeQuery_QueryCompleted; CarPolygon.Tap += CarPolygon_Tap; }
public async Task TestMethod_is_installed_success() { var camelSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; var count = 10; var json = JsonConvert.SerializeObject( new PageQuery() { Offset = 0, Count = count }, camelSettings); var routeQuery = new RouteQuery() { Body = new PageQuery() { Offset = 0, Count = count }, Method = "GET", Route = "v1/programs/page" }; var runResult = await(new CommandRunner()).RunViaRouteAsync(routeQuery); var items = runResult.Value as InstalledApp[]; Assert.AreEqual(count, items.Length); var displayName = items[0].DisplayName; json = JsonConvert.SerializeObject( new IsInstalledQuery() { DisplayName = displayName }, camelSettings); routeQuery = new RouteQuery() { Body = new IsInstalledQuery() { DisplayName = displayName }, Method = "GET", Route = "v1/programs/is-installed" }; runResult = await(new CommandRunner()).RunViaRouteAsync(routeQuery); PrimitiveValue <bool> result = runResult.Value as PrimitiveValue <bool>; Assert.AreEqual(true, result.Value); }
void Mygeocodequery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e) { if (e.Error == null) { MyQuery = new RouteQuery(); MyCoordinates.Add(e.Result[0].GeoCoordinate); MyQuery.Waypoints = MyCoordinates; MyQuery.QueryCompleted += MyQuery_QueryCompleted; MyQuery.QueryAsync(); Mygeocodequery.Dispose(); } }
private void Mygeocodequery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e) { if (e.Error == null) { MyQuery = new RouteQuery(); MyCoordinates.Add(e.Result[0].GeoCoordinate); MyQuery.Waypoints = MyCoordinates; MyQuery.QueryCompleted += MyQuery_QueryCompleted; MyQuery.QueryAsync(); Mygeocodequery.Dispose(); } }
private void vm_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "TrackPoints" && vm.TrackPoints.Count > 1) { RouteQuery query = new RouteQuery() { Waypoints = vm.TrackPoints, TravelMode = TravelMode.Driving, }; query.QueryCompleted += query_QueryCompleted; query.QueryAsync(); } }
private void FindRoute() { RouteQuery query = new RouteQuery() { TravelMode = TravelMode.Driving, Waypoints = new List<GeoCoordinate>() { TransitionData.start_location, TransitionData.finish_location, } }; query.QueryCompleted += routeQuery_QueryCompleted; query.QueryAsync(); }
public async Task <object> Fetch(object input) { Initialize(); //return await Task.Run(() => JsonConvert.SerializeObject(input, Formatting.Indented)); Input strongInput = null; string error = null; RunResult runResult = null; string jsonRunResult = null; Response response = new Response() { StatusCode = 404, StatusMessage = "", Value = null }; try { strongInput = input.ToInput(); ExpandoObject expandoInput = input as ExpandoObject; var expandoDict = expandoInput as IDictionary <string, object>; ExpandoObject body = expandoDict["body"] as ExpandoObject; var routeQuery = new RouteQuery() { Body = strongInput.Body, Method = strongInput.Method, Route = strongInput.Url }; runResult = await(new CommandRunner()).RunViaRouteAsync(routeQuery); response = new Response() { StatusCode = 200, StatusMessage = "OK", Value = runResult.Value }; if (runResult.ErrorCode != 0) { response.StatusCode = 404; response.StatusMessage = "Not Found"; response.Value = routeQuery; } } catch (Exception e) { error = e.Message; response.StatusMessage = error; } var expandoValue = response.ToExpandoObject(); return(expandoValue); }
// Constructor public MainPage() { InitializeComponent(); System.Windows.Input.Touch.FrameReported += Touch_FrameReported; map1.ZoomLevelChanged += map1_ZoomLevelChanged; AddResultToMap(new GeoCoordinate(60.17040395, 24.94121572), new GeoCoordinate(60.29143956, 24.96187636)); geoRev = new ReverseGeocodeQuery(); geoRev.QueryCompleted += geoRev_QueryCompleted; geoQ = new RouteQuery(); geoQ.QueryCompleted += geoQ_QueryCompleted; }
// Constructor public MainPage() { InitializeComponent(); System.Windows.Input.Touch.FrameReported += Touch_FrameReported; map1.ZoomLevelChanged += map1_ZoomLevelChanged; AddResultToMap(new GeoCoordinate(60.17040395, 24.94121572), new GeoCoordinate(60.29143956, 24.96187636)); geoRev = new ReverseGeocodeQuery(); geoRev.QueryCompleted += geoRev_QueryCompleted; geoQ = new RouteQuery(); geoQ.QueryCompleted += geoQ_QueryCompleted; }
/// <summary> /// Geo Code Query completed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void ShowRoute() { try { myRouteQuery = new RouteQuery(); myRouteCoordinates.Add(new GeoCoordinate(Convert.ToDouble(App.LocalServiceLatitude), Convert.ToDouble(App.LocalServiceLongitude))); myRouteQuery.Waypoints = myRouteCoordinates; myRouteQuery.TravelMode = TravelMode.Driving; myRouteQuery.QueryCompleted += myRouteQuery_QueryCompleted; myRouteQuery.QueryAsync(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { if (Tag != null) { Cmd[] cmds = (Tag as Eqlogic).cmds; Cmd cmd = cmds.GetCmdByConfigModeName("travelDistance"); if (cmd != null) { LblTrajet.Text = cmd.ToString(""); } cmd = cmds.GetCmdByConfigModeName("travelTime"); if (cmd != null) { LblTemp.Text = cmd.ToString(""); } cmd = cmds.GetCmdByConfigModeName("distance"); if (cmd != null) { LblDistance.Text = cmd.ToString(""); } cmd = cmds.GetCmdByConfigModeName("dynamic"); if (cmd != null) { string name = cmd.name; string coord = cmd.ToString(""); string[] tmp = coord.Split(','); MyCoordinates.Add(new GeoCoordinate(double.Parse(tmp[0], CultureInfo.InvariantCulture), double.Parse(tmp[1], CultureInfo.InvariantCulture))); cmd = cmds.GetCmdByConfigModeName("fixe"); if (cmd != null) { LblTitle.Text = cmd.name + "=>" + name; coord = cmd.ToString(""); tmp = coord.Split(','); MyCoordinates.Add(new GeoCoordinate(double.Parse(tmp[0], CultureInfo.InvariantCulture), double.Parse(tmp[1], CultureInfo.InvariantCulture))); RouteQuery MyQuery = new RouteQuery(); MyQuery.TravelMode = TravelMode.Driving; MyQuery.Waypoints = MyCoordinates; MyQuery.QueryCompleted += MyQuery_QueryCompleted; MyQuery.QueryAsync(); } MapControl.ZoomLevel = 16; MapControl.Center = MyCoordinates[0]; } } }
void MainPage_Loaded(object sender, RoutedEventArgs e) { mainMap.Center = new System.Device.Location.GeoCoordinate(41.532887, -87.355024); mainMap.ZoomLevel = 17; mainMap.Pitch = 45; mainMap.LandmarksEnabled = true; InitializeGPS(); InitializePolygons(); mapLayer = new MapLayer(); mapLayer.Add(Car); mainMap.Layers.Add(mapLayer); //--Add to load routeQuery = new RouteQuery(); routeQuery.QueryCompleted += routeQuery_QueryCompleted; }
public ItineraryDetails() { InitializeComponent(); //check tinh trang hanh trinh if (GlobalData.selectedItinerary.status.Equals(null)) { } else { } MapOverlay overlay = new MapOverlay(); //set point on map //draw start poit overlay = UserControls.MarkerDraw.DrawMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long)); wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long)); layer.Add(overlay); //draw end point overlay = UserControls.MarkerDraw.DrawMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long)); wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long)); layer.Add(overlay); mapItineraryDetails.Layers.Add(layer); //driection routeQuery = new RouteQuery(); //GeocodeQuery Mygeocodequery = null; routeQuery.QueryCompleted += routeQuery_QueryCompleted; routeQuery.TravelMode = TravelMode.Driving; routeQuery.RouteOptimization = RouteOptimization.MinimizeDistance; routeQuery.Waypoints = wayPoints; routeQuery.QueryAsync(); //set itinerary info txtDescription.Text = GlobalData.selectedItinerary.description; txtStartAddress.Text = GlobalData.selectedItinerary.start_address; txtEndAddress.Text = GlobalData.selectedItinerary.end_address; txtCost.Text = GlobalData.selectedItinerary.cost; txtPhone.Text = GlobalData.selectedItinerary.phone; txtLeaveDay.Text = GlobalData.selectedItinerary.leave_date; txtDistance.Text = GlobalData.selectedItinerary.distance.ToString(); txtDuration.Text = GlobalData.selectedItinerary.duration.ToString(); }
private void reverseGeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e) { if (e.Error == null) { geoCoordenadas.Add(e.Result[0].GeoCoordinate); routeQuery = new RouteQuery() { Waypoints = geoCoordenadas }; routeQuery.QueryCompleted += routeQuery_QueryCompleted; routeQuery.QueryAsync(); reverseGeocodeQuery.Dispose(); GC.SuppressFinalize(reverseGeocodeQuery); } }
public MapPage() { this.InitializeComponent(); this.DataContext = App.DataContext; Touch.FrameReported += this.Touch_FrameReported; this.map1.ZoomLevelChanged += this.map1_ZoomLevelChanged; this.geoRev = new ReverseGeocodeQuery(); this.geoRev.QueryCompleted += this.geoRev_QueryCompleted; this.geoQ = new RouteQuery(); this.geoQ.QueryCompleted += this.geoQ_QueryCompleted; this.markerLayer = new MapLayer(); this.map1.Layers.Add(this.markerLayer); this.AddPlusMinusButtons(); }
public ItineraryDetails() { InitializeComponent(); //check tinh trang hanh trinh if (GlobalData.selectedItinerary.status.Equals(null)) { } else { } MapOverlay overlay = new MapOverlay(); //set point on map //draw start poit overlay = UserControls.MarkerDraw.DrawMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long)); wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long)); layer.Add(overlay); //draw end point overlay = UserControls.MarkerDraw.DrawMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long)); wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long)); layer.Add(overlay); mapItineraryDetails.Layers.Add(layer); //driection routeQuery = new RouteQuery(); //GeocodeQuery Mygeocodequery = null; routeQuery.QueryCompleted += routeQuery_QueryCompleted; routeQuery.TravelMode = TravelMode.Driving; routeQuery.RouteOptimization = RouteOptimization.MinimizeDistance; routeQuery.Waypoints = wayPoints; routeQuery.QueryAsync(); //set itinerary info txtDescription.Text = GlobalData.selectedItinerary.description; txtStartAddress.Text = GlobalData.selectedItinerary.start_address; txtEndAddress.Text = GlobalData.selectedItinerary.end_address; txtCost.Text = GlobalData.selectedItinerary.cost; txtPhone.Text = GlobalData.selectedItinerary.phone; txtLeaveDay.Text = GlobalData.selectedItinerary.leave_date; txtDistance.Text = GlobalData.selectedItinerary.distance.ToString(); txtDuration.Text = GlobalData.selectedItinerary.duration.ToString(); }
/// <summary> /// Method to show Route /// </summary> private async void OnShowRoute() { this.UserLocationMarker.GeoCoordinate = Globals.RecentLocation.Coordinate; this.UserLocationMarker.Visibility = System.Windows.Visibility.Visible; this.RouteDirectionsPushPin.Visibility = Visibility.Visible; this.Map.SetView(this.UserLocationMarker.GeoCoordinate, this.userLocationMarkerZoomLevel); if (this.RouteDirectionsPushPin.GeoCoordinate == null || this.RouteDirectionsPushPin.Visibility == Visibility.Collapsed) { Deployment.Current.Dispatcher.BeginInvoke(() => Globals.DisplayToast(CustomMessage.MapTapHoldToShowRouteFromLocationToDestination, "basicWrap", "Info!")); } else { RouteQuery query; List <GeoCoordinate> wayPoints; Route route; if (this.MapRoute != null) { this.Map.RemoveRoute(this.MapRoute); } //await this.ShowUserLocation(); query = new RouteQuery(); wayPoints = new List <GeoCoordinate>(); wayPoints.Add(this.UserLocationMarker.GeoCoordinate); wayPoints.Add(this.RouteDirectionsPushPin.GeoCoordinate); query.Waypoints = wayPoints; route = await query.GetRouteAsync(); this.MapRoute = new MapRoute(route); this.Map.SetView(route.BoundingBox); this.Map.AddRoute(this.MapRoute); this.ChangeMode(MapMode.Route); } }
// Constructor public MainPage() { InitializeComponent(); markerLayer = new MapLayer(); startMark = AddMarkersToMap("Start", new GeoCoordinate(60.2214, 24.7572)); markerLayer.Add(startMark); enddMark = AddMarkersToMap("End", new GeoCoordinate(61.4468, 23.8646)); markerLayer.Add(enddMark); map1.Layers.Add(markerLayer); geoQ = new RouteQuery(); geoQ.QueryCompleted += geoQ_QueryCompleted; Debug.WriteLine("All construction done for rutting"); }
// Constructor public MainPage() { InitializeComponent(); markerLayer = new MapLayer(); startMark = AddMarkersToMap("Start", new GeoCoordinate(60.2214, 24.7572)); markerLayer.Add(startMark); enddMark = AddMarkersToMap("End", new GeoCoordinate(61.4468, 23.8646)); markerLayer.Add(enddMark); map1.Layers.Add(markerLayer); geoQ = new RouteQuery(); geoQ.QueryCompleted += geoQ_QueryCompleted; Debug.WriteLine("All construction done for rutting"); }
public async Task <object> Invoke(object input) { Input strongInput = null; string json = null; string error = null; RunResult runResult = null; string jsonRunResult = null; try { strongInput = input.ToInput(); ExpandoObject expandoInput = input as ExpandoObject; var expandoDict = expandoInput as IDictionary <string, object>; ExpandoObject body = expandoDict["body"] as ExpandoObject; json = expandoInput.ToJson(); var routeQuery = new RouteQuery() { Body = strongInput.Body, Method = strongInput.Method, Route = strongInput.Url }; runResult = await(new CommandRunner()).RunViaRouteAsync(routeQuery); jsonRunResult = JsonConvert.SerializeObject(runResult); } catch (Exception e) { error = e.Message; } ++count; if (!string.IsNullOrEmpty(error)) { return($"Hello from dot net:[{count}],error[{error}]"); } return($"Hello from dot net:[{count}],json[{json}]," + $"url[{strongInput.Url}],method[{strongInput.Method}]," + $"jsonHeaders[{strongInput.JsonHeaders}],jsonBody[{strongInput.JsonBody}]," + $"jsonRunResult:[{jsonRunResult}]"); }
private void CreateDirectionsPivotItem() { var currentPosition = LocationService.CurrentPosition; if (currentPosition != null && !currentPosition.IsUnknown && Settings.GetBool(Setting.LocationServicesEnabled)) { var routeQuery = new RouteQuery { RouteOptimization = RouteOptimization.MinimizeTime, TravelMode = TravelMode.Walking, Waypoints = new[] { currentPosition, new GeoCoordinate(departuresAndArrivalsTable.Station.Location.Lat, departuresAndArrivalsTable.Station.Location.Long) }, }; routeQuery.QueryCompleted += OnRouteQueryCompleted; routeQuery.QueryAsync(); } }
public async Task <Direction> WalkDistanceAsync(double sourceLat, double sourceLon, double targetLat, double targetLon) { Task completeTask = new Task(() => { }); double length = -1; TimeSpan time; var query = new RouteQuery { TravelMode = TravelMode.Walking, Waypoints = new GeoCoordinate[] { new GeoCoordinate(sourceLat, sourceLon), new GeoCoordinate(targetLat, targetLon) } }; query.QueryCompleted += delegate(object sender, QueryCompletedEventArgs <Microsoft.Phone.Maps.Services.Route> e) { if (e.Error == null) { var resultRoute = e.Result; length = resultRoute.LengthInMeters; time = resultRoute.EstimatedDuration; //MapRoute MyMapRoute = new MapRoute(resultRoute); query.Dispose(); } completeTask.Start(); }; query.QueryAsync(); await completeTask; if (length == -1) { return(null); } else { var res = new Direction { DistanceInMeters = length, EstimatedDuration = time }; return(res); } }
/// <summary> /// Event handler for the show route button /// </summary> /// <param name="sender">Sender of the event</param> /// <param name="e">Event arguments</param> private async void OnShowRoute(object sender, EventArgs e) { if (this.RouteDirectionsPushPin.GeoCoordinate == null || this.RouteDirectionsPushPin.Visibility == Visibility.Collapsed) { MessageBox.Show("Tap and hold somewhere in the map to show a Pushpin. After that you can show route from your location to the destination"); } else { RouteQuery query; List <GeoCoordinate> wayPoints; Route route; this.ShowStores(false); if (this.MapRoute != null) { this.Map.RemoveRoute(this.MapRoute); } await this.ShowUserLocation(); query = new RouteQuery(); wayPoints = new List <GeoCoordinate>(); wayPoints.Add(this.UserLocationMarker.GeoCoordinate); wayPoints.Add(this.RouteDirectionsPushPin.GeoCoordinate); query.Waypoints = wayPoints; route = await query.GetRouteAsync(); this.MapRoute = new MapRoute(route); this.Map.SetView(route.BoundingBox); this.Map.AddRoute(this.MapRoute); this.ChangeMode(MapMode.Route); } }
/// <summary> /// Geo Code Query completed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void mygeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs <IList <MapLocation> > e) { if (e.Error == null) { try { myRouteQuery = new RouteQuery(); myRouteCoordinates.Add(e.Result[0].GeoCoordinate); myRouteQuery.Waypoints = myRouteCoordinates; myRouteQuery.QueryCompleted += myRouteQuery_QueryCompleted; myRouteQuery.QueryAsync(); mygeocodeQuery.Dispose(); } catch (Exception) { } } }
void walkingRoute(GeoCoordinate currentLocation, GeoCoordinate stopLocation) //Get walking route from selected location to selected stop { if (MyMapRoute != null) { stopsMap.RemoveRoute(MyMapRoute); } MarkStopsLocations(ClosestStops); List<GeoCoordinate> MyCoordinates = new List<GeoCoordinate>(); MyCoordinates.Add(currentLocation); MyCoordinates.Add(stopLocation); RouteQuery WalkingRouteQuery = new RouteQuery(); WalkingRouteQuery.Waypoints = MyCoordinates; WalkingRouteQuery.TravelMode = TravelMode.Walking; //progressBar.Visibility = Visibility.Visible; progressBar.FlowDirection = System.Windows.FlowDirection.LeftToRight; WalkingRouteQuery.QueryCompleted += WalkingRouteQuery_QueryCompleted; WalkingRouteQuery.QueryAsync(); }
void geocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e) { if (e.Error == null) { GeoCoordinate geoCoordinate = e.Result[0].GeoCoordinate; myMap.Center = e.Result[0].GeoCoordinate; List<GeoCoordinate> geoCoordinates=new List<GeoCoordinate>(); geoCoordinates.Add(e.Result[0].GeoCoordinate); geoCoordinates.Add(e.Result[1].GeoCoordinate); RouteQuery routeQuery = new RouteQuery(); routeQuery.Waypoints = geoCoordinates; routeQuery.QueryCompleted += routeQuery_QueryCompleted; routeQuery.QueryAsync(); } }
/// <summary> /// Geo Code Query completed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void mygeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e) { if (e.Error == null) { try { myRouteQuery = new RouteQuery(); myRouteCoordinates.Add(e.Result[0].GeoCoordinate); myRouteQuery.Waypoints = myRouteCoordinates; myRouteQuery.QueryCompleted += myRouteQuery_QueryCompleted; myRouteQuery.QueryAsync(); mygeocodeQuery.Dispose(); } catch (Exception) { } } }
/// <summary> /// Method to initiate a route query. /// </summary> /// <param name="route">List of geocoordinates representing the route</param> private void CalculateRoute(List<GeoCoordinate> route) { ShowProgressIndicator(AppResources.CalculatingRouteProgressText); MyRouteQuery = new RouteQuery(); MyRouteQuery.TravelMode = _travelMode; MyRouteQuery.Waypoints = route; MyRouteQuery.QueryCompleted += RouteQuery_QueryCompleted; MyRouteQuery.QueryAsync(); }
private void GetCoordinates() { routeQuery = new RouteQuery(); /* GeoCoordinate currentLocation = new GeoCoordinate(37.7842, -122.4016); GeocodeQuery startPoint = new GeocodeQuery(); startPoint.SearchTerm = "Golden Gate Bridge"; startPoint.GeoCoordinate = currentLocation; startPoint.QueryCompleted += geocodequery_QueryCompleted; startPoint.QueryAsync(); pointCount++; GeocodeQuery endPoint = new GeocodeQuery(); endPoint.SearchTerm = "Rodeo Beach"; endPoint.GeoCoordinate = currentLocation; endPoint.QueryCompleted += geocodequery_QueryCompleted; endPoint.QueryAsync(); pointCount++; */ GeoCoordinate bridge = new GeoCoordinate(37.7829, -122.4000); GeoCoordinate midWay1 = new GeoCoordinate(37.7875, -122.4033); GeoCoordinate beach = new GeoCoordinate(37.8092, -122.4164); MyCoordinates.Add(bridge); MyCoordinates.Add(midWay1); MyCoordinates.Add(beach); routeQuery.Waypoints = MyCoordinates; routeQuery.QueryCompleted += routeQuery_QueryCompleted; routeQuery.QueryAsync(); }
public ItineraryDetails() { InitializeComponent(); //check status cua customer if (GlobalData.customer_status.Equals(2)) { //check tinh trang hanh trinh //hanh trinh chua ai dang ki if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_CREATED)) { //create button register itinerary Button btnAcceptItinerary = new Button(); btnAcceptItinerary.Content = "Accept Itinerary"; btnAcceptItinerary.Click += btnAcceptItinerary_Click; gridMap.Children.Add(btnAcceptItinerary); Grid.SetRow(btnAcceptItinerary, 1); } //dang doi driver accept else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_CUSTOMER_ACCEPTED)) { //tao trang thai dang doi accept, tao nut huy hanh trinh Button btnCancelItinerary = new Button(); btnCancelItinerary.Content = "Cancel Itinerary"; btnCancelItinerary.Click += btnCancelItinerary_Click; gridMap.Children.Add(btnCancelItinerary); Grid.SetRow(btnCancelItinerary, 1); } //driver da accepted else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_DRIVER_ACCEPTED)) { //tao trang thai da duoc accept, tao nut } //ongoing else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_ONGOING)) { //tao trang thai da duoc accept, tao nut //create button tracking hanh trinh Button btnTracking = new Button(); btnTracking.Content = "Tracking"; btnTracking.Click += btnTracking_Click; gridInfo.Children.Add(btnTracking); Grid.SetRow(btnTracking, 6); } //hanh trinh da ket thuc else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_FINISHED)) { } } else if (GlobalData.customer_status.Equals(1)) { } else { } MapOverlay overlay = new MapOverlay(); //set point on map //draw start poit overlay = UserControls.MarkerDraw.DrawCurrentMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long)); wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long)); mapItineraryDetails.Center = overlay.GeoCoordinate; layer.Add(overlay); //draw end point overlay = UserControls.MarkerDraw.DrawCurrentMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long)); wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long)); layer.Add(overlay); mapItineraryDetails.Layers.Add(layer); mapItineraryDetails.ZoomLevel = 14; //driection routeQuery = new RouteQuery(); //GeocodeQuery Mygeocodequery = null; routeQuery.QueryCompleted += routeQuery_QueryCompleted; routeQuery.TravelMode = TravelMode.Driving; routeQuery.RouteOptimization = RouteOptimization.MinimizeDistance; routeQuery.Waypoints = wayPoints; routeQuery.QueryAsync(); //set itinerary info txtDescription.Text = GlobalData.selectedItinerary.description; txtStartAddress.Text = GlobalData.selectedItinerary.start_address; txtEndAddress.Text = GlobalData.selectedItinerary.end_address; txtCost.Text = GlobalData.selectedItinerary.cost; txtPhone.Text = GlobalData.selectedItinerary.phone; txtLeaveDay.Text = GlobalData.selectedItinerary.leave_date; txtDistance.Text = GlobalData.selectedItinerary.distance.ToString(); txtDuration.Text = GlobalData.selectedItinerary.duration.ToString(); }
/// <summary> /// Cái này để xóa route /// </summary> private void RemoveMapRoute() { if (driverMapRoute != null) { map_DriverMap.RemoveRoute(driverMapRoute); driverMapLayer.Remove(driverDestinationIconOverlay); map_DriverMap.Layers.Remove(driverMapLayer); driverMapRoute = null; driverQuery = null; driverDestinationIconOverlay = null; } }
private void RemoveMapRouteOnly() { if (driverMapRoute != null) { map_DriverMap.RemoveRoute(driverMapRoute); driverMapRoute = null; driverQuery = null; } }
/// <summary> /// CÁI NÀY ĐỂ VẼ ĐƯỜNG ĐI GIỮA 2 điểm /// </summary> /// <param name="startPosition"></param> /// <param name="endPosition"></param> private void GetRouteOnMap(GeoCoordinate startPosition, GeoCoordinate endPosition) { if (driverMapRoute != null) { map_DriverMap.RemoveRoute(driverMapRoute); driverMapRoute = null; driverQuery = null; map_DriverMap.Layers.Remove(driverMapLayer); } driverQuery = new RouteQuery() { TravelMode = TravelMode.Driving, Waypoints = new List<GeoCoordinate>() { startPosition, endPosition }, RouteOptimization = RouteOptimization.MinimizeTime }; driverQuery.QueryCompleted += driverRouteQuery_QueryCompleted; driverQuery.QueryAsync(); }
/// <summary> /// CÁI NÀY LÀ ĐỂ KẺ LẠI MỘT ĐưỜNG MAP TRONG QUÁ TRÌNH TAXI ĐANG DI CHuyển /// </summary> /// <param name="startPosition"></param> /// <param name="endPosition"></param> private void TrackingRouteOnMap(GeoCoordinate startPosition, GeoCoordinate endPosition) { driverMapTrackerQuery = new RouteQuery() { TravelMode = TravelMode.Driving, Waypoints = new List<GeoCoordinate>() { startPosition, endPosition }, RouteOptimization = RouteOptimization.MinimizeTime }; driverMapTrackerQuery.QueryCompleted += driverTrackingRouteQuery_QueryCompleted; driverMapTrackerQuery.QueryAsync(); }
void MygeocodequerylocationSearch_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e) { List<GeoCoordinate> r; if (e.Result.Count > 0) { _myQueryLocation = new RouteQuery(); r = new List<GeoCoordinate> { new GeoCoordinate(_myLatitude, _myLongitude), e.Result[0].GeoCoordinate }; _myQueryLocation.Waypoints = r; _myQueryLocation.QueryCompleted += MyQuerySearchLocation_QueryCompleted; _myQueryLocation.QueryAsync(); //Mygeocodequerylocation.Dispose(); } }
public static Task <Route> GetRouteAsync(this RouteQuery routeQuery) { return(QueryAsync <Route>(routeQuery)); }
private void CalculateRoute(double latitudeA, double longitudeA, double latitudeB, double longitudeB, Color color) { RouteQuery geoQ = new RouteQuery(); geoQ.QueryCompleted += geoQ_QueryCompleted; if (geoQ.IsBusy == true) { geoQ.CancelAsync(); } List<GeoCoordinate> MyWayPoints = new List<GeoCoordinate>(); MyWayPoints.Add(new GeoCoordinate(latitudeA,longitudeA)); MyWayPoints.Add(new GeoCoordinate(latitudeB, longitudeB)); geoQ.Waypoints = MyWayPoints; geoQ.QueryAsync(); }
private void MappingRoute(object sender, System.EventArgs e) { routeQuery = new RouteQuery(); routeQuery.TravelMode = TravelMode.Walking; routeQuery.QueryCompleted += routeQuery_QueryCompleted; routeQuery.Waypoints = waypoints; routeQuery.QueryAsync(); }
/// <summary> /// Cái này để xóa route /// </summary> private void RemoveTrakingMapRoute() { if (driverMapTrackerRoute != null) { map_DriverMap.RemoveRoute(driverMapTrackerRoute); driverMapTrackerRoute = null; driverMapTrackerQuery = null; } }
private void CreateDirectionsPivotItem() { var currentPosition = LocationService.CurrentPosition; if (currentPosition != null && !currentPosition.IsUnknown && Settings.GetBool(Setting.LocationServicesEnabled)) { var routeQuery = new RouteQuery { RouteOptimization = RouteOptimization.MinimizeTime, TravelMode = TravelMode.Walking, Waypoints = new[] { currentPosition, new GeoCoordinate(departuresAndArrivalsTable.Station.Location.Lat, departuresAndArrivalsTable.Station.Location.Long) }, }; routeQuery.QueryCompleted += OnRouteQueryCompleted; routeQuery.QueryAsync(); } }
/// <summary> /// Hàm này để đặt lại mọi trạng thái điều kiện /// </summary> private void ResetFlag() { //For Router driverGeocodeQuery = null; driverQuery = null; driverMapRoute = null; driverRoute = null; //For get Current Location driverFirstGeolocator = null; driverFirstGeoposition = null; driverMapOverlay = null; driverMapLayer = null; //For Router driverGeocodeQuery = null; driverQuery = null; driverMapRoute = null; driverRoute = null; //For get Current Location driverFirstGeolocator = null; driverFirstGeoposition = null; driverMapOverlay = null; driverMapLayer = null; //Rider Destination Icon Overlay driverDestinationIconOverlay = null; //For Update Current Location currentLat = 0; currentLng = 0; countForUpdateLocation = 0; //For trip newTrip = null; myTrip = null; //For Trip Complete startLatitude = 0; startLongitude = 0; endLatitude = 0; endLongitude = 0; isTrack = false; estimateCost = 0; totalFare = 0; //For Distance distanceKm = 0; //mySelectedVehicle = null; if (tNetTripData != null) { tNetTripData = null; } //for complete trip completeTrip = null; //For continous tracking on map fiveStepBeforeLat = 0; fiveStepBeforeLng = 0; fiveStepAfterLat = 0; fiveStepAfterLng = 0; //driverMapTrackerQuery = null; //driverMapTrackerRoute = null; isTrackingRoute = false; countTracking = 0; //driverMapTrakerLayer = null; //driverMapTrackerOverlay = null; isCalculateFare = false; realDistance = 0; realFare = 0; isFinishTrip = false; isTrakingStated = false; txt_DistanceKm.Text = "0.0 (km)"; txt_PricePerDistance.Text = "0.000 (đ)"; txt_TotalPrice.Text = "0.000 (đ)"; }
public async Task TestMethod1() { var camelSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; var fetchInit = new FetchInit() { Headers = new Dictionary <string, string>(), Method = "Get" }; var json = JsonConvert.SerializeObject( new ComplexData() { SomeInt = 42, SomeString = "Hello Cat" }, camelSettings); fetchInit.Body = JObject.Parse(json); var jsonFetchInit = JsonConvert.SerializeObject(fetchInit, camelSettings); var fetchInit2 = JsonConvert.DeserializeObject <FetchInit>(jsonFetchInit); var jsonFetchInit2 = JsonConvert.SerializeObject(fetchInit2, camelSettings); var body = fetchInit2.Body; var jsonBody = JsonConvert.SerializeObject((object)body, camelSettings); var runResult = new CommandRunner().Run(new[] { "command-runner-test-class", "complex-param-to-hyphen-with-return", string.Format(@"--param-one={0}", json) }); var routeQuery = new RouteQuery() { Body = new ComplexData() { SomeInt = 42, SomeString = "Hello Cat" }, Method = "GET", Route = "My/Route/Base/v1/compleX" }; runResult = await(new CommandRunner()).RunViaRouteAsync(routeQuery); runResult = new CommandRunner().WithCommandFromType <CommandRunnerTestClass>().Run(new[] { "command-runner-test-class", "multiple-params-to-hyphen", "--param-one=one", "--param-two=two", "--param-three=three" }); runResult = new CommandRunner().WithCommandFromType <CommandRunnerTestClass>().Run(new[] { "command-runner-test-class", "multiple-params-to-hyphen-with-return", "--param-one=one", "--param-two=two", "--param-three=three" }); }
/// <summary> /// Get the route from me to a friend /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void FriendList_Route(object sender, RoutedEventArgs e) { try { //get index int selectedIndex = App.ViewModel.Friends.IndexOf((sender as MenuItem).DataContext as Friend); Friend friend = App.ViewModel.Friends[selectedIndex]; //Add start and end points List<GeoCoordinate> MyCoordinates = new List<GeoCoordinate>(); MyCoordinates.Add(new GeoCoordinate(Me.Latitude, Me.Longitude)); MyCoordinates.Add(new GeoCoordinate(friend.Latitude, friend.Longitude)); //send the query MyQuery = new RouteQuery(); MyQuery.Waypoints = MyCoordinates; MyQuery.QueryCompleted += MyQuery_QueryCompleted; try { MyQuery.QueryAsync(); } catch (Exception) { } } catch (Exception) { MessageBox.Show("Something gotta wrong."); } }
void Mygeocodequery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e) { if (e.Error == null) { MyQuery = new RouteQuery(); //MyCoordinates.Add(e.Result[0].GeoCoordinate); MyCoordinates[1] = e.Result[0].GeoCoordinate; DrawDestinationPushpin(); distanceLeft = MyCoordinates[0].GetDistanceTo(MyCoordinates[1]) * 0.000621371; // distance calculator in meters, converted to miles DistanceLeftDistanceTextBlock.Text = distanceLeft.ToString("0.00"); /* MyQuery.Waypoints = MyCoordinates; MyQuery.QueryCompleted += MyQuery_QueryCompleted; MyQuery.QueryAsync(); Mygeocodequery.Dispose(); * */ } }
private void DrawLinePathOnMap() { for (int i = 0; i < ObjRootObjectJourney.data.latlong.Count - 1; i++) { geo1 = new GeoCoordinate(Convert.ToDouble(ObjRootObjectJourney.data.latlong[i].latitude), Convert.ToDouble(ObjRootObjectJourney.data.latlong[i].longitude)); geo2 = new GeoCoordinate(Convert.ToDouble(ObjRootObjectJourney.data.latlong[i + 1].latitude), Convert.ToDouble(ObjRootObjectJourney.data.latlong[i + 1].longitude)); query = new RouteQuery() { TravelMode = TravelMode.Driving, Waypoints = new List<GeoCoordinate>() { geo1, geo2 } }; query.QueryCompleted += routeQuery_QueryCompleted; query.QueryAsync(); } progressBar1.Visibility = Visibility.Collapsed; }
public DriverItineraryDetails() { InitializeComponent(); //hanh trinh chua ai dang ki if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_CREATED)) { //create button update hanh trinh Button btnUpdate = new Button(); btnUpdate.Content = "Cập Nhật"; btnUpdate.Click += btnUpdate_Click; gridInfo.Children.Add(btnUpdate); Grid.SetRow(btnUpdate, 5); //create button huy hanh trinh Button btnDelete = new Button(); btnDelete.Content = "Xóa"; btnDelete.Click += btnDelete_Click; gridInfo.Children.Add(btnDelete); Grid.SetRow(btnDelete, 6); //cho phep sua doi dien di va diem den } //dang doi driver accept else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_CUSTOMER_ACCEPTED)) { //tao button accept va button huy customer accept //create button accept hanh trinh Button btnAccept = new Button(); btnAccept.Content = "Chấp Nhận"; btnAccept.Click += btnAccept_Click; gridInfo.Children.Add(btnAccept); Grid.SetRow(btnAccept, 5); //create button reject hanh trinh Button btnReject = new Button(); btnReject.Content = "Từ Chối"; btnReject.Click += btnReject_Click; gridInfo.Children.Add(btnReject); Grid.SetRow(btnReject, 6); } //driver da accepted else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_DRIVER_ACCEPTED)) { // //create button start hanh trinh Button btnStart = new Button(); btnStart.Content = "Start"; btnStart.Click += btnStart_Click; gridInfo.Children.Add(btnStart); Grid.SetRow(btnStart, 6); } //ongoing else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_ONGOING)) { //create button tracking hanh trinh Button btnTracking = new Button(); btnTracking.Content = "Tracking"; btnTracking.Click += btnTracking_Click; gridInfo.Children.Add(btnTracking); Grid.SetRow(btnTracking, 6); //btn Finish } //hanh trinh da ket thuc else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_FINISHED)) { } //draw 2 points on map startPointOverlay = UserControls.MarkerDraw.DrawCurrentMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long)); wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long)); mapLayer.Add(startPointOverlay); endPointOverlay = UserControls.MarkerDraw.DrawCurrentMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long)); wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long)); mapLayer.Add(endPointOverlay); //set zoom and center point mapItineraryDetails.ZoomLevel = 14; mapItineraryDetails.Center = startPointOverlay.GeoCoordinate; mapItineraryDetails.Layers.Add(mapLayer); //draw route routeQuery = new RouteQuery(); //GeocodeQuery Mygeocodequery = null; routeQuery.QueryCompleted += routeQuery_QueryCompleted; routeQuery.TravelMode = TravelMode.Driving; routeQuery.RouteOptimization = RouteOptimization.MinimizeDistance; routeQuery.Waypoints = wayPoints; routeQuery.QueryAsync(); //set text 2 points txtboxStart.Text = GlobalData.selectedItinerary.start_address; txtboxEnd.Text = GlobalData.selectedItinerary.end_address; //set text itinerary info txtbDistance.Text = GlobalData.selectedItinerary.distance.ToString(); txtbDescription.Text = GlobalData.selectedItinerary.description; txtbCost.Text = GlobalData.selectedItinerary.cost; //xu ly ngay thang string datetimeString = GlobalData.selectedItinerary.leave_date.Trim(); DateTime datetime = DateTimes.DatetimeConvert.convertDateTimeFromString(datetimeString); datePicker.Value = datetime; timePicker.Value = datetime; //datePicker.Value = GlobalData.selectedItinerary.da }
public DriverItineraryDetails() { InitializeComponent(); //hanh trinh chua ai dang ki if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_CREATED)) { //create button update hanh trinh Button btnUpdate = new Button(); btnUpdate.Content = "Cập Nhật"; btnUpdate.Click += btnUpdate_Click; gridInfo.Children.Add(btnUpdate); Grid.SetRow(btnUpdate, 5); //create button huy hanh trinh Button btnDelete = new Button(); btnDelete.Content = "Xóa"; btnDelete.Click += btnDelete_Click; gridInfo.Children.Add(btnDelete); Grid.SetRow(btnDelete, 6); //cho phep sua doi dien di va diem den } //dang doi driver accept else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_CUSTOMER_ACCEPTED)) { //tao button accept va button huy customer accept //create button accept hanh trinh Button btnAccept = new Button(); btnAccept.Content = "Chấp Nhận"; btnAccept.Click += btnAccept_Click; gridInfo.Children.Add(btnAccept); Grid.SetRow(btnAccept, 5); //create button reject hanh trinh Button btnReject = new Button(); btnReject.Content = "Từ Chối"; btnReject.Click += btnReject_Click; gridInfo.Children.Add(btnReject); Grid.SetRow(btnReject, 6); } //driver da accepted else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_DRIVER_ACCEPTED)) { // //create button start hanh trinh Button btnStart = new Button(); btnStart.Content = "Start"; btnStart.Click += btnStart_Click; gridInfo.Children.Add(btnStart); Grid.SetRow(btnStart, 6); } //ongoing else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_ONGOING)) { //create button tracking hanh trinh Button btnTracking = new Button(); btnTracking.Content = "Tracking"; btnTracking.Click += btnTracking_Click; gridInfo.Children.Add(btnTracking); Grid.SetRow(btnTracking, 6); //btn Finish } //hanh trinh da ket thuc else if (GlobalData.selectedItinerary.status.Equals(Global.GlobalData.ITINERARY_STATUS_FINISHED)) { } //draw 2 points on map startPointOverlay = UserControls.MarkerDraw.DrawCurrentMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long)); wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.start_address_lat, GlobalData.selectedItinerary.start_address_long)); mapLayer.Add(startPointOverlay); endPointOverlay = UserControls.MarkerDraw.DrawCurrentMapMarker(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long)); wayPoints.Add(new GeoCoordinate(GlobalData.selectedItinerary.end_address_lat, GlobalData.selectedItinerary.end_address_long)); mapLayer.Add(endPointOverlay); //set zoom and center point mapItineraryDetails.ZoomLevel = 14; mapItineraryDetails.Center = startPointOverlay.GeoCoordinate; mapItineraryDetails.Layers.Add(mapLayer); //draw route routeQuery = new RouteQuery(); //GeocodeQuery Mygeocodequery = null; routeQuery.QueryCompleted += routeQuery_QueryCompleted; routeQuery.TravelMode = TravelMode.Driving; routeQuery.RouteOptimization = RouteOptimization.MinimizeDistance; routeQuery.Waypoints = wayPoints; routeQuery.QueryAsync(); //set text 2 points txtboxStart.Text = GlobalData.selectedItinerary.start_address; txtboxEnd.Text = GlobalData.selectedItinerary.end_address; //set text itinerary info txtbDistance.Text = GlobalData.selectedItinerary.distance.ToString(); txtbDescription.Text = GlobalData.selectedItinerary.description; txtbCost.Text = GlobalData.selectedItinerary.cost; //xu ly ngay thang string datetimeString = GlobalData.selectedItinerary.leave_date.Trim(); DateTime datetime = DateTimes.DatetimeConvert.convertDateTimeFromString(datetimeString); datePicker.Value = datetime; timePicker.Value = datetime; //datePicker.Value = GlobalData.selectedItinerary.da }