墨水画布橡皮擦

发布于 2024-10-28 03:27:48 字数 882 浏览 6 评论 0原文

我的画板为 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

试试这个:

  1. 按 e 选择橡皮擦,橡皮擦手写笔提示将出现矩形
  2. 按 + 符号增加大小,您将看不到任何更改。为什么?
  3. 现在按 i 更改编辑模式,会出现墨迹提示。
  4. 再次按 e 重新切换到橡皮擦。您会看到橡皮擦形状已更改。

为什么按+号后不呢?

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

Try this:

  1. Select eraser by pressing e, Eraser stylusTip will appears Rectangular
  2. Press + sign to increase size , you will not see any changes. Why?
  3. Now you press i to change editing mode, ink tip will appears.
  4. Press e again to reswitch to Eraser. You will see that eraser shape has been changed.

Why not after pressing + sign?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初心 2024-11-04 03:27:48

来自 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;
}

From the help:

"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;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文