/// <summary> /// Passes touch gesture events to the children. /// </summary> /// <param name="e">Touch event arguments.</param> /// <returns>Touch event arguments.</returns> /// <remarks>Events are passed to the children in descending order (from the last child added to the first).</remarks> public override TouchGestureEventArgs OnTouchGesture(TouchGestureEventArgs e) { DisplayObject child; for (int i = _displayList.Count - 1; i >= 0; i--) { if (!e.Propagate) { break; } child = (DisplayObject)_displayList[i]; if (child.Enabled && child.Visible && child.Interactive) { e = child.OnTouchGesture(e); } } if (e.Propagate) { TriggerGestureEvent(this, 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); } }
/// <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); } }
protected virtual void OnGenericEvent(GenericEventArgs e) { GenericEvent internalEvent = e.InternalEvent; if (internalEvent.EventCategory != (byte)2) { return; } TouchGestureEventArgs e1 = new TouchGestureEventArgs() { Gesture = (TouchGesture)internalEvent.EventMessage, X = internalEvent.X, Y = internalEvent.Y, Arguments = (ushort)internalEvent.EventData }; if (e1.Gesture == TouchGesture.Begin) { this.OnTouchGestureStarted(e1); } else if (e1.Gesture == TouchGesture.End) { this.OnTouchGestureEnded(e1); } else { this.OnTouchGestureChanged(e1); } }
private void TouchManager_TouchGestureEnded(object sender, TouchGestureEventArgs e) { Control touchTarget = GetTouchTarget(e.Point); if (touchTarget != null) { touchTarget.RaiseTouchGestureEndedEvent(e); } }
void GestureRecognizer_OnGestureRecognized(object sender, TouchGestureEventArgs args) { switch (args.Type) { case TouchGestureType.Tap: //Console.WriteLine("TAP"); break; case TouchGestureType.LongTap: //Console.WriteLine("LONGTAP"); break; case TouchGestureType.Pan: //Console.WriteLine("PAN"); try { date.AddTicks(-2 * (Int64)args.Data.X * pixeltime); } catch (OverflowException) { if (args.Data.X < 0) { date = TimelineDateTime.MaxValue; } else { date = TimelineDateTime.MinValue; } } DateStr = date.DateStr(ZoomUnit - 1); canvasView.InvalidateSurface(); break; case TouchGestureType.Pinch: //Console.WriteLine("PINCH - " + args.Data.ToString()); Zoom -= Zoom * 0.005 * args.Data.X; if (Zoom < 4) { Zoom = 4; } if (Zoom > 2073600) { Zoom = 2073600; } pixeltime = (Int64)(Zoom * TimeSpan.TicksPerSecond); //Console.WriteLine("Zoom: " + Zoom.ToString() + " pixeltime: " + pixeltime.ToString()); AdjustZoomUnit(); DateStr = date.DateStr(ZoomUnit - 1); canvasView.InvalidateSurface(); break; case TouchGestureType.Swipe: //Console.WriteLine("SWIPE"); break; } }
protected virtual void OnTouchGestureEnded(TouchGestureEventArgs e) { // ISSUE: reference to a compiler-generated field TouchGestureEventHandler touchGestureEnd = this.TouchGestureEnd; if (touchGestureEnd == null) { return; } touchGestureEnd((object)this, e); }
protected virtual void OnTouchGestureEnded(TouchGestureEventArgs e) { if (TouchGestureEnded != null) { TouchGestureEnded(this, e); } if (parent != null) { parent.OnTouchGestureEnded(e); } }
/// <summary> /// Handles multi-touch gesture events. Multitouch gestures are performed on the emulator by /// holding down CTRL+[Z|P|R] and inking (to change the angle/zoom level). /// </summary> /// <param name="e">Touch gesture event data</param> protected override void OnTouchGestureChanged(TouchGestureEventArgs e) { base.OnTouchGestureChanged(e); Bitmap b; switch (e.Gesture) { /// /// Zoom gesture magnifies the original bitmap by the gesture value contained in e.Arguments /// case TouchGesture.Zoom: if (_bmpGesture != null) { b = new Bitmap(_bitmap.Width, _bitmap.Height); b.DrawRectangle(Color.Black, 1, 0, 0, b.Width - 2, b.Height - 2, 0, 0, Color.White, 0, 0, Color.White, b.Width, b.Height, Bitmap.OpacityOpaque); b.StretchImage(-(e.Arguments), -(e.Arguments), _bmpGesture, _bmpGesture.Width + 2 * (e.Arguments), _bmpGesture.Height + 2 * (e.Arguments), Bitmap.OpacityOpaque); _bitmap = b; Invalidate(); } break; /// /// Pan (zoom out) gesture shrinks the original bitmap by the gesture value contained in e.Arguments /// case TouchGesture.Pan: if (_bmpGesture != null) { b = new Bitmap(_bitmap.Width, _bitmap.Height); b.DrawRectangle(Color.Black, 1, 0, 0, b.Width - 2, b.Height - 2, 0, 0, Color.White, 0, 0, Color.White, b.Width, b.Height, Bitmap.OpacityOpaque); b.StretchImage((e.Arguments), (e.Arguments), _bmpGesture, _bmpGesture.Width - 2 * (e.Arguments), _bmpGesture.Height - 2 * (e.Arguments), Bitmap.OpacityOpaque); _bitmap = b; Invalidate(); } break; /// /// Rotate gesture spins the original bitmap by the gesture value contained in e.Angle (0-360). /// case TouchGesture.Rotate: if (_bmpGesture != null) { b = new Bitmap(_bitmap.Width, _bitmap.Height); b.DrawRectangle(Color.Black, 1, 0, 0, b.Width, b.Height, 0, 0, Color.White, 0, 0, Color.White, b.Width, b.Height, Bitmap.OpacityOpaque); b.RotateImage((int)e.Angle, 1, 1, _bmpGesture, 1, 1, _bmpGesture.Width - 2, _bmpGesture.Height - 2, Bitmap.OpacityOpaque); _bitmap = b; Invalidate(); } break; } }
/// <summary> /// The handler for the gesture changed event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GestureChangedHandler(object sender, TouchGestureEventArgs e) { int id = (int)_currentScreenId; id = (id + 1) % (int)ScreenId.Last; switch (e.Gesture) { case TouchGesture.Right: Show((ScreenId)id, false); break; case TouchGesture.Left: Show((ScreenId)id, false); break; default: break; } }
protected override void OnTouchGestureChanged(TouchGestureEventArgs e) { // Find the affected block. int x = e.X; int y = e.Y; #endif int c = x / blockDimension; int r = y / blockDimension; int b = c + r * 3; int nc = c; int nr = r; int[] altAnimX = null; int[] altAnimY = null; _animationTargetBlock = b; // The gesture event tells us what direction the user gestured. // Based on the gesture, use the animation offset arrays to move // the block to the appropriate location. #if MF_FRAMEWORK_VERSION_V3_0 switch (e.Gesture.Id) #else switch (e.Gesture) #endif { #if MF_FRAMEWORK_VERSION_V3_0 case ApplicationGesture.Left: #else case TouchGesture.Left: #endif { nc = nc - 1; activeAnimX = anim3; activeAnimY = anim1; altAnimX = anim6; altAnimY = anim1; break; } #if MF_FRAMEWORK_VERSION_V3_0 case ApplicationGesture.Right: #else case TouchGesture.Right: #endif { nc = nc + 1; activeAnimX = anim4; activeAnimY = anim1; altAnimX = anim5; altAnimY = anim1; break; } #if MF_FRAMEWORK_VERSION_V3_0 case ApplicationGesture.Up: #else case TouchGesture.Up: #endif { nr = nr - 1; activeAnimX = anim1; activeAnimY = anim3; altAnimX = anim1; altAnimY = anim6; break; } #if MF_FRAMEWORK_VERSION_V3_0 case ApplicationGesture.Down: #else case TouchGesture.Down: #endif { nr = nr + 1; activeAnimX = anim1; activeAnimY = anim4; altAnimX = anim1; altAnimY = anim5; break; } #if MF_FRAMEWORK_VERSION_V3_0 case ApplicationGesture.UpLeft: #else case TouchGesture.UpLeft: #endif { nc = -1; nr = -1; activeAnimX = anim6; activeAnimY = anim6; break; } #if MF_FRAMEWORK_VERSION_V3_0 case ApplicationGesture.UpRight: #else case TouchGesture.UpRight: #endif { nc = -1; nr = -1; activeAnimX = anim5; activeAnimY = anim6; break; } #if MF_FRAMEWORK_VERSION_V3_0 case ApplicationGesture.DownLeft: #else case TouchGesture.DownLeft: #endif { nc = -1; nr = -1; activeAnimX = anim6; activeAnimY = anim5; break; } #if MF_FRAMEWORK_VERSION_V3_0 case ApplicationGesture.DownRight: #else case TouchGesture.DownRight: #endif { nc = -1; nr = -1; activeAnimX = anim5; activeAnimY = anim5; break; } default: { nc = -1; nr = -1; activeAnimX = anim2; activeAnimY = anim1; break; } } // Verify that the target block location is empty. if ((nc >= 0) && (nc < 3) && (nr >= 0) && (nr < 3)) { int nb = nc + nr * 3; if (_blocks[nb] == 8) { /// Target location is empty. _blocks[nb] = _blocks[b]; _blocks[b] = 8; _animationTargetBlock = nb; } else { activeAnimX = altAnimX; activeAnimY = altAnimY; } } else if (altAnimX != null) { activeAnimX = altAnimX; activeAnimY = altAnimY; } if (activeAnimX != null && activeAnimY != null) { _animationStep = 0; _animationTimer.Start(); } #if !MF_FRAMEWORK_VERSION_V3_0 base.OnTouchGestureChanged(e); #endif }
/// <summary> /// Passes touch gesture events to the children. /// </summary> /// <param name="e">Touch event arguments.</param> /// <returns>Touch event arguments.</returns> /// <remarks>Events are passed to the children in descending order (from the last child added to the first).</remarks> public override TouchGestureEventArgs OnTouchGesture(TouchGestureEventArgs e) { DisplayObject child; for (int i = _displayList.Count - 1; i >= 0; i--) { if (!e.Propagate) break; child = (DisplayObject)_displayList[i]; if (child.Enabled && child.Visible && child.Interactive) e = child.OnTouchGesture(e); } if (e.Propagate) TriggerGestureEvent(this, e); return e; }
/// <summary> /// Reset the gesture bitmap when the gesture is finished. /// </summary> /// <param name="e">Touch gesture event data</param> protected override void OnTouchGestureEnded(TouchGestureEventArgs e) { base.OnTouchGestureEnded(e); _bmpGesture = null; }
/// <summary> /// When the gesture starts, save the current bitmap so that gesture events will /// be performed on the original (to avoid degradation of the image from multiple operations). /// </summary> /// <param name="e">Touch gesture event data</param> protected override void OnTouchGestureStarted(TouchGestureEventArgs e) { base.OnTouchGestureStarted(e); _bmpGesture = _bitmap; }
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; }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> #if !MF_FRAMEWORK_VERSION_V3_0 void puzzleBoard_Gesture(object sender, TouchGestureEventArgs e) { string gesture = "Unknown"; switch (e.Gesture) { case TouchGesture.Right: gesture = "Right"; break; case TouchGesture.UpRight: gesture = "UpRight"; break; case TouchGesture.Up: gesture = "Up"; break; case TouchGesture.UpLeft: gesture = "UpLeft"; break; case TouchGesture.Left: gesture = "Left"; break; case TouchGesture.DownLeft: gesture = "DownLeft"; break; case TouchGesture.Down: gesture = "Down"; break; case TouchGesture.DownRight: gesture = "DownRight"; break; case TouchGesture.Tap: gesture = "Tap"; break; case TouchGesture.DoubleTap: gesture = "DoubleTap"; break; case TouchGesture.Zoom: gesture = "Zoom"; break; case TouchGesture.Pan: gesture = "Pan"; break; case TouchGesture.Rotate: gesture = "Rotate: " + e.Angle.ToString(); break; case TouchGesture.TwoFingerTap: gesture = "TwoFingerTap"; break; case TouchGesture.Rollover: gesture = "Rollover"; break; } text.TextContent = gesture; }
/// <summary> /// Raises a touch gesture event. /// </summary> /// <param name="sender">Object associated with the event.</param> /// <param name="e">Touch event arguments.</param> public static void RaiseTouchGestureEvent(object sender, TouchGestureEventArgs e) { TouchGestureEvent(sender, e); }
internal void RaiseTouchGestureEndedEvent(TouchGestureEventArgs e) { OnTouchGestureEnded(e); }
/// <summary> /// The handler for the gesture changed event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GestureChangedHandler(object sender, TouchGestureEventArgs e) { int id = (int)_currentScreenId; id = (id + 1) % (int)ScreenId.Last; switch(e.Gesture) { case TouchGesture.Right: Show((ScreenId)id, false); break; case TouchGesture.Left: Show((ScreenId)id, false); break; default: break; } }
/// <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); }
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); }