我的草图为InkCanvas
;我想改变橡皮擦的大小,所以我写了:
Private Sub Sketchpad_KeyDown(sender As System.Object, e As System.Windows.Input.KeyEventArgs) Handles Sketchpad.KeyDown
If e.Key = Key.OemMinus Then
' Decrease size of Eraser to 5*5
Sketchpad.EraserShape = New RectangleStylusShape(5, 5)
End If
If e.Key = Key.OemPlus Then
' Increase size of Eraser to 50*50
Sketchpad.EraserShape = New RectangleStylusShape(50, 50)
End If
If e.Key = Key.I Then
' Change editing mode to Ink
Sketchpad.EditingMode = InkCanvasEditingMode.Ink
End If
If e.Key = Key.E Then
' Change editing mode to Eraser
Sketchpad.EditingMode = InkCanvasEditingMode.EraseByPoint
End If
End Sub
试试这个:
为什么不按+号后?
答案 0 :(得分:2)
来自help:
“如果更改EraserShape,则在下一个EditingMode更改之前,InkCanvas上呈现的光标不会更新。”
我测试了以下代码并且工作正常:
if (e.Key == Key.OemMinus)
{
ink.EraserShape = new RectangleStylusShape(5, 5);
var editMode = ink.EditingMode;
ink.EditingMode = InkCanvasEditingMode.None;
ink.EditingMode = editMode;
}
if (e.Key == Key.OemPlus)
{
ink.EraserShape = new RectangleStylusShape(50, 50);
var editMode = ink.EditingMode;
ink.EditingMode = InkCanvasEditingMode.None;
ink.EditingMode = editMode;
}