private void CreateArrows(Path path, StreamGeometryContext gc)
        {
            double start;

            if (path.PathType == PathType.Convex)
            {
                start = GeometryHelper.GetAngleFromPoint(path.StartPoint, path.Origin);
            }
            else
            {
                start = GeometryHelper.GetAngleFromPoint(path.EndPoint, path.Origin);
            }

            for(int i= 0; i < 10; i++)
            {
                start += 8;
                var org = GeometryHelper.GetPointAtAngle(path.Origin, path.Radius, start);
                var pt1 = GeometryHelper.GetPointAtAngle(path.Origin, path.Radius + 10, start);
                var pt2 = GeometryHelper.GetPointAtAngle(path.Origin, path.Radius - 10, start);
                var pt3 = GeometryHelper.GetPointAtAngle(org, 20, start + 90);

                gc.BeginFigure(pt1, true, true);
                gc.LineTo(pt2, true, true);
                gc.LineTo(pt3, true, true);
                gc.LineTo(pt1, true, true);

                gc.BeginFigure(path.Origin, false, false);
                gc.LineTo(pt1, true, true);

            }
        }
Beispiel #2
0
        public PathStepVisual(Path path)
        {
            var brush = Brushes.Blue;
            var pen = new Pen(brush, 1);

            var stepPlotter = new PathAngleCalculator(path);
            var angles = stepPlotter.Calculate();
            var anglePerUnit = stepPlotter.CalculateAnglePerUnit();
            var upperCurve = path.Radius + (path.Width/4);
            var lowerCurve = path.Radius - (path.Width/4);
            const int unitSize = 15;
            const int unitSizeDivisor = 3;
            var geometry = new StreamGeometry();
            using(var gc = geometry.Open())
            {
                foreach (var angle in angles)
                {
                    var angleMovement = angle - ((anglePerUnit * unitSize)/2);
                    var centrePoint = GeometryHelper.GetPointAtAngle(path.Origin, upperCurve, angle);
                    var lower = GeometryHelper.GetPointAtAngle(path.Origin, upperCurve - unitSize/unitSizeDivisor, angleMovement);
                    var upper = GeometryHelper.GetPointAtAngle(path.Origin, upperCurve + unitSize/unitSizeDivisor, angleMovement);
                    var centre = GeometryHelper.GetPointAtAngle(path.Origin, upperCurve, angleMovement);
                    var point = GeometryHelper.GetPointAtAngle(centre, unitSize, angle + 90);

                    gc.BeginFigure(lower, true, true);
                    gc.LineTo(upper, true, true);
                    gc.LineTo(point, true, true);
                    gc.LineTo(lower, true, true);

                    angleMovement = angle + ((anglePerUnit * unitSize) / 2);
                    centrePoint = GeometryHelper.GetPointAtAngle(path.Origin, lowerCurve, angle);
                    lower = GeometryHelper.GetPointAtAngle(path.Origin, lowerCurve - unitSize / unitSizeDivisor, angleMovement);
                    upper = GeometryHelper.GetPointAtAngle(path.Origin, lowerCurve + unitSize / unitSizeDivisor, angleMovement);
                    centre = GeometryHelper.GetPointAtAngle(path.Origin, lowerCurve, angleMovement);
                    point = GeometryHelper.GetPointAtAngle(centre, unitSize, angle - 90);

                    gc.BeginFigure(lower, true, true);
                    gc.LineTo(upper, true, true);
                    gc.LineTo(point, true, true);
                    gc.LineTo(lower, true, true);
                }
            }

            using (var context = RenderOpen())
            {
                context.DrawGeometry(brush, pen, geometry);
            }
        }
        public PathElementsVisual(Path path)
        {
            var geometry = new StreamGeometry();
            using(var gc = geometry.Open())
            {

                CreateArrows(path, gc);

            }

            using (var context = RenderOpen())
            {
                var linePen = new Pen(Brushes.Red, 1);
                context.DrawLine(linePen, path.StartPoint, path.EndPoint);

                var firstCirclePen = new Pen(Brushes.Green, 1);
                context.DrawEllipse(Brushes.Transparent, firstCirclePen, path.CurveCircles[0], path.Radius, path.Radius);

                var secondCirclePen = new Pen(Brushes.Orange, 1);
                context.DrawEllipse(Brushes.Transparent, secondCirclePen, path.CurveCircles[1], path.Radius, path.Radius);

                context.DrawGeometry(Brushes.Black, new Pen(Brushes.Black, 1), geometry);
            }
        }
Beispiel #4
0
 public Context()
 {
     firstPath = new Path(new Point(50, 200), new Point(450, 200), 220, 100, PathType.Convex);
     //secondPath = new Path(new Point(450, 150), new Point(550, 600), 280, 100, PathDirection.Convex);
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PathOutliner"/> class.
 /// </summary>
 /// <param name="path"></param>
 /// <param name="origin"></param>
 public PathOutliner(Path path, Point origin)
 {
     this.path = path;
     this.origin = origin;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PathAnglePlotter"/> class.
 /// </summary>
 /// <param name="path"></param>
 public PathAngleCalculator(Path path)
 {
     this.path = path;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PathNodePlotter"/> class.
 /// </summary>
 /// <param name="path"></param>
 public PathNodePlotter(Path path)
 {
     this.path = path;
 }