Event arguments for all gesture events
Some of the properties are related to specific messages: Panning: PanTranslation Zooming: ZoomFactor Rotation: RotateAngle
상속: System.EventArgs
예제 #1
0
        private void UpdateValue(GestureEventArgs e)
        {
            try
            {
                int v = int.Parse(base.Text);
                base.Text = (v + e.PanTranslation.Width).ToString();
            }
            catch
            {

            }
        }
        /// <summary>
        /// The Windows message interception for gesture events handling
        /// </summary>
        /// <param name="hWnd">WndProc hWnd</param>
        /// <param name="msg">WndProc msg</param>
        /// <param name="wParam">WndProc wParam</param>
        /// <param name="lParam">WndProc lParam</param>
        /// <returns>WndProc return</returns>
        public override uint WindowProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam)
        {
            //We care only for gesture events
            if (msg != User32.WM_GESTURE)
                return 0;

            GESTUREINFO gestureInfo = new GESTUREINFO
            {
                cbSize = (uint)Marshal.SizeOf(typeof(GESTUREINFO))
            };

            bool result = User32.GetGestureInfo(lParam, ref gestureInfo);

            if (!result)
                throw new Exception("Cannot get gesture information");

            //Decode the gesture info and get the message event argument
            GestureEventArgs eventArgs = new GestureEventArgs(this, ref gestureInfo);
            try
            {
                //Fire the event using the event map
                _eventMap[MapWM2EventId(gestureInfo.dwID, gestureInfo.dwFlags)].Invoke(this, eventArgs);
            }
            catch (ArgumentOutOfRangeException) //In case future releases will introduce new event values
            {
            }

            //Keep the last message for relative calculations
            LastEvent = eventArgs;

            //Keep the first message for relative calculations
            if (eventArgs.IsBegin)
                LastBeginEvent = eventArgs;

            User32.CloseGestureInfoHandle(lParam);

            return 1;
        }
예제 #3
0
 private void ProcessRollOver(object sender, GestureEventArgs args)
 {
     if (_image.Effect == _dropShadow)
     {
         _image.Effect = null;
     }
     else
     {
         _image.Effect = _dropShadow;
     }
 }
예제 #4
0
 private void ProcessRotate(object sender, GestureEventArgs args)
 {
     _rotate.Angle -= args.RotateAngle * 180 / Math.PI;
 }
예제 #5
0
 private void ProcessPan(object sender, GestureEventArgs args)
 {
     _translate.X += args.PanTranslation.Width;
     _translate.Y += args.PanTranslation.Height;
 }
예제 #6
0
 private void ProcessZoom(object sender, GestureEventArgs args)
 {
     _scale.ScaleX *= args.ZoomFactor;
     _scale.ScaleY *= args.ZoomFactor;
 }
예제 #7
0
 private void ProcessTwoFingerTap(object sender, GestureEventArgs args)
 {
     if (_image.Effect == _blur)
     {
         _image.Effect = null;
     }
     else
     {
         _image.Effect = _blur;
     }
 }
예제 #8
0
 private void ProcessZoom(object sender, GestureEventArgs args)
 {
     _rect.Zoom(args.ZoomFactor, args.Center);
     Invalidate();
 }
예제 #9
0
 private void ProcessTwoFingerTap(object sender, GestureEventArgs args)
 {
     _rect.TogleDrawDiagonals();
     Invalidate();
 }
예제 #10
0
 private void ProcessRollOver(object sender, GestureEventArgs args)
 {
     _rect.ShiftColor();
     Invalidate();
 }
예제 #11
0
 private void ProcessRotate(object sender, GestureEventArgs args)
 {
     _rect.Rotate(args.RotateAngle, args.Center);
     Invalidate();
 }
예제 #12
0
 private void ProcessPan(object sender, GestureEventArgs args)
 {
     _rect.Move(args.PanTranslation);
     //Text = String.Format("{0}", args.DistanceBetweenFingers);
     Invalidate();
 }