GET_POINTER_ID() static private method

static private GET_POINTER_ID ( IntPtr wParam ) : int
wParam System.IntPtr
return int
コード例 #1
0
ファイル: TouchForm.cs プロジェクト: nkast/FusionFramework
        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;
        }
コード例 #2
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);
            }
        }