/// <summary> /// Pass touch gesture events to the children. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TouchGestureEvent(object sender, TouchGestureEventArgs e) { if (_handleEvents) OnTouchGesture(e); }
/// <summary> /// Handles touch gesture events. /// </summary> /// <param name="e">Touch event arguments.</param> /// <returns>Touch event arguments.</returns> public virtual TouchGestureEventArgs OnTouchGesture(TouchGestureEventArgs e) { return e; }
/// <summary> /// Triggers a gesture event. /// </summary> /// <param name="sender">Object associated with the event.</param> /// <param name="args">Touch gesture event arguments.</param> public void TriggerGestureEvent(object sender, TouchGestureEventArgs args) { if (GestureEvent != null) GestureEvent(sender, args); }
bool IEventListener.OnEvent(BaseEvent ev) { /// Process known events, otherwise forward as generic to MainWindow. /// TouchEvent touchEvent = ev as TouchEvent; if (touchEvent != null) { // dispatch only when the event is in the active area for(int i = 0; i < _activeRegions.Length; ++i) { ActiveRectangle ar = _activeRegions[i]; // only check the first if(ar.Contains(touchEvent.Touches[0])) { TouchScreenEventArgs tea = new TouchScreenEventArgs(touchEvent.Time, touchEvent.Touches, ar.Target); switch((TouchMessages)touchEvent.EventMessage) { case TouchMessages.Down: if(OnTouchDown != null) { OnTouchDown(this, tea); } break; case TouchMessages.Up: if(OnTouchUp != null) { OnTouchUp(this, tea); } break; case TouchMessages.Move: if(OnTouchMove != null) { OnTouchMove(this, tea); } break; } } } return true; } else if(ev is GenericEvent) { GenericEvent genericEvent = (GenericEvent)ev; switch (genericEvent.EventCategory) { case (byte)EventCategory.Gesture: { TouchGestureEventArgs ge = new TouchGestureEventArgs(); ge.Gesture = (TouchGesture)genericEvent.EventMessage; ge.X = genericEvent.X; ge.Y = genericEvent.Y; ge.Arguments = (ushort)genericEvent.EventData; if (ge.Gesture == TouchGesture.Begin && OnGestureStarted != null) { OnGestureStarted(this, ge); } else if (ge.Gesture == TouchGesture.End && OnGestureEnded!= null) { OnGestureEnded(this, ge); } else if(OnGestureChanged != null) { OnGestureChanged(this, ge); } break; } default: break; } } return false; }