Exemplo n.º 1
0
        private void DecodeZoomGesture(ref Win32.GESTUREINFO gestureInfo)
        {
            ZoomGestureEventArgs args = new ZoomGestureEventArgs();

            switch (gestureInfo.dwFlags)
            {
            case Win32.GF_BEGIN:
            {
                args.state          = GestureState.Begin;
                mZoomInfo.ptFirst.X = gestureInfo.ptsLocation.X;
                mZoomInfo.ptFirst.Y = gestureInfo.ptsLocation.Y;
            }
            break;

            default:
            {
                if (args.state == GestureState.End)
                {
                    args.state = GestureState.End;
                }
                else
                {
                    args.state = GestureState.Move;
                }
                // Read the second point of the gesture, this is the middle point between the fingers
                mZoomInfo.ptSecond.X = gestureInfo.ptsLocation.X;
                mZoomInfo.ptSecond.Y = gestureInfo.ptsLocation.Y;
                // Calculate the zoom center point
                POINT ptZoomCenter = new POINT((mZoomInfo.ptFirst.X + mZoomInfo.ptSecond.X) / 2,
                                               (mZoomInfo.ptFirst.Y + mZoomInfo.ptSecond.Y) / 2);
                args.zoom = (double)(gestureInfo.ullArguments & Win32.ULL_ARGUMENTS_BIT_MASK) /
                            (double)(mZoomInfo.argument);
            }
            break;
            }

            args.distance   = (int)(gestureInfo.ullArguments & Win32.ULL_ARGUMENTS_BIT_MASK);
            args.ptFirst.X  = mZoomInfo.ptFirst.X;
            args.ptFirst.Y  = mZoomInfo.ptFirst.Y;
            args.ptSecond.X = mZoomInfo.ptSecond.X;
            args.ptSecond.Y = mZoomInfo.ptSecond.Y;
            if (ZoomEventHandler != null)
            {
                ZoomEventHandler(this, args);
            }

            // Store the new information as a starting point for the next step in the gesture
            mZoomInfo.argument = (int)(gestureInfo.ullArguments & Win32.ULL_ARGUMENTS_BIT_MASK);
            if (gestureInfo.dwFlags != Win32.GF_BEGIN)
            {
                mZoomInfo.ptFirst.X = mZoomInfo.ptSecond.X;
                mZoomInfo.ptFirst.Y = mZoomInfo.ptSecond.Y;
            }
        }
Exemplo n.º 2
0
        private void DecodeZoomGesture(ref Win32.GESTUREINFO gestureInfo)
        {
            ZoomGestureEventArgs e = new ZoomGestureEventArgs();

            if (gestureInfo.dwFlags == 1)
            {
                e.state = GestureState.Begin;
                this.mZoomInfo.ptFirst.X = gestureInfo.ptsLocation.X;
                this.mZoomInfo.ptFirst.Y = gestureInfo.ptsLocation.Y;
            }
            else
            {
                if (e.state == GestureState.End)
                {
                    e.state = GestureState.End;
                }
                else
                {
                    e.state = GestureState.Move;
                }
                this.mZoomInfo.ptSecond.X = gestureInfo.ptsLocation.X;
                this.mZoomInfo.ptSecond.Y = gestureInfo.ptsLocation.Y;
                new POINT((this.mZoomInfo.ptFirst.X + this.mZoomInfo.ptSecond.X) / 2, (this.mZoomInfo.ptFirst.Y + this.mZoomInfo.ptSecond.Y) / 2);
                e.zoom = ((double)(((ulong)gestureInfo.ullArguments) & 0xffffffffL)) / ((double)this.mZoomInfo.argument);
            }
            e.distance   = (int)(((ulong)gestureInfo.ullArguments) & 0xffffffffL);
            e.ptFirst.X  = this.mZoomInfo.ptFirst.X;
            e.ptFirst.Y  = this.mZoomInfo.ptFirst.Y;
            e.ptSecond.X = this.mZoomInfo.ptSecond.X;
            e.ptSecond.Y = this.mZoomInfo.ptSecond.Y;
            if (this.ZoomEventHandler != null)
            {
                this.ZoomEventHandler(this, e);
            }
            this.mZoomInfo.argument = (int)(((ulong)gestureInfo.ullArguments) & 0xffffffffL);
            if (gestureInfo.dwFlags != 1)
            {
                this.mZoomInfo.ptFirst.X = this.mZoomInfo.ptSecond.X;
                this.mZoomInfo.ptFirst.Y = this.mZoomInfo.ptSecond.Y;
            }
        }
Exemplo n.º 3
0
 private void DecodeZoomGesture(ref Win32.GESTUREINFO gestureInfo)
 {
     ZoomGestureEventArgs e = new ZoomGestureEventArgs();
     if (gestureInfo.dwFlags == 1)
     {
         e.state = GestureState.Begin;
         this.mZoomInfo.ptFirst.X = gestureInfo.ptsLocation.X;
         this.mZoomInfo.ptFirst.Y = gestureInfo.ptsLocation.Y;
     }
     else
     {
         if (e.state == GestureState.End)
         {
             e.state = GestureState.End;
         }
         else
         {
             e.state = GestureState.Move;
         }
         this.mZoomInfo.ptSecond.X = gestureInfo.ptsLocation.X;
         this.mZoomInfo.ptSecond.Y = gestureInfo.ptsLocation.Y;
         new POINT((this.mZoomInfo.ptFirst.X + this.mZoomInfo.ptSecond.X) / 2, (this.mZoomInfo.ptFirst.Y + this.mZoomInfo.ptSecond.Y) / 2);
         e.zoom = ((double) (((ulong) gestureInfo.ullArguments) & 0xffffffffL)) / ((double) this.mZoomInfo.argument);
     }
     e.distance = (int) (((ulong) gestureInfo.ullArguments) & 0xffffffffL);
     e.ptFirst.X = this.mZoomInfo.ptFirst.X;
     e.ptFirst.Y = this.mZoomInfo.ptFirst.Y;
     e.ptSecond.X = this.mZoomInfo.ptSecond.X;
     e.ptSecond.Y = this.mZoomInfo.ptSecond.Y;
     if (this.ZoomEventHandler != null)
     {
         this.ZoomEventHandler(this, e);
     }
     this.mZoomInfo.argument = (int) (((ulong) gestureInfo.ullArguments) & 0xffffffffL);
     if (gestureInfo.dwFlags != 1)
     {
         this.mZoomInfo.ptFirst.X = this.mZoomInfo.ptSecond.X;
         this.mZoomInfo.ptFirst.Y = this.mZoomInfo.ptSecond.Y;
     }
 }