/// <summary> /// regenerates shape of route /// </summary> public virtual void RegenerateShape(GMapControl map) { if (map != null) { Map = map; if (Points.Count > 1) { Position = Points[0]; var localPath = new List<System.Windows.Point>(); var offset = Map.FromLatLngToLocal(Points[0]); foreach (var i in Points) { var p = Map.FromLatLngToLocal(new PointLatLng(i.Lat, i.Lng)); localPath.Add(new System.Windows.Point(p.X - offset.X, p.Y - offset.Y)); } var shape = map.CreateRoutePath(localPath); if (this.Shape != null && this.Shape is Path) { (this.Shape as Path).Data = shape.Data; } else { this.Shape = shape; } } else { this.Shape = null; } } }
public override void RegenerateShape(GMapControl map) { if (map != null) { if (Points.Count > 1) { var localPath = new List<Point>(); var offset = map.FromLatLngToLocal(Points[0]); foreach (PointLatLng i in Points) { var p = map.FromLatLngToLocal(new PointLatLng(i.Lat, i.Lng)); localPath.Add(new Point(p.X - offset.X, p.Y - offset.Y)); } // Create a StreamGeometry to use to specify myPath. var geometry = new StreamGeometry(); using (StreamGeometryContext ctx = geometry.Open()) { ctx.BeginFigure(localPath[0], false, false); // Draw a line to the next specified point. ctx.PolyLineTo(localPath, true, true); } // Freeze the geometry (make it unmodifiable) // for additional performance benefits. geometry.Freeze(); // Create a path to draw a geometry with. Shape = new Path { Data = geometry, Stroke = Brushes.Gray, StrokeThickness = 3, Opacity = 0.5, IsHitTestVisible = true }; } else { Shape = null; } } }
public override void RegenerateShape(GMapControl map) { if (map != null) { if (Points.Count > 1) { var localPath = new List<Point>(); var offset = map.FromLatLngToLocal(Points[0]); foreach (PointLatLng i in Points) { var p = map.FromLatLngToLocal(new PointLatLng(i.Lat, i.Lng)); localPath.Add(new Point(p.X - offset.X, p.Y - offset.Y)); } // Create a StreamGeometry to use to specify myPath. var geometry = new StreamGeometry(); using (StreamGeometryContext ctx = geometry.Open()) { ctx.BeginFigure(localPath[0], true, true); // Draw a line to the next specified point. ctx.PolyLineTo(localPath, true, true); } // Freeze the geometry (make it unmodifiable) // for additional performance benefits. geometry.Freeze(); var fillBrush = new SolidColorBrush(); BindingOperations.SetBinding(fillBrush, SolidColorBrush.ColorProperty, new Binding("Variety.ClusterIndex") {Converter = new IndexToColorConverter(), ConverterParameter = Colors.CornflowerBlue}); var strokeBrush = new SolidColorBrush(); BindingOperations.SetBinding(strokeBrush, SolidColorBrush.ColorProperty, new Binding("Color") {Source = fillBrush, Converter = new ColorBrightnessConverter(), ConverterParameter = -0.15}); // Create a path to draw a geometry with. var path = new Path { Data = geometry, Effect = new BlurEffect {KernelType = KernelType.Gaussian, Radius = 3.0, RenderingBias = RenderingBias.Quality}, Stroke = strokeBrush, Fill = fillBrush, StrokeThickness = 3, Opacity = 0.5, IsHitTestVisible = true, DataContext = _region, Visibility = Shape == null ? Visibility.Visible : Shape.Visibility }; Shape = path; Shape.MouseEnter += Shape_MouseEnter; Shape.MouseLeave += Region_MouseLeave; } else { Shape = null; } } }