Share via


WorkflowDesignerMessageFilter.OnKeyDown(KeyEventArgs) Méthode

Définition

Se produit lors de la pression sur une touche.

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

Paramètres

eventArgs
KeyEventArgs

KeyEventArgs qui contient des informations sur l'événement.

Retours

true si le message est géré ; sinon false.

Exemples

L'exemple de code suivant montre comment remplacer la méthode OnKeyDown pour personnaliser la suppression des activités d'une aire de conception de workflow.

Cet exemple de code fait partie de l'exemple du Kit de développement logiciel (SDK) DesignerHosting du fichier DesignerShell.cs. Pour plus d’informations, consultez Hébergement Designer de base.

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

Remarques

OnKeyDown se produit lorsqu'une touche est enfoncée alors qu'un objet spécifique a le focus.

S’applique à

Voir aussi