Exemple #1
0
        public BackgroundTouch(TouchForm tForm) : base()
        {
            touchForm = tForm;

            Win32TouchFunctions.INTERACTION_CONTEXT_CONFIGURATION[] cfg = new Win32TouchFunctions.INTERACTION_CONTEXT_CONFIGURATION[]
            {
                new Win32TouchFunctions.INTERACTION_CONTEXT_CONFIGURATION(Win32TouchFunctions.INTERACTION.TAP,
                                                                          Win32TouchFunctions.INTERACTION_CONFIGURATION_FLAGS.TAP |
                                                                          Win32TouchFunctions.INTERACTION_CONFIGURATION_FLAGS.TAP_DOUBLE),

                new Win32TouchFunctions.INTERACTION_CONTEXT_CONFIGURATION(Win32TouchFunctions.INTERACTION.SECONDARY_TAP,
                                                                          Win32TouchFunctions.INTERACTION_CONFIGURATION_FLAGS.SECONDARY_TAP),

                new Win32TouchFunctions.INTERACTION_CONTEXT_CONFIGURATION(Win32TouchFunctions.INTERACTION.HOLD,
                                                                          Win32TouchFunctions.INTERACTION_CONFIGURATION_FLAGS.HOLD),

                new Win32TouchFunctions.INTERACTION_CONTEXT_CONFIGURATION(Win32TouchFunctions.INTERACTION.MANIPULATION,
                                                                          Win32TouchFunctions.INTERACTION_CONFIGURATION_FLAGS.MANIPULATION |
                                                                          Win32TouchFunctions.INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_SCALING |
                                                                          Win32TouchFunctions.INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_TRANSLATION_X |
                                                                          Win32TouchFunctions.INTERACTION_CONFIGURATION_FLAGS.MANIPULATION_TRANSLATION_Y)
            };

            Win32TouchFunctions.SetInteractionConfigurationInteractionContext(Context, cfg.Length, cfg);
        }
Exemple #2
0
 public void StopProcessing()
 {
     foreach (int pointerID in _activePointers)
     {
         Win32TouchFunctions.RemovePointerInteractionContext(_context, pointerID);
     }
     _activePointers.Clear();
     Win32TouchFunctions.StopInteractionContext(_context);
 }
Exemple #3
0
 public void ProcessPointerFrames(int pointerID, int frameID)
 {
     if (_lastFrameID != frameID)
     {
         _lastFrameID = frameID;
         int entriesCount = 0;
         int pointerCount = 0;
         if (!Win32TouchFunctions.GetPointerFrameInfoHistory(pointerID, ref entriesCount, ref pointerCount, IntPtr.Zero))
         {
             Win32TouchFunctions.CheckLastError();
         }
         Win32TouchFunctions.POINTER_INFO[] piArr = new Win32TouchFunctions.POINTER_INFO[entriesCount * pointerCount];
         if (!Win32TouchFunctions.GetPointerFrameInfoHistory(pointerID, ref entriesCount, ref pointerCount, piArr))
         {
             Win32TouchFunctions.CheckLastError();
         }
         IntPtr hr = Win32TouchFunctions.ProcessPointerFramesInteractionContext(_context, entriesCount, pointerCount, piArr);
         if (Win32TouchFunctions.FAILED(hr))
         {
             Debug.WriteLine("ProcessPointerFrames failed: " + Win32TouchFunctions.GetMessageForHR(hr));
         }
     }
 }
Exemple #4
0
 public void RemovePointer(int pointerID)
 {
     Win32TouchFunctions.RemovePointerInteractionContext(_context, pointerID);
     _activePointers.Remove(pointerID);
 }
Exemple #5
0
 public void AddPointer(int pointerID)
 {
     Win32TouchFunctions.AddPointerInteractionContext(_context, pointerID);
     _activePointers.Add(pointerID);
 }
Exemple #6
0
 public void Dispose()
 {
     Win32TouchFunctions.DisposeInteractionContext(_context);
     _context = IntPtr.Zero;
 }
Exemple #7
0
        public BaseTouchHandler()
        {
            _context = Win32TouchFunctions.CreateInteractionContext(this, SynchronizationContext.Current);

            //Win32.SetPropertyInteractionContext(Context, Win32.INTERACTION_CONTEXT_PROPERTY.FILTER_POINTERS, Win32.ICP_FILTER_POINTERS_ON);
        }
Exemple #8
0
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case Win32TouchFunctions.WM_POINTERDOWN:
            case Win32TouchFunctions.WM_POINTERUP:
            case Win32TouchFunctions.WM_POINTERUPDATE:
            case Win32TouchFunctions.WM_POINTERCAPTURECHANGED:
                break;

            default:
                base.WndProc(ref m);
                return;
            }
            int pointerID = Win32TouchFunctions.GET_POINTER_ID(m.WParam);

            Win32TouchFunctions.POINTER_INFO pi = new Win32TouchFunctions.POINTER_INFO();
            if (!Win32TouchFunctions.GetPointerInfo(pointerID, ref pi))
            {
                Win32TouchFunctions.CheckLastError();
            }
            switch (m.Msg)
            {
            case Win32TouchFunctions.WM_POINTERDOWN:
            {
                if ((pi.PointerFlags & Win32TouchFunctions.POINTER_FLAGS.PRIMARY) != 0)
                {
                    this.Capture = true;
                }
                Point pt = PointToClient(pi.PtPixelLocation.ToPoint());

                background.AddPointer(pointerID);
                background.ProcessPointerFrames(pointerID, pi.FrameID);
            }
            break;

            case Win32TouchFunctions.WM_POINTERUP:

                if ((pi.PointerFlags & Win32TouchFunctions.POINTER_FLAGS.PRIMARY) != 0)
                {
                    this.Capture = false;
                }

                if (background.ActivePointers.Contains(pointerID))
                {
                    background.ProcessPointerFrames(pointerID, pi.FrameID);
                    background.RemovePointer(pointerID);
                }
                break;

            case Win32TouchFunctions.WM_POINTERUPDATE:

                if (background.ActivePointers.Contains(pointerID))
                {
                    background.ProcessPointerFrames(pointerID, pi.FrameID);
                }
                break;

            case Win32TouchFunctions.WM_POINTERCAPTURECHANGED:

                this.Capture = false;

                if (background.ActivePointers.Contains(pointerID))
                {
                    background.StopProcessing();
                }
                break;
            }
            m.Result = IntPtr.Zero;
        }
Exemple #9
0
        public TouchForm() : base()
        {
            Win32TouchFunctions.EnableMouseInPointer(false);

            background = new BackgroundTouch(this);
        }
Exemple #10
0
        protected override void WndProc(ref Message m)
        {
            try {
                switch (m.Msg)
                {
                case Win32TouchFunctions.WM_POINTERDOWN:
                case Win32TouchFunctions.WM_POINTERUP:
                case Win32TouchFunctions.WM_POINTERUPDATE:
                case Win32TouchFunctions.WM_POINTERCAPTURECHANGED:
                    break;

                default:
                    base.WndProc(ref m);
                    return;
                }

                int pointerID = Win32TouchFunctions.GET_POINTER_ID(m.WParam);

                Win32TouchFunctions.POINTER_INFO pi = new Win32TouchFunctions.POINTER_INFO();
                if (!Win32TouchFunctions.GetPointerInfo(pointerID, ref pi))
                {
                    Win32TouchFunctions.CheckLastError();
                }

                DrawPoint pt = PointToClient(pi.PtPixelLocation.ToPoint());

                switch (m.Msg)
                {
                case Win32TouchFunctions.WM_POINTERDOWN:
                {
                    if ((pi.PointerFlags & Win32TouchFunctions.POINTER_FLAGS.PRIMARY) != 0)
                    {
                        this.Capture = true;
                    }

                    var pointerDown = PointerDown;
                    if (pointerDown != null)
                    {
                        pointerDown(new object(), new TouchEventArgs(pointerID, new Point(pt.X, pt.Y)));
                    }
                }
                break;

                case Win32TouchFunctions.WM_POINTERUP:

                    if ((pi.PointerFlags & Win32TouchFunctions.POINTER_FLAGS.PRIMARY) != 0)
                    {
                        this.Capture = false;
                    }

                    var pointerUp = PointerUp;
                    if (pointerUp != null)
                    {
                        pointerUp(new object(), new TouchEventArgs(pointerID, new Point(pt.X, pt.Y)));
                    }

                    break;

                case Win32TouchFunctions.WM_POINTERUPDATE:

                    var pointerUpdate = PointerUpdate;
                    if (pointerUpdate != null)
                    {
                        pointerUpdate(new object(), new TouchEventArgs(pointerID, new Point(pt.X, pt.Y)));
                    }

                    break;

                case Win32TouchFunctions.WM_POINTERCAPTURECHANGED:

                    this.Capture = false;

                    var pointerLostCapture = PointerLostCapture;
                    if (pointerLostCapture != null)
                    {
                        pointerLostCapture(new object(), new TouchEventArgs(pointerID, new Point(pt.X, pt.Y)));
                    }

                    break;
                }
                m.Result = IntPtr.Zero;
            }
            catch (Exception e) {
                Log.Warning(e.Message);
            }
        }
Exemple #11
0
 public TouchForm() : base()
 {
     Win32TouchFunctions.EnableMouseInPointer(false);
 }