WorkflowDesignerMessageFilter 類別

定義

警告

此 API 現已淘汰。

對所有工作流程訊息篩選條件提供基底類別。Provides a base class for all workflow message filters.

public ref class WorkflowDesignerMessageFilter abstract : IDisposable
[System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
public abstract class WorkflowDesignerMessageFilter : IDisposable
type WorkflowDesignerMessageFilter = class
    interface IDisposable
Public MustInherit Class WorkflowDesignerMessageFilter
Implements IDisposable
繼承
WorkflowDesignerMessageFilter
屬性
實作

範例

下列程式碼範例示範衍生自 WorkflowDesignerMessageFilter 的自訂設計工具訊息篩選條件。The following code example shows a custom designer message filter that derives from WorkflowDesignerMessageFilter. 名稱為 CustomMessageFilter 的類別會覆寫一些基底類別方法,包括 OnMouseDownOnMouseMoveOnMouseUpOnMouseDoubleClickOnMouseEnterOnMouseHoverOnMouseLeaveOnDragEnterOnDragOverOnKeyDownThe class, named CustomMessageFilter, overrides a number of its base class methods including OnMouseDown, OnMouseMove, OnMouseUp, OnMouseDoubleClick, OnMouseEnter, OnMouseHover, OnMouseLeave, OnDragEnter, OnDragOver, and OnKeyDown.

這個程式碼範例是 DesignerShell.cs 檔案中<Basic Designer Hosting SDK>範例的一部分。This code example is part of the Basic Designer Hosting SDK Sample from the DesignerShell.cs file. 如需詳細資訊, 請參閱基本設計工具裝載For more information, see Basic Designer Hosting.

internal sealed class CustomMessageFilter : WorkflowDesignerMessageFilter
{
    #region Members and Constructor

    private bool mouseDown;
    private IServiceProvider serviceProvider;
    private WorkflowView workflowView;
    private WorkflowDesignerLoader loader;

    public CustomMessageFilter(IServiceProvider provider, WorkflowView workflowView, WorkflowDesignerLoader loader)
    {
        this.serviceProvider = provider;
        this.workflowView = workflowView;
        this.loader = loader;
    }

    #endregion

    #region MessageFilter Overridables

    protected override bool OnMouseDown(MouseEventArgs eventArgs)
    {
        //Allow other components to process this event by not returning true.
        this.mouseDown = true;
        return false;
    }

    protected override bool OnMouseMove(MouseEventArgs eventArgs)
    {
        //Allow other components to process this event by not returning true.
        if (mouseDown)
        {
            workflowView.ScrollPosition = new Point(eventArgs.X, eventArgs.Y);
        }
        return false;
    }

    protected override bool OnMouseUp(MouseEventArgs eventArgs)
    {
        //Allow other components to process this event by not returning true.
        mouseDown = false;
        return false;
    }

    protected override bool OnMouseDoubleClick(MouseEventArgs eventArgs)
    {
        mouseDown = false;
        return true;
    }

    protected override bool OnMouseEnter(MouseEventArgs eventArgs)
    {
        //Allow other components to process this event by not returning true.
        mouseDown = false;
        return false;
    }

    protected override bool OnMouseHover(MouseEventArgs eventArgs)
    {
        //Allow other components to process this event by not returning true.
        mouseDown = false;
        return false;
    }

    protected override bool OnMouseLeave()
    {
        //Allow other components to process this event by not returning true.
        mouseDown = false;
        return false;
    }

    protected override bool OnMouseWheel(MouseEventArgs eventArgs)
    {
        mouseDown = false;
        return true;
    }

    protected override bool OnMouseCaptureChanged()
    {
        //Allow other components to process this event by not returning true.
        mouseDown = false;
        return false;
    }

    protected override bool OnDragEnter(DragEventArgs eventArgs)
    {
        return true;
    }

    protected override bool OnDragOver(DragEventArgs eventArgs)
    {
        return true;
    }

    protected override bool OnDragLeave()
    {
        return true;
    }

    protected override bool OnDragDrop(DragEventArgs eventArgs)
    {
        return true;
    }

    protected override bool OnGiveFeedback(GiveFeedbackEventArgs gfbevent)
    {
        return true;
    }

    protected override bool OnQueryContinueDrag(QueryContinueDragEventArgs qcdevent)
    {
        return true;
    }

    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 override bool OnKeyUp(KeyEventArgs eventArgs)
    {
        return true;
    }

    protected override bool OnShowContextMenu(Point menuPoint)
    {
        return true;
    }

    #endregion
}
    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

備註

注意

此資料討論已被汰換的類型及命名空間。This material discusses types and namespaces that are obsolete. 如需詳細資訊,請參閱 Windows Workflow Foundation 4.5 中即將淘汰的類型For more information, see Deprecated Types in Windows Workflow Foundation 4.5.

工作流程設計工具會提供 Strategy 設計模式,以建立可取代的訊息篩選物件來處理事件。The workflow designer provides a Strategy design pattern to create replaceable message filter objects to handle events.

衍生自 WorkflowDesignerMessageFilter 類別,可建立會回應至工作流程設計工具事件 (例如拖曳作業、配置和繪製作業以及其他設計工具事件) 的訊息篩選條件。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. 若要將自訂訊息篩選條件新增至訊息篩選條件鏈結,請呼叫 AddDesignerMessageFilter 上的 WorkflowView,或覆寫自訂根活動上的 MessageFilters 虛擬屬性,並將自訂訊息篩選條件新增至從基底類別傳回的集合。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.

建構函式

WorkflowDesignerMessageFilter()

在衍生類別中實作時,初始化 WorkflowDesignerMessageFilter 的執行個體。When implemented in a derived class, initializes an instance of a WorkflowDesignerMessageFilter.

屬性

MessageHitTestContext

取得 HitTestInfo,而這會描述 WorkflowDesignerMessageFilter 的內容。Gets the HitTestInfo that describes the context of the WorkflowDesignerMessageFilter.

ParentView

取得與 WorkflowView 關聯的 WorkflowDesignerMessageFilterGets the WorkflowView that is associated with the WorkflowDesignerMessageFilter.

方法

Dispose()

釋放 WorkflowDesignerMessageFilter 使用的資源。Releases the resources used by the WorkflowDesignerMessageFilter.

Dispose(Boolean)

釋放 WorkflowDesignerMessageFilter 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the WorkflowDesignerMessageFilter and optionally releases the managed resources.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
Finalize()

藉由在記憶體回收收回物件前呼叫 Dispose(false) 的方法,嘗試釋放資源。Attempts to free resources by calling Dispose(false) before the object is reclaimed by garbage collection.

GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
Initialize(WorkflowView)

使用關聯的 WorkflowDesignerMessageFilter 初始化 WorkflowViewInitializes the WorkflowDesignerMessageFilter with the associated WorkflowView.

MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
OnDragDrop(DragEventArgs)

發生於使用者在拖曳作業期間於物件上放開滑鼠按鈕時。Occurs when the mouse button is released above an object during a drag operation.

OnDragEnter(DragEventArgs)

發生於使用者在拖曳作業期間,滑鼠指標進入物件範圍時。Occurs when the mouse pointer enters the bounds of an object during a drag operation.

OnDragLeave()

發生於使用者在拖曳作業期間,滑鼠指標離開物件範圍時。Occurs when the mouse pointer leaves the bounds of an object during a drag operation.

OnDragOver(DragEventArgs)

發生於使用者在拖曳作業期間,滑鼠指標在物件範圍內移動時。Occurs when the mouse pointer moves within the bounds of an object during a drag operation.

OnGiveFeedback(GiveFeedbackEventArgs)

發生於拖曳作業時。Occurs during a drag operation.

OnKeyDown(KeyEventArgs)

發生於按下按鍵時。Occurs when a key is pressed.

OnKeyUp(KeyEventArgs)

發生於放開按鍵時。Occurs when a key is released.

OnLayout(LayoutEventArgs)

發生於應該可以重新定位子物件時。Occurs when child objects should be repositioned.

OnMouseCaptureChanged()

發生於透過滑鼠拖曳所選擇的項目變更時。Occurs when the items selected by dragging the mouse changes.

OnMouseDoubleClick(MouseEventArgs)

發生於按兩下滑鼠時。Occurs when you double-click the mouse.

OnMouseDown(MouseEventArgs)

發生於按一下滑鼠按鈕時。Occurs when a mouse button is clicked.

OnMouseEnter(MouseEventArgs)

發生於滑鼠指標進入物件的範圍時。Occurs when the mouse pointer enters the bounds of an object.

OnMouseHover(MouseEventArgs)

發生於滑鼠指標在物件上暫停時。Occurs when the mouse pointer pauses above an object.

OnMouseLeave()

發生於滑鼠指標離開物件的範圍時。Occurs when the mouse pointer leaves the bounds of an object.

OnMouseMove(MouseEventArgs)

發生於滑鼠指標在物件的範圍內移動時。Occurs when the mouse pointer moves while within the bounds of an object.

OnMouseUp(MouseEventArgs)

發生於放開滑鼠按鈕時。Occurs when the mouse button is released.

OnMouseWheel(MouseEventArgs)

發生於滑鼠滾輪移動時。Occurs when the mouse wheel moves.

OnPaint(PaintEventArgs, Rectangle, AmbientTheme)

發生於接收繪製訊息時。Occurs when a paint message is received.

OnPaintWorkflowAdornments(PaintEventArgs, Rectangle, AmbientTheme)

發生於工作流程應該重新繪製其裝飾時。Occurs when the workflow should repaint its adornments.

OnQueryContinueDrag(QueryContinueDragEventArgs)

發生於拖曳作業時。Occurs during a drag operation.

OnScroll(ScrollBar, Int32)

發生於使用者在工作流程設計工具中捲動時。Occurs when a user scrolls in a workflow designer.

OnShowContextMenu(Point)

發生於工作流程應該顯示操作功能表時。Occurs when the workflow should show a context menu.

OnThemeChange()

發生於工作流程的主題變更時。Occurs when the theme of the workflow changes.

ProcessMessage(Message)

發生於需要處理未經處理的 Win32 訊息時。Occurs when a raw Win32 message must be processed.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

適用於

另請參閱