private void OnRoadMapReceived(object o, PlanMyWay.Lib.Manager.EventArgs.RoadMapReceivedEventArgs e) { try { if (e.Error) { MessageBox.Show(e.MessageError); indicator.IsIndeterminate = false; indicator.IsVisible = false; btn_refresh.IsEnabled = true; btn_setting.IsEnabled = true; btn_export.IsEnabled = true; traitementEnd = true; this.NavigationService.GoBack(); return; } myRoadM = e.RoadMap; map_Rdv.SetView(e.RoadMap.RouteResult.Summary.BoundingRectangle); var strokeThickness = e.RoadMap.Trips.Count * 2 + 1; int endRdv = 0; foreach (var portion in e.RoadMap.Trips) { endRdv++; //Random rand = new Random(); //byte r = (byte)rand.Next(0, 255); //byte g = (byte)rand.Next(0, 255); //byte b = (byte)rand.Next(0, 255); MapPolyline polyline = new MapPolyline(); polyline.StrokeThickness = strokeThickness; polyline.Opacity = 1; polyline.Locations = new LocationCollection(); foreach (var point in portion.RoutePath) polyline.Locations.Add(point); polyline.Stroke = PivotRoadTrip.blue; if (portion.IsTripFail) { polyline.StrokeThickness += 2; polyline.Stroke = PivotRoadTrip.red; } else if (endRdv == e.RoadMap.ValidMeetings.Count - 1) { polyline.Stroke = PivotRoadTrip.black; } strokeThickness -= 2; map_Rdv.Children.Add(polyline); } //Création des points sur la carte correspondant au rendez-vous int counRdv = 0; foreach (var rdv in e.RoadMap.Meetings) { if (rdv.IsLocationFail) continue; Pushpin p = new Pushpin(); if (counRdv == 0 && rdv.GetType() == typeof(ReferenceMeeting)) { p.Content = "Départ"; } else if (rdv.GetType() == typeof(ReferenceMeeting)) { p.Content = "Arrivée"; } else { p.Content = "RDV" + (counRdv) + " : " + rdv.Subject; } p.Background = new SolidColorBrush(Colors.Black); p.Location = rdv.Location; map_Rdv.Children.Add(p); counRdv++; } if (e.RoadMap != null) { m = e.RoadMap.ValidMeetings; meetingLocationFail = e.RoadMap.LocationFailMeetings; tripTimeFail = e.RoadMap.FailTrips; myRoadM = e.RoadMap; } myRMM.RoadMapReceived = null; InitGrid(); InitAnomlie(); btn_refresh.IsEnabled = true; btn_setting.IsEnabled = true; btn_export.IsEnabled = true; traitementEnd = true; } catch(Exception exception) { MessageBox.Show("Erreur de recepetion de la map bing, Réesseyer"); Console.WriteLine(exception.Message.ToString()); traitementEnd = true; } }
private void OnRoadMapReceived(object o, PlanMyWay.Lib.Manager.EventArgs.RoadMapReceivedEventArgs e) { int counRdv = -1; int endRdv = 0; try { if (e.Error) { Debug.WriteLine("Aucun rendez-vous n'existe pour le jour sélectionné"); MessageBox.Show("Aucun rendez-vous n'existe pour le jour sélectionné ou bien Vérifier les lieux de départ et d'arrivée dans l'application"); indicator.IsIndeterminate = false; indicator.IsVisible = false; btn_refresh.IsEnabled = true; btn_setting.IsEnabled = true; traitementEnd = true; return; } myRoadM = e.RoadMap; map_Rdv.SetView(e.RoadMap.RouteResult.Summary.BoundingRectangle); var strokeThickness = e.RoadMap.Trips.Count * 2 + 1; foreach (var portion in e.RoadMap.Trips) { endRdv++; Random rand = new Random(); byte r = (byte)rand.Next(0, 255); byte g = (byte)rand.Next(0, 255); byte b = (byte)rand.Next(0, 255); MapPolyline polyline = new MapPolyline(); polyline.StrokeThickness = strokeThickness; polyline.Opacity = 1; polyline.Locations = new LocationCollection(); foreach (var point in portion.RoutePath) polyline.Locations.Add(point); map_Rdv.Children.Add(polyline); polyline.Stroke = new SolidColorBrush(Color.FromArgb(255, 27, 161, 226)); if (portion.IsTripFail) { polyline.StrokeThickness += 2; polyline.Stroke = new SolidColorBrush(Colors.Red); } if (endRdv == e.RoadMap.Trips.Count) polyline.Stroke = new SolidColorBrush(Colors.Black); strokeThickness -= 2; } foreach (var rdv in e.RoadMap.Meetings) { if (rdv.IsLocationFail) continue; Pushpin p = new Pushpin(); if (counRdv == 1 && rdv.GetType() == typeof(ReferenceMeeting)) { p.Content = "Départ"; } else { counRdv++; p.Content = "RDV" + (counRdv) + " : " + rdv.Subject; } if (counRdv != 1 && rdv.GetType() == typeof(ReferenceMeeting)) { p.Content = "Arrivée"; } p.Background = new SolidColorBrush(Colors.Black); p.Location = rdv.Location; map_Rdv.Children.Add(p); } if (e.RoadMap != null) { m = e.RoadMap.ValidMeetings; meetingLocationFail = e.RoadMap.LocationFailMeetings; tripTimeFail = e.RoadMap.FailTrips; myRoadM = e.RoadMap; } InitGrid(); InitAnomlie(); btn_refresh.IsEnabled = true; btn_setting.IsEnabled = true; traitementEnd = true; } catch(Exception exception) { MessageBox.Show("Erreur de recepetion de la map bing, Réesseyer"); Console.WriteLine(exception.Message.ToString()); traitementEnd = true; } }