Esempio n. 1
0
    /// <summary>
    /// Initializes a new instance of the <see cref="EngineHandler"/> class.
    /// </summary>
    /// <param name="engineCreator">The function used to create an instance of the engine that actually recognizes the gesture.</param>
    /// <param name="trackedElement">The tracked element.</param>
    /// <param name="handleTouchEvent">if set to <c>true</c> then all touch events occurring on the tracked element will get e.Handled set to true to avoid further routing of the events.</param>
    public EngineHandlerBase(Func<IGestureEngine> engineCreator, UIElement trackedElement, bool handleTouchEvent = false)
    {
      this._engineCreator = engineCreator;
      this._trackedElement = trackedElement;
      this.HandlesTouchEvents = handleTouchEvent;
      trackedElement.AddHandler(UIElement.TouchDownEvent, new EventHandler<TouchEventArgs>(OnTrackedElementTouchDown), true);
      trackedElement.AddHandler(UIElement.TouchUpEvent, new EventHandler<TouchEventArgs>(OnTrackedElementTouchUp), true);
      trackedElement.AddHandler(UIElement.TouchMoveEvent, new EventHandler<TouchEventArgs>(OnTrackedElementTouchMove), true);


      //trackedElement.AddHandler(UIElement.MouseDownEvent, new EventHandler<MouseButtonEventArgs>(OnTrackedElementMouseDown));
      //trackedElement.AddHandler(UIElement.MouseUpEvent, new EventHandler<MouseButtonEventArgs>(OnTrackedElementMouseUp));
      //trackedElement.AddHandler(UIElement.MouseMoveEvent, new EventHandler<MouseButtonEventArgs>(OnTrackedElementMouseMove));

    }
Esempio n. 2
0
        /// <summary>
        /// 注册事件
        /// </summary>
        /// <param name="element"></param>
        public void RegisterEvent(UIElement element)
        {
            if (element != null)
            {

                element.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(ElementMouseDown), true);
            }
        }
Esempio n. 3
0
        /// <summary>
        ///     Attaches the handler on the element.
        /// </summary>
        /// <param name="element">The element on which to attach the handler.</param>
        /// <param name="handler">The handler to attach.</param>
        public static void AddPreviewExecutedHandler(UIElement element, ExecutedRoutedEventHandler handler)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }

            element.AddHandler(PreviewExecutedEvent, handler);
        }
Esempio n. 4
0
 // Methods
 public CaptureThief(UIElement element)
 {
     this.Owner = element;
     SetHasCaptureThief(this.Owner, true);
     element.AddHandler(UIElement.GotMouseCaptureEvent, new MouseEventHandler(this.OnGotMouseCapture), true);
     element.AddHandler(UIElement.GotTouchCaptureEvent, new EventHandler<TouchEventArgs>(this.OnGotTouchCapture), true);
     element.AddHandler(UIElement.MouseMoveEvent, new MouseEventHandler(this.OnMouseMove), true);
     element.AddHandler(UIElement.TouchMoveEvent, new EventHandler<TouchEventArgs>(this.OnTouchMove), true);
     element.AddHandler(UIElement.LostMouseCaptureEvent, new MouseEventHandler(this.OnLostMouseCapture), true);
     element.AddHandler(UIElement.LostTouchCaptureEvent, new EventHandler<TouchEventArgs>(this.OnLostTouchCapture), true);
 }
		public HexMouseProcessorCollection(UIElement mouseElement, UIElement manipulationElement, DefaultHexMouseProcessor defaultMouseProcessor, HexMouseProcessor[] mouseProcessors, Func<MouseEventArgs, bool> allowEvent) {
			if (mouseElement == null)
				throw new ArgumentNullException(nameof(mouseElement));
			if (defaultMouseProcessor == null)
				throw new ArgumentNullException(nameof(defaultMouseProcessor));
			if (mouseProcessors == null)
				throw new ArgumentNullException(nameof(mouseProcessors));
			this.mouseElement = mouseElement;
			this.manipulationElement = manipulationElement;
			this.defaultMouseProcessor = defaultMouseProcessor;
			this.mouseProcessors = mouseProcessors;
			this.allowEvent = allowEvent ?? defaultAllowEvent;
			mouseElement.AddHandler(UIElement.QueryContinueDragEvent, new QueryContinueDragEventHandler(MouseElement_QueryContinueDrag), true);
			mouseElement.AddHandler(UIElement.MouseWheelEvent, new MouseWheelEventHandler(MouseElement_MouseWheel), true);
			mouseElement.AddHandler(UIElement.MouseUpEvent, new MouseButtonEventHandler(MouseElement_MouseUp), true);
			mouseElement.AddHandler(UIElement.MouseRightButtonUpEvent, new MouseButtonEventHandler(MouseElement_MouseRightButtonUp), true);
			mouseElement.AddHandler(UIElement.MouseRightButtonDownEvent, new MouseButtonEventHandler(MouseElement_MouseRightButtonDown), true);
			mouseElement.AddHandler(UIElement.MouseMoveEvent, new MouseEventHandler(MouseElement_MouseMove), true);
			mouseElement.AddHandler(UIElement.MouseLeftButtonUpEvent, new MouseButtonEventHandler(MouseElement_MouseLeftButtonUp), true);
			mouseElement.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(MouseElement_MouseLeftButtonDown), true);
			mouseElement.AddHandler(UIElement.MouseLeaveEvent, new MouseEventHandler(MouseElement_MouseLeave), true);
			mouseElement.AddHandler(UIElement.MouseEnterEvent, new MouseEventHandler(MouseElement_MouseEnter), true);
			mouseElement.AddHandler(UIElement.MouseDownEvent, new MouseButtonEventHandler(MouseElement_MouseDown), true);
			mouseElement.AddHandler(UIElement.GiveFeedbackEvent, new GiveFeedbackEventHandler(MouseElement_GiveFeedback), true);
			mouseElement.AddHandler(UIElement.DropEvent, new DragEventHandler(MouseElement_Drop), true);
			mouseElement.AddHandler(UIElement.DragOverEvent, new DragEventHandler(MouseElement_DragOver), true);
			mouseElement.AddHandler(UIElement.DragLeaveEvent, new DragEventHandler(MouseElement_DragLeave), true);
			mouseElement.AddHandler(UIElement.DragEnterEvent, new DragEventHandler(MouseElement_DragEnter), true);
			if (manipulationElement != null) {
				manipulationElement.AddHandler(UIElement.TouchUpEvent, new EventHandler<TouchEventArgs>(ManipulationElement_TouchUp), true);
				manipulationElement.AddHandler(UIElement.TouchDownEvent, new EventHandler<TouchEventArgs>(ManipulationElement_TouchDown), true);
				manipulationElement.AddHandler(UIElement.StylusSystemGestureEvent, new StylusSystemGestureEventHandler(ManipulationElement_StylusSystemGesture), true);
				manipulationElement.AddHandler(UIElement.ManipulationStartingEvent, new EventHandler<ManipulationStartingEventArgs>(ManipulationElement_ManipulationStarting), true);
				manipulationElement.AddHandler(UIElement.ManipulationInertiaStartingEvent, new EventHandler<ManipulationInertiaStartingEventArgs>(ManipulationElement_ManipulationInertiaStarting), true);
				manipulationElement.AddHandler(UIElement.ManipulationDeltaEvent, new EventHandler<ManipulationDeltaEventArgs>(ManipulationElement_ManipulationDelta), true);
				manipulationElement.AddHandler(UIElement.ManipulationCompletedEvent, new EventHandler<ManipulationCompletedEventArgs>(ManipulationElement_ManipulationCompleted), true);
			}
		}
Esempio n. 6
0
        /// <summary>
        /// Adds a handler for the QueryGripInteractionStatus attached event
        /// </summary>
        /// <param name="element">UIElement that listens to this event</param>
        /// <param name="handler">Event Handler to be added</param>
        public static void AddQueryInteractionStatusHandler(UIElement element, EventHandler<QueryInteractionStatusEventArgs> handler)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            element.AddHandler(KinectRegion.QueryInteractionStatusEvent, handler);
        }
Esempio n. 7
0
        /// <summary>
        /// Adds a handler for the HandPointerLostCapture attached event
        /// </summary>
        /// <param name="element">UIElement that listens to this event</param>
        /// <param name="handler">Event Handler to be added</param>
        public static void AddHandPointerLostCaptureHandler(UIElement element, EventHandler<HandPointerEventArgs> handler)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            element.AddHandler(KinectRegion.HandPointerLostCaptureEvent, handler);
        }
Esempio n. 8
0
        public static void Relay(UIElement element)
        {
            element.AddHandler(CommandManager.ExecutedEvent, new RoutedEventHandler(HandleExecute), true);
            element.AddHandler(CommandManager.CanExecuteEvent, new RoutedEventHandler(HandleCanExecute), true);

            element.AddHandler(CommandManager.PreviewExecutedEvent, new RoutedEventHandler(HandlePreviewExecute), true);
            element.AddHandler(CommandManager.PreviewCanExecuteEvent, new RoutedEventHandler(HandlePreviewCanExecute), true);
        }
Esempio n. 9
0
 /// <summary>
 /// Adds a handler for the ClearPropertyItem attached event
 /// </summary>
 /// <param name="element">the element to attach the handler</param>
 /// <param name="handler">the handler for the event</param>
 public static void AddClearPropertyItemHandler( UIElement element, PropertyItemEventHandler handler )
 {
   element.AddHandler( PropertyGrid.ClearPropertyItemEvent, handler );
 }
Esempio n. 10
0
 /// <summary>
 /// Adds a handler for the PreparePropertyItem attached event
 /// </summary>
 /// <param name="element">the element to attach the handler</param>
 /// <param name="handler">the handler for the event</param>
 public static void AddPreparePropertyItemHandler( UIElement element, PropertyItemEventHandler handler )
 {
   element.AddHandler( PropertyGrid.PreparePropertyItemEvent, handler );
 }
Esempio n. 11
0
        /// <summary>
        ///     Attaches the handler on the element.
        /// </summary>
        /// <param name="element">The element on which to attach the handler.</param>
        /// <param name="handler">The handler to attach.</param>
        public static void AddCanExecuteHandler(UIElement element, CanExecuteRoutedEventHandler handler)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }

            element.AddHandler(CanExecuteEvent, handler);
        }
Esempio n. 12
0
 public static void AddGiveFeedbackHandler(DependencyObject element, GiveFeedbackEventHandler handler)
 {
     UIElement.AddHandler(element, GiveFeedbackEvent, handler);
 }
Esempio n. 13
0
 public static void AddDropHandler(DependencyObject element, DragEventHandler handler)
 {
     UIElement.AddHandler(element, DropEvent, handler);
 }
Esempio n. 14
0
 public static void AddQueryContinueDragHandler(DependencyObject element, QueryContinueDragEventHandler handler)
 {
     UIElement.AddHandler(element, QueryContinueDragEvent, handler);
 }
Esempio n. 15
0
 public static void AddPreviewDragOverHandler(DependencyObject element, DragEventHandler handler)
 {
     UIElement.AddHandler(element, PreviewDragOverEvent, handler);
 }
Esempio n. 16
0
 public static void PairExpanded(this TreeViewItem item, UIElement pairToObject, RoutedEvent pairToExpandEvent, RoutedEvent pairToCollapseEvent, DependencyProperty pairToProperty)
 {
     item.AddSelfExpanded((sender, args) => pairToObject.SetValue(pairToProperty, true));
     item.AddSelfCollapsed((sender, args) => pairToObject.SetValue(pairToProperty, false));
     pairToObject.SetValue(pairToProperty, item.IsExpanded);
     pairToObject.AddHandler(pairToExpandEvent, new RoutedEventHandler((sender, args) => item.IsExpanded = true));
     pairToObject.AddHandler(pairToCollapseEvent, new RoutedEventHandler((sender, args) => item.IsExpanded = false));
 }