WorkflowDesignerMessageFilter.OnKeyDown(KeyEventArgs) Método

Definição

Ocorre quando uma tecla é pressionada.

protected:
 virtual bool OnKeyDown(System::Windows::Forms::KeyEventArgs ^ eventArgs);
protected virtual bool OnKeyDown (System.Windows.Forms.KeyEventArgs eventArgs);
abstract member OnKeyDown : System.Windows.Forms.KeyEventArgs -> bool
override this.OnKeyDown : System.Windows.Forms.KeyEventArgs -> bool
Protected Overridable Function OnKeyDown (eventArgs As KeyEventArgs) As Boolean

Parâmetros

eventArgs
KeyEventArgs

Um KeyEventArgs que contém informações sobre o evento.

Retornos

true se a mensagem for manipulada, caso contrário, false.

Exemplos

O exemplo de código a seguir mostra como substituir o OnKeyDown método para personalizar como remover atividades de uma superfície de design de fluxo de trabalho.

Este exemplo de código faz parte do Exemplo básico do SDK de hospedagem de Designer do arquivo DesignerShell.cs. Para obter mais informações, consulte Hospedagem básica de Designer.

protected override bool OnKeyDown(KeyEventArgs eventArgs)
{
    if (eventArgs.KeyCode == Keys.Delete)
    {
        ISelectionService selectionService = (ISelectionService)serviceProvider.GetService(typeof(ISelectionService));
        if (selectionService != null && selectionService.PrimarySelection is CodeActivity)
        {
            CodeActivity codeActivityComponent = (CodeActivity)selectionService.PrimarySelection;
            CompositeActivity parentActivity = codeActivityComponent.Parent;
            if (parentActivity != null)
            {
                parentActivity.Activities.Remove(codeActivityComponent);
                this.ParentView.Update();
            }
            loader.RemoveActivityFromDesigner(codeActivityComponent);
        }
    }
    return true;
}
Protected Overrides Function OnKeyDown(ByVal eventArgs As KeyEventArgs) As Boolean
    If eventArgs.KeyCode = Keys.Delete Then
        Dim selectionService As ISelectionService = CType(serviceProvider.GetService(GetType(ISelectionService)), ISelectionService)
        If selectionService IsNot Nothing AndAlso TypeOf selectionService.PrimarySelection Is CodeActivity Then
            Dim codeActivityComponent As CodeActivity = CType(selectionService.PrimarySelection, CodeActivity)
            Dim parentActivity As CompositeActivity = codeActivityComponent.Parent
            If parentActivity IsNot Nothing Then
                parentActivity.Activities.Remove(codeActivityComponent)
                Me.ParentView.Update()
            End If
            loader.RemoveActivityFromDesigner(codeActivityComponent)
        End If
    End If
    Return True
End Function

Comentários

OnKeyDown ocorre quando uma tecla é pressionada quando um objeto específico tem foco.

Aplica-se a

Confira também