Exemple #1
0
        private void TouchThread()
        {
            // These are used for the touch up event
            int lastX = 0;
            int lastY = 0;

            // These store the current X and Y
            int x = 0;
            int y = 0;

            // Keeps track of whether the panel was touched or not
            bool isTouched = false;

            // Create touch inputs that are used as arguments
            TouchInput[] touches = new TouchInput[] { new TouchInput() };

            // Begin touch panel polling
            while (_dragging)
            {
                //TODO:
            //                Microsoft.SPOT.Touch.TouchCollectorConfiguration.GetLastTouchPoint(ref x, ref y);

                if (x >= 0 && x <= Glide.LCD.Width && y >= 0 && y <= Glide.LCD.Height)
                {
                    if (isTouched == false)
                    {
                        // Touch down
                        touches[0].X = x;
                        touches[0].Y = y;
                        GlideTouch.RaiseTouchDownEvent(this, new TouchEventArgs(touches));

                        lastX = x;
                        lastY = y;
                        isTouched = true;
                    }
                    else
                    {
                        // Filter finger movements to avoid spamming
                        if (System.Math.Abs(x - lastX) > 2 || System.Math.Abs(y - lastY) > 2)
                        {
                            // Touch move
                            touches[0].X = x;
                            touches[0].Y = y;
                            GlideTouch.RaiseTouchMoveEvent(this, new TouchEventArgs(touches));

                            lastX = x;
                            lastY = y;
                        }
                    }
                }
                else
                {
                    if (isTouched == true)
                    {
                        // Touch up
                        touches[0].X = lastX;
                        touches[0].Y = lastY;
                        GlideTouch.RaiseTouchUpEvent(this, new TouchEventArgs(touches));

                        isTouched = false;
                    }
                }

                Thread.Sleep(30);
            }

            // Allow other threads to run so we dont get double touch events
            // once the message box closes.
            Thread.Sleep(0);

            GlideTouch.IgnoreAllEvents = false;
        }
Exemple #2
0
 public bool Contains(TouchInput input)
 {
     if(
         input.X >= this.X               &&
         input.X <  this.X + this.Width  &&
         input.Y >= this.Y               &&
         input.Y <  this.Y + this.Height
       )
     {
         return true;
     }
     return false;
 }
 public static extern void SetTouchInput(TouchInput flag, int param1, int param2, int param3);
 // Methods
 public TouchScreenEventArgs(DateTime timestamp, TouchInput[] touches, object target)
 {
     this.Touches = touches;
     this.TimeStamp = timestamp;
     this.Target = target;
 }
 public static extern void GetTouchInput(TouchInput flag, ref int param1, ref int param2, ref int param3);