예제 #1
0
        public async Task DrawBezierCurve(CancellationToken cancellationToken)
        {
            using (_splineBasePoints.Frost())
            {
                var bezierDrawer = _bezierDrawer = new BezierDrawer(_splineBasePoints);
                while (!cancellationToken.IsCancellationRequested && bezierDrawer.MoveToNextPoint())
                {
                    InvalidateVisual();
                    try { await Task.Delay(5, cancellationToken); }
                    catch (TaskCanceledException) { }
                }
            }

            InvalidateVisual();
        }
예제 #2
0
        private void RenderBezierLine(DrawingContext drawingContext, BezierDrawer bezierDrawer)
        {
            if (bezierDrawer == null)
            {
                return;
            }

            if (DrawingInProgress)
            {
                bezierDrawer.DrawIntermediateLines(drawingContext);
            }

            var primaryLine = bezierDrawer.PrimaryLinePoints;

            for (var i = 1; i < primaryLine.Count; i++)
            {
                drawingContext.DrawLine(PrimaryLinePen, primaryLine[i - 1], primaryLine[i]);
            }

            if (!bezierDrawer.Finished)
            {
                drawingContext.DrawEllipse(Brushes.Green, null, primaryLine.Last(), EllipseRadius, EllipseRadius);
            }
        }