示例#1
0
        public TouchPoint[] GetTouches()
        {
            int number_of_touches = (new Random().Next() % 10);

            TouchPoint[] touches = null;

            if (number_of_touches > 0)
            {
                touches = new TouchPoint[number_of_touches];

                Random randomPosition = new Random();

                while (--number_of_touches > 0)
                {
                    touches[number_of_touches] = new TouchPoint {
                        x = randomPosition.NextDouble(),
                        y = randomPosition.NextDouble()
                    };
                }
            }

            return(touches);
        }
示例#2
0
        /* Pre:
         * Simulation : process touch screen for interacting with interface of app
         */
        public void Visit(Touchscreen ts)
        {
            if (ts == null)
            {
                return;
            }

            TouchPoint[] points  = ts.GetTouches();
            int          index   = points.Length;
            TouchPoint   average = new TouchPoint {
                x = 0, y = 0
            };

            while (--index > 0)
            {
                average.x += points[index].x;
                average.y += points[index].y;
            }
            average.x /= points.Length;
            average.y /= points.Length;

            MessageBox.Show("Mobile app: Average point position: { x = " + average.x + ", y = " + average.y + " } of " + points.Length + " points");
        }