in ExampleGallery/SvgExample.xaml.cs [150:213]
private void canvasControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
{
if (!svgSupported)
{
args.DrawingSession.Clear(Colors.Black);
DrawNotSupportedMessage(args.DrawingSession, sender.Size);
return;
}
if (svgDocument == null)
{
canvasControl.Invalidate();
return;
}
Size viewportSize = new Size() { Width = 1000, Height = 1000 };
if (CurrentEffectType == EffectType.None)
{
args.DrawingSession.DrawSvg(svgDocument, viewportSize);
}
else if (CurrentEffectType == EffectType.EdgeDetection)
{
CanvasCommandList commandList = new CanvasCommandList(sender);
using (var ds = commandList.CreateDrawingSession())
{
ds.DrawSvg(svgDocument, viewportSize);
}
var edgeDetection = new EdgeDetectionEffect
{
Source = commandList,
Amount = 1,
BlurAmount = 1
};
args.DrawingSession.DrawImage(edgeDetection);
}
if (pointerDrag != null)
{
if (CurrentShapeType == ShapeType.Rectangle)
{
// Show ghost
args.DrawingSession.DrawRectangle(pointerDrag.GetRectangle(), Colors.Magenta);
}
else if (CurrentShapeType == ShapeType.Ellipse)
{
var ellipse = pointerDrag.GetEllipse();
args.DrawingSession.DrawEllipse(ellipse.CenterX, ellipse.CenterY, ellipse.RadiusX, ellipse.RadiusY, Colors.Magenta);
}
else if (CurrentShapeType == ShapeType.Circle)
{
var circle = pointerDrag.GetCircle();
args.DrawingSession.DrawCircle(circle.Center, circle.Radius, Colors.Magenta);
args.DrawingSession.DrawLine(circle.Center, pointerDrag.CurrentLocation.ToVector2(), Colors.Magenta);
}
else if (CurrentShapeType == ShapeType.Line)
{
args.DrawingSession.DrawLine(pointerDrag.StartLocation.ToVector2(), pointerDrag.CurrentLocation.ToVector2(), Colors.Magenta);
}
}
}