private void DrawRoute(DateTime newstart, DateTime newend) { bool bRouteValid = false; if (newstart < newend) { // Effacement EmptyAssociatedDecorations(); // Ok, on met à jour List <PointLatLng> newpts = new List <PointLatLng>(); for (int i = 0; i < _Times.Count; i++) { PointLatLng pt = _Pts[i]; DateTime ptdate = _Times[i]; if ((ptdate >= newstart) && (ptdate <= newend)) { newpts.Add(pt); } } if (newpts.Count >= 2) { bRouteValid = true; // On ajoute un marker début et fin _Daddy._cacheDetail._gmap.Overlays[GMapWrapper.RESERVED4].Markers.Add(CreateMarker(newpts[0], GMarkerGoogleType.green, _Daddy.GetTranslator().GetString("LblStart"))); _Daddy._cacheDetail._gmap.Overlays[GMapWrapper.RESERVED4].Markers.Add(CreateMarker(newpts[newpts.Count - 1], GMarkerGoogleType.orange, _Daddy.GetTranslator().GetString("LblEnd"))); // On ajoute un marker mobile au début du parcours // Uniquement si le graphe est affiché if ((_Elevations != null) || _ComputeSpeed) { _Daddy._cacheDetail._gmap.Overlays[GMapWrapper.RESERVED4].Markers.Add(CreateMarker(newpts[0], GMarkerGoogleType.blue, _Daddy.GetTranslator().GetString("LblCurrent"))); } // And draw elevations DrawElevationsSpeed(0); GMapRoute route = null; if (_ComputeSpeed) { // La route en ligne droite // Colors list based on speed Color[] colors = new Color[newpts.Count]; float[] fwidth = new float[newpts.Count]; int i = 0; foreach (Double d in _SpeedsRoute) { fwidth[i] = 2.0f; // Color is based on speed double percentage = (_SpeedsRoute[i] - _Min_speed) / (_Max_speed - _Min_speed); // Min = green // Max = red if (_speedColorType == ColorType.GreenRed) { int ired = (int)(255.0 * (percentage)); int igreen = (int)(255.0 * (1.0 - percentage)); ired = Math.Max(0, ired); ired = Math.Min(255, ired); igreen = Math.Max(0, igreen); igreen = Math.Min(255, igreen); Color c = Color.FromArgb(ired, igreen, 0); colors[i] = c; } else if (_speedColorType == ColorType.HSL) { ColorRGB c = ColorRGB.HSL2RGB(percentage, 0.5, 0.5); colors[i] = Color.FromArgb(c.R, c.G, c.B); } else { colors[i] = _singlecolor; } i++; } route = new GMapRouteGradient(newpts, "Route", colors, fwidth); } else { route = new GMapRoute(newpts, "Route"); } _PtsRoute = newpts; route.IsHitTestVisible = true; route.Tag = _Daddy._cacheDetail._gmap; // très important pour le tooltip Pen pen = new Pen(_singlecolor); pen.Width = 2; // route.Stroke.Width; route.Stroke = pen; // On change le nom de cette route pour le tooltip String kmmi = (_Daddy._bUseKm) ? _Daddy.GetTranslator().GetString("LVKm") : _Daddy.GetTranslator().GetString("LVMi"); double dist = (_Daddy._bUseKm) ? route.Distance : route.Distance * _Daddy._dConvKmToMi; String tooltiptext = dist.ToString("0.0") + " " + kmmi; route.Name = tooltiptext; _Daddy._cacheDetail._gmap.Overlays[GMapWrapper.RESERVED4].Routes.Add(route); } } else { // On efface de toute façon EmptyAssociatedDecorations(); } if (!_ComputeSpeed) { lblSpeedMoy.Visible = false; } else { // On calcule la vitesse moyenne _Daddy.Log("TrackSelector DrawBasedOnParameters: Compute mean speed"); lblSpeedMoy.Visible = true; lblSpeedMoy.Text = _Daddy.GetTranslator().GetString("LblMeanSpeed"); if (bRouteValid) { GMapRoute route = _Daddy._cacheDetail._gmap.Overlays[GMapWrapper.RESERVED4].Routes[0]; String kmmph = (_Daddy._bUseKm) ? "kmh" : "mph"; double dist = (_Daddy._bUseKm) ? route.Distance : route.Distance * _Daddy._dConvKmToMi; if ((_TimesRoute != null) && (_TimesRoute.Count >= 2)) { double deltah = (_TimesRoute[_TimesRoute.Count - 1] - _TimesRoute[0]).TotalHours; double speed = dist / deltah; lblSpeedMoy.Text += speed.ToString("0.0 ") + kmmph; } else { lblSpeedMoy.Text += "-"; } } else { DrawElevationsSpeed(0); lblSpeedMoy.Text += "-"; } } }