//Decode the gesture private void DecodeGesture(IHwndWrapper hWndWrapper, ref GESTUREINFO gestureInfo) { Location = hWndWrapper.PointToClient(new Point(gestureInfo.ptsLocation.x, gestureInfo.ptsLocation.y)); Center = Location; switch (GestureId) { case User32.GID_ROTATE: ushort lastArguments = (ushort)(IsBegin ? 0 : LastEvent.GestureArguments); RotateAngle = User32.GID_ROTATE_ANGLE_FROM_ARGUMENT((ushort)(gestureInfo.ullArguments - lastArguments)); break; case User32.GID_ZOOM: Point first = IsBegin ? Location : LastBeginEvent.Location; Center = new Point((Location.X + first.X) / 2, (Location.Y + first.Y) / 2); ZoomFactor = IsBegin ? 1 : (double)gestureInfo.ullArguments / LastEvent.GestureArguments; //DistanceBetweenFingers = User32.LoDWord(gestureInfo.ullArguments); break; case User32.GID_PAN: PanTranslation = IsBegin ? new Size(0, 0) : new Size(Location.X - LastEvent.Location.X, Location.Y - LastEvent.Location.Y); int panVelocity = User32.HiDWord((long)(gestureInfo.ullArguments)); PanVelocity = new Size(User32.LoWord(panVelocity), User32.HiWord(panVelocity)); //DistanceBetweenFingers = User32.LoDWord(gestureInfo.ullArguments); break; } }
/// <summary> /// Create new touch event argument instance /// </summary> /// <param name="hWndWrapper">The target control</param> /// <param name="touchInput">one of the inner touch input in the message</param> internal TouchEventArgs(IHwndWrapper hWndWrapper, float dpiX, float dpiY, ref TOUCHINPUT touchInput) { _hWndWrapper = hWndWrapper; _dpiXFactor = 96F / dpiX; _dpiYFactor = 96F / dpiY; DecodeTouch(ref touchInput); }
/// <summary> /// Create new touch event argument instance /// </summary> /// <param name="hWndWrapper">The target control</param> /// <param name="touchInput">one of the inner touch input in the message</param> internal TouchEventArgs(IHwndWrapper hWndWrapper, float dpiX, float dpiY, ref TOUCHINPUT touchInput) { _hWndWrapper = hWndWrapper; _dpiXFactor = 96F / dpiX; _dpiYFactor = 96F / dpiY; DecodeTouch(ref touchInput); }
/// <summary> /// Create new touch event argument instance /// </summary> /// <param name="hWndWrapper">The target control</param> /// <param name="touchInput">one of the inner touch input in the message</param> internal TouchEventArgs(IHwndWrapper hWndWrapper, float dpiX, float dpiY, ref TOUCHINPUT touchInput) { //need to change according to device _hWndWrapper = hWndWrapper; _dpiXFactor = dpiX / dpiX;//120F / dpiX; _dpiYFactor = dpiY / dpiY;//120F / dpiY; DecodeTouch(ref touchInput); }
/// <summary> /// We create the hanlder using a factory method. /// </summary> /// <param name="hWndWrapper">The control or Window that registered for touch/gesture events</param> internal Handler(IHwndWrapper hWndWrapper) { _hWndWrapper = hWndWrapper; if (_hWndWrapper.IsHandleCreated) { Initialize(); } else { _hWndWrapper.HandleCreated += (s, e) => Initialize(); } }
internal static T CreateHandler <T>(IHwndWrapper hWndWrapper) where T : Handler { if (_controlInUse.Contains(hWndWrapper.Source)) { throw new Exception("Only one handler can be registered for a control."); } hWndWrapper.HandleDestroyed += (s, e) => _controlInUse.Remove(s); _controlInUse.Add(hWndWrapper.Source); return(Activator.CreateInstance(typeof(T), BindingFlags.CreateInstance | BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.Instance, null, new object [] { hWndWrapper }, Thread.CurrentThread.CurrentCulture) as T); }
/// <summary> /// Construct a gesture handler instance /// </summary> /// <param name="hWndWrapper">The target control wrapper</param> internal GestureHandler(IHwndWrapper hWndWrapper) : base(hWndWrapper) { }
//Decode the gesture private void DecodeGesture(IHwndWrapper hWndWrapper, ref GESTUREINFO gestureInfo) { Location = hWndWrapper.PointToClient(new Point(gestureInfo.ptsLocation.x, gestureInfo.ptsLocation.y)); Center = Location; switch (GestureId) { case User32.GID_ROTATE: ushort lastArguments = (ushort)(IsBegin ? 0 : LastEvent.GestureArguments); RotateAngle = User32.GID_ROTATE_ANGLE_FROM_ARGUMENT((ushort)(gestureInfo.ullArguments - lastArguments)); break; case User32.GID_ZOOM: Point first = IsBegin ? Location : LastBeginEvent.Location; Center = new Point((Location.X + first.X) / 2, (Location.Y + first.Y) / 2); ZoomFactor = IsBegin ? 1 : (double)gestureInfo.ullArguments / LastEvent.GestureArguments; //DistanceBetweenFingers = User32.LoDWord(gestureInfo.ullArguments); break; case User32.GID_PAN: PanTranslation = IsBegin ? new Size(0, 0) : new Size(Location.X - LastEvent.Location.X, Location.Y - LastEvent.Location.Y); int panVelocity = User32.HiDWord((long)(gestureInfo.ullArguments)); PanVelocity = new Size(User32.LoWord(panVelocity), User32.HiWord(panVelocity)); //DistanceBetweenFingers = User32.LoDWord(gestureInfo.ullArguments); break; } }
/// <summary> /// Construct a gesture handler instance /// </summary> /// <param name="hWndWrapper">The target control wrapper</param> internal GestureHandler(IHwndWrapper hWndWrapper) : base(hWndWrapper) { }
public TouchHandler(IHwndWrapper hWndWrapper) : base(hWndWrapper) { }
internal TouchHandler(IHwndWrapper hWndWrapper) : base(hWndWrapper) { }
public TouchHandler(IHwndWrapper hWndWrapper) : base(hWndWrapper) { }
public static TouchHandler CreateTouchHandler(IHwndWrapper hWndWrapper) { if (ControlInUse.Contains(hWndWrapper.Source)) throw new Exception("Only one handler can be registered for a control."); //hWndWrapper.HandleDestroyed += (s, e) => ControlInUse.Remove(s); //_controlInUse.Add(hWndWrapper.Source); return new TouchHandler(hWndWrapper); }
/// <summary> /// We create the hanlder using a factory method. /// </summary> /// <param name="hWndWrapper">The control or Window that registered for touch/gesture events</param> internal TouchHandler(IHwndWrapper hWndWrapper) { _hWndWrapper = hWndWrapper; Initialize(); }
internal TouchHandler(IHwndWrapper hWndWrapper) : base(hWndWrapper) { }