This documentation is archived and is not being maintained.

WorkflowDesignerMessageFilter Class

Provides a base class for all workflow message filters.

Namespace:  System.Workflow.ComponentModel.Design
Assembly:  System.Workflow.ComponentModel (in System.Workflow.ComponentModel.dll)

'Declaration
Public MustInherit Class WorkflowDesignerMessageFilter _
	Implements IDisposable
'Usage
Dim instance As WorkflowDesignerMessageFilter

The workflow designer provides a Strategy design pattern to create replaceable message filter objects to handle events.

Derive from the WorkflowDesignerMessageFilter class to create message filters that can respond to workflow designer events, such as drag operations, layout and paint operations, and other designer events. To add a custom message filter to the message filters chain, call the AddDesignerMessageFilter on the WorkflowView or override the MessageFilters virtual property on the custom root activity and add the custom message filter to the collection returned from the base class.

The following code example shows a custom designer message filter that derives from WorkflowDesignerMessageFilter. The class, named CustomMessageFilter, overrides a number of its base class methods including OnMouseDown, OnMouseMove, OnMouseUp, OnMouseDoubleClick, OnMouseEnter, OnMouseHover, OnMouseLeave, OnDragEnter, OnDragOver, and OnKeyDown.

This code example is part of the Basic Designer Hosting SDK Sample from the DesignerShell.cs file. For more information, see Basic Designer Hosting.

    Friend NotInheritable Class CustomMessageFilter
        Inherits WorkflowDesignerMessageFilter

#Region "Members and Constructor" 

        Private mouseDown As Boolean 
        Private serviceProvider As IServiceProvider
        Private workflowView As WorkflowView
        Private loader As WorkflowDesignerLoader

        Public Sub New(ByVal provider As IServiceProvider, ByVal workflowView As WorkflowView, ByVal loader As WorkflowDesignerLoader)
            Me.serviceProvider = provider
            Me.workflowView = workflowView
            Me.loader = loader
        End Sub

#End Region

#Region "WorkflowDesignerMessageFilter Overridables" 

        Protected Overrides Function OnMouseDown(ByVal eventArgs As System.Windows.Forms.MouseEventArgs) As Boolean 
            ' Allow other components to process this event by not returning true.
            mouseDown = True 
            Return False 
        End Function 

        Protected Overrides Function OnMouseMove(ByVal eventArgs As System.Windows.Forms.MouseEventArgs) As Boolean 
            ' Allow other components to process this event by not returning true. 
            If mouseDown Then
                workflowView.ScrollPosition = New Point(eventArgs.X, eventArgs.Y)
            End If 
            Return False 
        End Function 

        Protected Overrides Function OnMouseUp(ByVal eventArgs As MouseEventArgs) As Boolean 
            ' Allow other components to process this event by not returning true.
            mouseDown = False 
            Return False 
        End Function 

        Protected Overrides Function OnMouseDoubleClick(ByVal eventArgs As MouseEventArgs) As Boolean
            mouseDown = False 
            Return True 
        End Function 

        Protected Overrides Function OnMouseEnter(ByVal eventArgs As MouseEventArgs) As Boolean 
            ' Allow other components to process this event by not returning true.
            mouseDown = False 
            Return False 
        End Function 

        Protected Overrides Function OnMouseHover(ByVal eventArgs As MouseEventArgs) As Boolean 
            ' Allow other components to process this event by not returning true.
            mouseDown = False 
            Return False 
        End Function 

        Protected Overrides Function OnMouseLeave() As Boolean 
            ' Allow other components to process this event by not returning true.
            mouseDown = False 
            Return False 
        End Function 

        Protected Overrides Function OnMouseWheel(ByVal eventArgs As MouseEventArgs) As Boolean
            mouseDown = False 
            Return True 
        End Function 

        Protected Overrides Function OnMouseCaptureChanged() As Boolean 
            ' Allow other components to process this event by not returning true.
            mouseDown = False 
            Return False 
        End Function 

        Protected Overrides Function OnDragEnter(ByVal eventArgs As DragEventArgs) As Boolean 
            Return True 
        End Function 

        Protected Overrides Function OnDragOver(ByVal eventArgs As DragEventArgs) As Boolean 
            Return True 
        End Function 

        Protected Overrides Function OnDragLeave() As Boolean 
            Return True 
        End Function 

        Protected Overrides Function OnDragDrop(ByVal eventArgs As DragEventArgs) As Boolean 
            Return True 
        End Function 

        Protected Overrides Function OnGiveFeedback(ByVal gfbevent As GiveFeedbackEventArgs) As Boolean 
            Return True 
        End Function 

        Protected Overrides Function OnQueryContinueDrag(ByVal qcdevent As QueryContinueDragEventArgs) As Boolean 
            Return True 
        End Function 

        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 

        Protected Overrides Function OnKeyUp(ByVal eventArgs As KeyEventArgs) As Boolean 
            Return True 
        End Function 

        Protected Overrides Function OnShowContextMenu(ByVal menuPoint As Point) As Boolean 
            Return True 
        End Function

#End Region

    End Class

System.Object
  System.Workflow.ComponentModel.Design.WorkflowDesignerMessageFilter

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Show: