在wpf上的墨迹上的橡皮擦

时间:2017-12-12 04:24:16

标签: c# wpf

private void inkcanvas_StrokeErased(object sender, RoutedEventArgs e)
{
    var erasedstrokes = (sender as InkCanvas).Strokes;
    aftererasedstrokecollection = erasedstrokes;
    foreach (var item in aftererasedstrokecollection)
    {
        removedstrokes.Add(item);
    }
}
private void inkcanvas_StrokeErasing(object sender InkCanvasStrokeErasingEventArgs e)
{
    var beforeerased = (sender as InkCanvas).Strokes;
    beforeerasedstrokecollection = beforeerased;
    foreach (var item in beforeerasedstrokecollection)
    {
        unremovedstrokes.Add(item);
    }
}

private void btnUndo_Click(object sender, RoutedEventArgs e)
{
    if (DrawingTool == "Eraser" || DrawingTool == "Delete")
    {
        int length = removedstrokes.Count;
        for (int i = 0; i < length; i++)
        {
            estroke = removedstrokes[i];
            inkcanvas.Strokes.Remove(estroke);
        }

        for (int i = 0; i < unremovedstrokes.Count; i++)
        {
            estroke = unremovedstrokes[i];
            inkcanvas.Strokes.Add(estroke);
        }
    }
    else
    {
        if (inkcanvas.Strokes.Count > 0)
        {
            int i = inkcanvas.Strokes.Count;
            inkcanvas.Strokes.RemoveAt(i - 1);
        }
    }
    removedstrokes.Clear();
    DrawingTool = "UnDo";
    HighlightSelectedButton(sender);
    IsDrawing = false;
    inkcanvas.EditingMode = InkCanvasEditingMode.None;
}

我想在WPF中撤消点击时再次绘制已删除的笔划。通过上面的代码我这样做单笔,但我想做多笔画。 请提出任何想法。

我是如何通过墨迹扫描的擦除点法获得擦除点

0 个答案:

没有答案