Ejemplo n.º 1
0
            /// <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;
            }
Ejemplo n.º 2
0
            /// <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;
                }
            }
Ejemplo n.º 3
0
            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
            }
Ejemplo n.º 4
0
            /// <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;
            }
Ejemplo n.º 5
0
            /// <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;
            }
Ejemplo n.º 6
0
 protected virtual void OnTouchGestureEnded(TouchGestureEventArgs e)
 {
     if (TouchGestureEnd != null)
     {
         TouchGestureEnd(this, e);
     }
 }
Ejemplo n.º 7
0
 protected virtual void OnTouchGestureStarted(TouchGestureEventArgs e)
 {
     if (TouchGestureStart != null)
     {
         TouchGestureStart(this, e);
     }
 }
Ejemplo n.º 8
0
        protected virtual void OnGenericEvent(GenericEventArgs e)
        {
            GenericEvent genericEvent = e.InternalEvent;
            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)
                        {
                            OnTouchGestureStarted(ge);
                        }
                        else if (ge.Gesture == TouchGesture.End)
                        {
                            OnTouchGestureEnded(ge);
                        }
                        else
                        {
                            OnTouchGestureChanged(ge);
                        }

                        break;
                    }
                default:
                    {
                        break;
                    }
            }

        }