如何在Windows phone 8.1 silverlight中擦除画布上的部分笔划

如何在Windows phone 8.1 silverlight中擦除画布上的部分笔划,silverlight,canvas,windows-phone-8.1,Silverlight,Canvas,Windows Phone 8.1,我正在使用InkPresenter使用画布在图像上绘制笔划。它工作得很好。现在,我可以通过触摸笔划的任何点来擦除我想要的任何笔划。但我需要抹掉一部分笔划。我看到一些商店wp应用程序可以做到这一点。这是怎么可能的。这是我的密码 Stroke NewStroke; double strokeSize = 4; Color drawingColor = Colors.White; private enum EditState { Draw, Erase, Effect }; private void

我正在使用InkPresenter使用画布在图像上绘制笔划。它工作得很好。现在,我可以通过触摸笔划的任何点来擦除我想要的任何笔划。但我需要抹掉一部分笔划。我看到一些商店wp应用程序可以做到这一点。这是怎么可能的。这是我的密码

Stroke NewStroke;
double strokeSize = 4;
Color drawingColor = Colors.White;
private enum EditState { Draw, Erase, Effect };
private void StartDrawing_MouseEnter(object sender, MouseEventArgs e) {
    try
    {
       if (crtState == EditState.Draw) {
          MyIP.CaptureMouse();
          StylusPointCollection MyStylusPointCollection = new StylusPointCollection();
          MyStylusPointCollection.Add(e.StylusDevice.GetStylusPoints(MyIP));
          NewStroke = new Stroke(MyStylusPointCollection);
          NewStroke.DrawingAttributes.Color = drawingColor;
          NewStroke.DrawingAttributes.Height = strokeSize;
          NewStroke.DrawingAttributes.Width = strokeSize;
          MyIP.Strokes.Add(NewStroke);
          StylusPointCollection ErasePointCollection = new StylusPointCollection();                    
        }
        else if(crtState == EditState.Erase) {
           MyIP.CaptureMouse();
           StylusPointCollection pointErasePoints = e.StylusDevice.GetStylusPoints(MyIP);
           StrokeCollection hitStrokes = MyIP.Strokes.HitTest(pointErasePoints);
           if (hitStrokes.Count > 0)
               foreach (Stroke hitStroke in hitStrokes)
                  MyIP.Strokes.Remove(hitStroke);
          }
        }
        catch (Exception) { }    
    }

    private void MyIP_MouseMove(object sender, MouseEventArgs e)
    {
        if (crtState == EditState.Erase) {
            StylusPointCollection pointErasePoints = e.StylusDevice.GetStylusPoints(MyIP);
            StrokeCollection hitStrokes = MyIP.Strokes.HitTest(pointErasePoints);    
            if (hitStrokes.Count > 0)
                foreach (Stroke hitStroke in hitStrokes)
                    MyIP.Strokes.Remove(hitStroke); 
        }

        if (crtState==EditState.Draw && NewStroke != null)             
           NewStroke.StylusPoints.Add(e.StylusDevice.GetStylusPoints(MyIP));
    }

    private void MyIP_MouseLeave(object sender, MouseEventArgs e)
    {
        NewStroke = null;
    }  

你不能用画布背景色的笔划来擦除吗?@asitis我在画布上使用透明色,因为有一个图像我想在上面画笔划。