WorkflowDesignerMessageFilter.OnKeyDown(KeyEventArgs) Método

Definición

Se produce cuando se presiona una tecla.

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

Un KeyEventArgs que contiene información sobre el evento.

Devoluciones

Es true si se ha administrado el mensaje; en caso contrario, es false.

Ejemplos

En el ejemplo de código siguiente se muestra cómo invalidar el método OnKeyDown para personalizar la eliminación de actividades de una superficie de diseño de flujo de trabajo.

Este ejemplo de código forma parte del ejemplo de SDK de hospedaje de diseñador básico del archivo DesignerShell.cs. Para obtener más información, consulte Hospedaje básico 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

Comentarios

OnKeyDown se produce cuando se presiona una tecla mientras un objeto específico tiene el foco.

Se aplica a

Consulte también