forked from judero01col/GMap.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGMapRoute.cs
More file actions
82 lines (72 loc) · 2.48 KB
/
Copy pathGMapRoute.cs
File metadata and controls
82 lines (72 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Effects;
using System.Windows.Shapes;
namespace GMap.NET.WindowsPresentation
{
public interface IShapable
{
List<PointLatLng> Points
{
get;
set;
}
Path CreatePath(List<Point> localPath, bool addBlurEffect);
}
public class GMapRoute : GMapMarker, IShapable
{
public List<PointLatLng> Points { get; set; }
public GMapRoute(IEnumerable<PointLatLng> points)
{
Points = new List<PointLatLng>(points);
}
public override void Clear()
{
base.Clear();
Points.Clear();
}
/// <summary>
/// creates path from list of points, for performance set addBlurEffect to false
/// </summary>
/// <returns></returns>
public virtual Path CreatePath(List<Point> localPath, bool addBlurEffect)
{
// Create a StreamGeometry to use to specify myPath.
var geometry = new StreamGeometry();
using (var 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.
var myPath = new Path();
{
// Specify the shape of the Path using the StreamGeometry.
myPath.Data = geometry;
if (addBlurEffect)
{
var ef = new BlurEffect();
{
ef.KernelType = KernelType.Gaussian;
ef.Radius = 3.0;
ef.RenderingBias = RenderingBias.Performance;
}
myPath.Effect = ef;
}
myPath.Stroke = Brushes.Navy;
myPath.StrokeThickness = 5;
myPath.StrokeLineJoin = PenLineJoin.Round;
myPath.StrokeStartLineCap = PenLineCap.Triangle;
myPath.StrokeEndLineCap = PenLineCap.Square;
myPath.Opacity = 0.6;
myPath.IsHitTestVisible = false;
}
return myPath;
}
}
}