InkCanvas橡皮擦 [英] InkCanvas Eraser
本文介绍了InkCanvas橡皮擦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的画板为InkCanvas
;我想更改橡皮擦的大小,所以写了:
I have sketchpad as InkCanvas
; I want to change size of eraser so I've written:
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
尝试一下:
- 通过按e选择橡皮擦,橡皮擦笔尖将显示为矩形
- 按+号增加大小,您将看不到任何更改.为什么?
- 现在按i更改编辑模式,将出现墨水笔尖.
- 再次按e切换到橡皮擦.您将看到橡皮擦形状已更改.
为什么不按+号呢?
推荐答案
来自如果更改EraserShape,则在下一次EditingMode更改之前,不会更新InkCanvas上呈现的光标."
"If you change the EraserShape, the cursor rendered on the InkCanvas is not updated until the next EditingMode change."
我测试了以下代码,它可以正常工作:
I tested the following code and it works fine:
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;
}
这篇关于InkCanvas橡皮擦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文