Page 1 of 1

Drawing a line with direction indication

Posted: Wed Sep 28, 2016 2:20 pm
by KasperD
Dear colleagues,

One of our customers is using the RoutePolyLine animation to show users which way the route is going. As this takes up a huge amount of CPU time (25% of 1 core in a quad-core system), he wishes to disable the animation but still show which way the route is going. using the following code:

var poly = new MapPolyline
{
Points = pc,
MapStrokeThickness = 10,
StrokeLineJoin = PenLineJoin.Round,
StrokeStartLineCap = PenLineCap.Flat,
StrokeEndLineCap = PenLineCap.Triangle,
Stroke = new SolidColorBrush(System.Windows.Media.Color.FromArgb(128, color.R, color.G, color.B)),
ScaleFactor = 0.05,
ToolTip = toolTip
};
var polyArrow = new MapPolyline
{
Points = pc,
MapStrokeThickness = 11,
StrokeLineJoin = PenLineJoin.Round,
StrokeStartLineCap = PenLineCap.Flat,
StrokeEndLineCap = PenLineCap.Triangle,
Stroke = new SolidColorBrush(System.Windows.Media.Color.FromArgb(128, color.R, color.G, color.B)),
StrokeDashCap = PenLineCap.Triangle,
StrokeDashArray = new DoubleCollection { 1, 2 },
// StrokeDashOffset = 2.0,
ScaleFactor = 0.05,
ToolTip = toolTip
};

The customer is able to produce a line as shown in the attachment arrow1. however, he would like to have a line as depicted in attachment arrow2. is this possible, code-wise?

Re: Drawing a line with direction indication

Posted: Fri Sep 30, 2016 12:25 pm
by Marco
Dear Kasper,

out of the box, there is no way to customize the dashes along the routing polyline. In WPF, there exists only four different constants for PenLineCap (flat, round, triangle, square). All of them are symmetric, i.e. it's not possible to show a direction.

To resolve that problem, the customer has to draw the lines manually himself. See here: http://stackoverflow.com/questions/5188 ... e-in-c-wpf

I'm very sorry, but this problem is more complicated and goes beyond our intention of the code samples: We want to show how to use the PTV xServer for implementing desktop applications and avoided complex GUI elements generally.

Re: Drawing a line with direction indication

Posted: Fri Sep 30, 2016 1:22 pm
by KasperD
Marco,

Thanks, no problem. Forwarded the information to the customer and he'll find a way to make what he needs.