I am working on a project in which I have to draw different nodes(junctions) and then show connection between them. Simply, I used ellipse class to draw the nodes with their coordinates as (x, y) on Canvas inside ViewBox
.Then, all i did was read the link's starting and ending coordinate and stored them in a List and by reading the List, I added them to the canvas.
I have the following code to draw the line on canvas
which reads the start point and endpoint:
foreach(LineProperty lnp in lstLnPro){
Line ln = new Line();
ln = ds.drawLine(lnp.x1, lnp.y1, lnp.x2, lnp.y2);
ln.MouseEnter += ln_MouseEnter;
ln.MouseLeave += ln_MouseLeave;
canvasName.Children.Add(ln);
}
And the ds object calls the drawLine function.
public Line drawLine(double x1, double y1, double x2, double y2) {
Line ln = new Line();
ln.X1 = x1;
ln.Y1 = y1;
ln.X2 = x2;
ln.Y2 = y2;
ln.StrokeThickness = 1;
ln.Visibility = System.Windows.Visibility.Visible;
ln.Stroke = System.Windows.Media.Brushes.Green;
return ln;
}
Now, i need these drawn lines to be directed i.e. having arrows in the middle which shows the path from (x1, y1) to (x2, y2) i.e. point from starting point to ending point. Can somebody give me a direction?