So I have an InkCanvas to which I have added "custom strokes".
I am at a complete loss as to how to erase custom strokes added to the InkCanvas through its DrawingContext. (Google has been of no help:( ) Making the assumption that I have a bounding rectangle for the area on the InkCanvas I want to erase, how can this be done?
(I am quickly coming to the conclusion that once something is drawn on the DrawingContext it can not be removed -- only convered :( ).
The Custom Strokes are created in the standard way by overriding the DrawCore method of the Stroke, e.g.,
// Draw Rectangle
public class RectangleStroke : Stroke
{
// Constructor
public RectangleStroke(StylusPointCollection pts)
: base(pts)
{
StylusPoints = pts;
}
protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes)
{
if (drawingContext == null)
{
throw new ArgumentNullException("drawingContext");
}
if (null == drawingAttributes)
{
throw new ArgumentNullException("drawingAttributes");
}
DrawingAttributes originalDa = drawingAttributes.Clone();
SolidColorBrush brush = new SolidColorBrush(drawingAttributes.Color);
brush.Freeze();
Pen pen = new Pen(brush, 1);
StylusPoint stp = StylusPoints[0];
StylusPoint sp = StylusPoints[1];
drawingContext.DrawRectangle(brush, pen, new Rect(new Point(sp.X, sp.Y), new Point(stp.X, stp.Y)));
}
}
Similar methods results in a picture like:
How are custom strokes erased knowing only the bounding rectangle?
Thanks for any help or suggestions.