InkCanvas Borracha
-
14-11-2019 - |
Pergunta
Eu tenho sketchpad como InkCanvas
;Eu quero mudar tamanho da borracha para que eu escrevi:
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
Tente isso:
- Selecione borracha pressionando e, Borracha stylusTip vai aparece Retangular
- Pressione o sinal " + " para aumentar o tamanho , você não vai ver nenhuma mudança.Por quê?
- Agora você pressione i para alterar o modo de edição, dica de tinta vai aparecer.
- Prima e novamente para reswitch de Borracha.Você vai ver que eraser forma foi alterado.
Por que não depois de pressionar + sinal?
Solução
Do ajuda:
"Se você alterar o EraserShape, o cursor prestados no InkCanvas não é atualizado até que o próximo EditingMode mudar."
Eu testei o código a seguir e ele funciona muito bem:
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;
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow