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; }
private void ProcessRollOver(object sender, GestureEventArgs args) { if (_image.Effect == _dropShadow) { _image.Effect = null; } else { _image.Effect = _dropShadow; } }
private void ProcessRotate(object sender, GestureEventArgs args) { _rotate.Angle -= args.RotateAngle * 180 / Math.PI; }
private void ProcessPan(object sender, GestureEventArgs args) { _translate.X += args.PanTranslation.Width; _translate.Y += args.PanTranslation.Height; }
private void ProcessZoom(object sender, GestureEventArgs args) { _scale.ScaleX *= args.ZoomFactor; _scale.ScaleY *= args.ZoomFactor; }
private void ProcessTwoFingerTap(object sender, GestureEventArgs args) { if (_image.Effect == _blur) { _image.Effect = null; } else { _image.Effect = _blur; } }
private void ProcessZoom(object sender, GestureEventArgs args) { _rect.Zoom(args.ZoomFactor, args.Center); Invalidate(); }
private void ProcessTwoFingerTap(object sender, GestureEventArgs args) { _rect.TogleDrawDiagonals(); Invalidate(); }
private void ProcessRollOver(object sender, GestureEventArgs args) { _rect.ShiftColor(); Invalidate(); }
private void ProcessRotate(object sender, GestureEventArgs args) { _rect.Rotate(args.RotateAngle, args.Center); Invalidate(); }
private void ProcessPan(object sender, GestureEventArgs args) { _rect.Move(args.PanTranslation); //Text = String.Format("{0}", args.DistanceBetweenFingers); Invalidate(); }