Пример #1
0
 void DrawRoutedEdge(RoutedEdge routedEdge)
 {
     /*for (int i = 1; i < routedEdge.Points.Count; i++) {
         var point0 = routedEdge.Points[i - 1];
         var point1 = routedEdge.Points[i];
         var line = new Line { Stroke = new SolidColorBrush(Colors.Black),
             X1 = point0.X, Y1 = point0.Y, X2 = point1.X, Y2 = point1.Y };
         canvas.Children.Add(line);
     }*/
     PathFigure edgeSplineFigure = createEdgeSpline(routedEdge);
     PathGeometry geometryVisible = new PathGeometry();
     geometryVisible.Figures.Add(edgeSplineFigure);
     Path pathVisible = new Path();
     pathVisible.Stroke = Brushes.Black;
     pathVisible.Fill = Brushes.Black;
     pathVisible.StrokeThickness = 1;
     pathVisible.Data = geometryVisible;
     canvas.Children.Add(pathVisible);
 }
Пример #2
0
        private PathFigure createEdgeSpline(RoutedEdge edge)
        {
            PathFigure figure = new PathFigure();
            figure.IsClosed = false;
            figure.IsFilled = false;

            figure.StartPoint = edge.SplinePoints[0].ToWindowsPoint();
            for (int i = 1; i < edge.SplinePoints.Count; i += 3)
            {
                figure.Segments.Add(new BezierSegment(
                    edge.SplinePoints[i].ToWindowsPoint(),
                    edge.SplinePoints[i + 1].ToWindowsPoint(),
                    edge.SplinePoints[i + 2].ToWindowsPoint(),
                    true));
            }

            return figure;
        }
Пример #3
0
 public RoutedEdge BuildRoutedEdge(IEnumerable<IPoint> points)
 {
     var routedEdge = new RoutedEdge();
     foreach (var point in points) {
         routedEdge.Points.Add(new Point2D(point.X, point.Y));
     }
     return routedEdge;
 }