コード例 #1
0
 public void ProcessPointerFrames(int pointerID, int frameID)
 {
     if (_lastFrameID != frameID)
     {
         _lastFrameID = frameID;
         int entriesCount = 0;
         int pointerCount = 0;
         if (!Win32.GetPointerFrameInfoHistory(pointerID, ref entriesCount, ref pointerCount, IntPtr.Zero))
         {
             Win32.CheckLastError();
         }
         Win32.POINTER_INFO[] piArr = new Win32.POINTER_INFO[entriesCount * pointerCount];
         if (!Win32.GetPointerFrameInfoHistory(pointerID, ref entriesCount, ref pointerCount, piArr))
         {
             Win32.CheckLastError();
         }
         IntPtr hr = Win32.ProcessPointerFramesInteractionContext(_context, entriesCount, pointerCount, piArr);
         if (Win32.FAILED(hr))
         {
             Debug.WriteLine("ProcessPointerFrames failed: " + Win32.GetMessageForHR(hr));
         }
     }
 }
コード例 #2
0
ファイル: BaseHandler.cs プロジェクト: andyhebear/Touch_Hook
 public void ProcessPointerFrames(int pointerID, int frameID)
 {
     if (_lastFrameID != frameID)
     {
         _lastFrameID = frameID;
         int entriesCount = 0;
         int pointerCount = 0;
         if (!Win32.GetPointerFrameInfoHistory(pointerID, ref entriesCount, ref pointerCount, IntPtr.Zero))
         {
             Win32.CheckLastError();
         }
         Win32.POINTER_INFO[] piArr = new Win32.POINTER_INFO[entriesCount * pointerCount];
         if (!Win32.GetPointerFrameInfoHistory(pointerID, ref entriesCount, ref pointerCount, piArr))
         {
             Win32.CheckLastError();
         }
         //System.Windows.Forms.MessageBox.Show(string.Format("ec:{0} pc:{1} piArr:{2}",entriesCount,pointerCount,piArr.Length));
         IntPtr hr = Win32.ProcessPointerFramesInteractionContext(_context, (UInt32)entriesCount, (UInt32)pointerCount, piArr);
         if (Win32.FAILED(hr))
         {
             Debug.WriteLine("ProcessPointerFrames failed: " + Win32.GetMessageForHR(hr));
         }
     }
 }
コード例 #3
0
ファイル: TouchForm.cs プロジェクト: andyhebear/Touch_Hook
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case Win32.WM_POINTERDOWN:
            case Win32.WM_POINTERUP:
            case Win32.WM_POINTERUPDATE:
            case Win32.WM_POINTERCAPTURECHANGED:
                break;

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

            Win32.POINTER_INFO pi = new Win32.POINTER_INFO();
            if (!Win32.GetPointerInfo(pointerID, ref pi))
            {
                Win32.CheckLastError();
            }
            bool processed = false;

            switch (m.Msg)
            {
            case Win32.WM_POINTERDOWN:
            {
                if ((pi.PointerFlags & Win32.POINTER_FLAGS.PRIMARY) != 0)
                {
                    this.Capture = true;
                }
                Point pt = PointToClient(pi.PtPixelLocation.ToPoint());
                foreach (Figure f in _figures)
                {
                    if (f.HitTest(pt.X, pt.Y))
                    {
                        f.BringToFront();
                        f.AddPointer(pointerID);
                        f.ProcessPointerFrames(pointerID, pi.FrameID);
                        if (f.Pivot)
                        {
                            Point pt1 = Point.Ceiling(f.Points[0]);
                            Point pt0 = Point.Ceiling(f.Points[3]);
                            pt0.X = (pt0.X + pt1.X) / 2;
                            pt0.Y = (pt0.Y + pt1.Y) / 2;
                            pt0   = PointToScreen(pt0);
                            Win32.SetPivotInteractionContext(f.Context, pt0.X, pt0.Y, 0f);
                        }
                        processed = true;
                        break;
                    }
                }
                if (!processed)
                {
                    _background.AddPointer(pointerID);
                    _background.ProcessPointerFrames(pointerID, pi.FrameID);
                }
            }
            break;

            case Win32.WM_POINTERUP:

                if ((pi.PointerFlags & Win32.POINTER_FLAGS.PRIMARY) != 0)
                {
                    this.Capture = false;
                }
                foreach (Figure f in _figures)
                {
                    if (f.ActivePointers.Contains(pointerID))
                    {
                        f.ProcessPointerFrames(pointerID, pi.FrameID);
                        f.RemovePointer(pointerID);
                        processed = true;
                        break;
                    }
                }
                if (!processed && _background.ActivePointers.Contains(pointerID))
                {
                    _background.ProcessPointerFrames(pointerID, pi.FrameID);
                    _background.RemovePointer(pointerID);
                }
                break;

            case Win32.WM_POINTERUPDATE:

                foreach (Figure f in _figures)
                {
                    if (f.ActivePointers.Contains(pointerID))
                    {
                        f.ProcessPointerFrames(pointerID, pi.FrameID);
                        processed = true;
                        break;
                    }
                }
                if (!processed && _background.ActivePointers.Contains(pointerID))
                {
                    _background.ProcessPointerFrames(pointerID, pi.FrameID);
                }
                break;

            case Win32.WM_POINTERCAPTURECHANGED:

                this.Capture = false;
                foreach (Figure f in _figures)
                {
                    if (f.ActivePointers.Contains(pointerID))
                    {
                        f.StopProcessing();
                        processed = true;
                        break;
                    }
                }
                if (!processed && _background.ActivePointers.Contains(pointerID))
                {
                    _background.StopProcessing();
                }
                break;
            }
            m.Result = IntPtr.Zero;
        }