WorkflowDesignerMessageFilter Класс

Определение

Внимание!

The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*

Предоставляет базовый класс для всех фильтров сообщений рабочего процесса.

public ref class WorkflowDesignerMessageFilter abstract : IDisposable
public abstract class WorkflowDesignerMessageFilter : 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
[<System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")>]
type WorkflowDesignerMessageFilter = class
    interface IDisposable
Public MustInherit Class WorkflowDesignerMessageFilter
Implements IDisposable
Наследование
WorkflowDesignerMessageFilter
Атрибуты
Реализации

Примеры

В следующем примере кода показан пользовательский фильтр сообщений конструктора, который наследуется из объекта WorkflowDesignerMessageFilter. В классе с именем CustomMessageFilter переопределяется некоторое количество методов базового класса, включая: OnMouseDown, OnMouseMove, OnMouseUp, OnMouseDoubleClick, OnMouseEnter, OnMouseHover, OnMouseLeave, OnDragEnter, OnDragOver, OnKeyDown.

Данный пример кода является частью примера SDK«Basic Designer Hosting» из файла DesignerShell.cs. Дополнительные сведения см. в разделе Базовое размещение Designer.

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

Комментарии

Примечание

В этом материале обсуждаются устаревшие типы и пространства имен. Дополнительные сведения см. в статье о нерекомендуемых типах в Windows Workflow Foundation 4.5.

Конструктор рабочих процессов предоставляет шаблон проектирования Strategy для создания заменяемых объектов фильтров сообщений для обработки событий.

Наследуется от класса WorkflowDesignerMessageFilter для создания фильтров сообщений, которые могут реагировать на события конструктора рабочих процессов, например, операции перетаскивания, компоновки, рисования и другие события конструктора. Чтобы добавить пользовательский фильтра сообщений к цепочке фильтров сообщений, вызовите метод AddDesignerMessageFilter в объекте WorkflowView или переопределите виртуальное свойство MessageFiltersв пользовательской корневой операции и добавьте пользовательский фильтр сообщений к коллекции, которая возвращается из базового класса.

Конструкторы

WorkflowDesignerMessageFilter()
Устаревшие..

При реализации в производном классе инициализирует экземпляр WorkflowDesignerMessageFilter.

Свойства

MessageHitTestContext
Устаревшие..

Возвращает объект HitTestInfo, который описывает контекст объекта WorkflowDesignerMessageFilter.

ParentView
Устаревшие..

Возвращает объект WorkflowView, связанный с WorkflowDesignerMessageFilter.

Методы

Dispose()
Устаревшие..

Освобождает ресурсы, используемые объектом WorkflowDesignerMessageFilter.

Dispose(Boolean)
Устаревшие..

Освобождает неуправляемые ресурсы, используемые объектом WorkflowDesignerMessageFilter, а при необходимости освобождает также управляемые ресурсы.

Equals(Object)
Устаревшие..

Определяет, равен ли указанный объект текущему объекту.

(Унаследовано от Object)
Finalize()
Устаревшие..

Пытается освободить ресурсы путем вызова метода Dispose(false) перед уничтожением объекта во время сборки мусора.

GetHashCode()
Устаревшие..

Служит хэш-функцией по умолчанию.

(Унаследовано от Object)
GetType()
Устаревшие..

Возвращает объект Type для текущего экземпляра.

(Унаследовано от Object)
Initialize(WorkflowView)
Устаревшие..

Инициализирует объект WorkflowDesignerMessageFilter со связанным объектом WorkflowView.

MemberwiseClone()
Устаревшие..

Создает неполную копию текущего объекта Object.

(Унаследовано от Object)
OnDragDrop(DragEventArgs)
Устаревшие..

Вызывается при отпускании кнопки мыши над объектом во время операции перетаскивания.

OnDragEnter(DragEventArgs)
Устаревшие..

Вызывается, когда указатель мыши пересекает границы объекта во время операции перетаскивания.

OnDragLeave()
Устаревшие..

Вызывается, когда указатель мыши выходит за границы объекта во время операции перетаскивания.

OnDragOver(DragEventArgs)
Устаревшие..

Вызывается, когда указатель мыши перемещается в границах объекта во время операции перетаскивания.

OnGiveFeedback(GiveFeedbackEventArgs)
Устаревшие..

Вызывается при выполнении операции перетаскивания.

OnKeyDown(KeyEventArgs)
Устаревшие..

Вызывается при нажатии клавиши.

OnKeyUp(KeyEventArgs)
Устаревшие..

Вызывается при отпускании клавиши.

OnLayout(LayoutEventArgs)
Устаревшие..

Вызывается, когда необходимо изменить расположение дочерних объектов.

OnMouseCaptureChanged()
Устаревшие..

Вызывается, когда изменяются элементы, выбранные с помощью перетаскивания мыши.

OnMouseDoubleClick(MouseEventArgs)
Устаревшие..

Вызывается при двойном щелчке мыши.

OnMouseDown(MouseEventArgs)
Устаревшие..

Вызывается при нажатии кнопки мыши.

OnMouseEnter(MouseEventArgs)
Устаревшие..

Вызывается, когда указатель мыши входит в границы объекта.

OnMouseHover(MouseEventArgs)
Устаревшие..

Вызывается, когда указатель мыши останавливается над объектом.

OnMouseLeave()
Устаревшие..

Вызывается, когда указатель мыши выходит за границы объекта.

OnMouseMove(MouseEventArgs)
Устаревшие..

Вызывается, когда указатель мыши перемещается в границах объекта.

OnMouseUp(MouseEventArgs)
Устаревшие..

Вызывается при отпускании кнопки мыши.

OnMouseWheel(MouseEventArgs)
Устаревшие..

Вызывается при движении колесика мыши.

OnPaint(PaintEventArgs, Rectangle, AmbientTheme)
Устаревшие..

Вызывается при получении сообщения рисования.

OnPaintWorkflowAdornments(PaintEventArgs, Rectangle, AmbientTheme)
Устаревшие..

Вызывается, когда рабочий процесс должен перерисовать свои элементы оформления.

OnQueryContinueDrag(QueryContinueDragEventArgs)
Устаревшие..

Вызывается при выполнении операции перетаскивания.

OnScroll(ScrollBar, Int32)
Устаревшие..

Вызывается, когда пользователь выполняет прокрутку в конструкторе рабочего процесса.

OnShowContextMenu(Point)
Устаревшие..

Вызывается, когда рабочий процесс должен показать контекстное меню.

OnThemeChange()
Устаревшие..

Вызывается при изменении темы рабочего процесса.

ProcessMessage(Message)
Устаревшие..

Вызывается, когда необходимо обработать необработанное сообщения Win32.

ToString()
Устаревшие..

Возвращает строку, представляющую текущий объект.

(Унаследовано от Object)

Применяется к

См. также раздел