WPF UIEventHub register a number of events and distributed to registered UIEventProcessor, available UIEventProcessor included MultiSelectEventProcessor and DragDropEventProcessor, which is an update for SelectionHelper and FileDragDropHelper static class in FileExplorer2.

A full list of UIEventProcessors.

Please also see this article
public interface IUIEventHub
{
    UIElement Control { get; }
    IList<UIEventProcessorBase> EventProcessors { get; }
    bool IsEnabled { get; set; }
}

When IsEnabled is set, UIEventHub will query its UIEventProcessors for event it wish to listen, and register those events from the control, so if DragDropEventProcessor and MultiSelectEventProcessor both want to listen to UIEvent.PreviewMouseDown event, UIEventHub will register one instance of handler only.

When an event is triggered, the sender and EventArgs is convert to UIInput, and this UIInput is passed to a list of UIInputProcessor to update certain property. Then UIEventHub will call each EventProcessor's OnEvent(eventId) method to receive what to execute for particular event, it's in the form IScriptCommand, and execute them sequentially.

How to use?
public UIEventHub(IScriptRunner runner, UIElement control, bool startIsEnabled = true, params UIEventProcessorBase[] eventProcessors)

You can use the constructor of UIEventHub to register the EventProcessors, or you can register in the xaml via the UIEventAdapter:
<uc:ListViewEx ... >
        <bc:UIEventAdapter.Processors>
            <bc:TouchGestureEventProcessor Gesture="FlickLeft" Command="BrowseBack" />
         <!-- More processor here -->
   </bc:UIEventAdapter.Processors>
</uc:ListViewEx>





Last edited Oct 17, 2014 at 5:22 PM by lycj, version 11

Comments

No comments yet.