Exemplo n.º 1
0
        public void processEventFrame(Provider.FrameEventArgs e)
        {
            foreach (WiiContact contact in e.Contacts)
            {
                Color color = Color.Blue;
                switch (contact.Type)
                {
                case ContactType.Start:
                    color = Color.Green;
                    break;

                case ContactType.Move:
                    color = Color.Yellow;
                    break;

                case ContactType.End:
                    color = Color.Red;
                    break;
                }

                Brush brush = new SolidBrush(color);
                graphic.DrawEllipse(Pens.Black, (float)contact.Position.X - 10, (float)contact.Position.Y - 10, 20, 20);
                graphic.FillEllipse(brush, (float)contact.Position.X - 10, (float)contact.Position.Y - 10, 20, 20);
            }
        }
        public void processEventFrame(Provider.FrameEventArgs e)
        {
            touchscreenMutex.WaitOne();
            List <PointerTouchInfo> toFire = new List <PointerTouchInfo>();

            foreach (WiiContact contact in e.Contacts)
            {
                if (Settings.Default.pointer_customCursor && (contact.Type == ContactType.Hover || contact.Type == ContactType.EndFromHover))
                {
                    //If we are using the custom cursor and it's more than 1 touchpoints, we skip the hovering because otherwise it's not working with edge guestures for example.
                }
                else
                {
                    ContactType type = contact.Type;

                    if (Settings.Default.pointer_customCursor && (contact.Type == ContactType.EndToHover))
                    {
                        type = ContactType.End;
                    }

                    PointerTouchInfo touch = new PointerTouchInfo();
                    touch.PointerInfo.pointerType = PointerInputType.TOUCH;
                    touch.TouchFlags = TouchFlags.NONE;
                    //contact.Orientation = (uint)cur.getAngleDegrees();//this is only valid for TuioObjects
                    touch.Pressure   = 0;
                    touch.TouchMasks = TouchMask.NONE;
                    touch.PointerInfo.PtPixelLocation.X = (int)contact.Position.X;
                    touch.PointerInfo.PtPixelLocation.Y = (int)contact.Position.Y;
                    touch.PointerInfo.PointerId         = (uint)contact.ID;
                    touch.PointerInfo.PerformanceCount  = e.Timestamp;

                    if (type == ContactType.Start)
                    {
                        touch.PointerInfo.PointerFlags = PointerFlags.DOWN | PointerFlags.INRANGE | PointerFlags.INCONTACT;
                    }
                    else if (type == ContactType.Move)
                    {
                        touch.PointerInfo.PointerFlags = PointerFlags.UPDATE | PointerFlags.INRANGE | PointerFlags.INCONTACT;
                    }
                    else if (type == ContactType.End)
                    {
                        touch.PointerInfo.PointerFlags = PointerFlags.UP;
                    }
                    else if (type == ContactType.EndToHover)
                    {
                        touch.PointerInfo.PointerFlags = PointerFlags.UP | PointerFlags.INRANGE;
                    }
                    else if (type == ContactType.Hover)
                    {
                        touch.PointerInfo.PointerFlags = PointerFlags.UPDATE | PointerFlags.INRANGE;
                    }
                    else if (type == ContactType.EndFromHover)
                    {
                        touch.PointerInfo.PointerFlags = PointerFlags.UPDATE;
                    }

                    toFire.Add(touch);
                }
            }
            //fire the events
            if (toFire.Count > 0)
            {
                if (!TCD.System.TouchInjection.TouchInjector.InjectTouchInput(toFire.Count, toFire.ToArray()))
                {
                    Console.WriteLine("Could not send touch input, count " + toFire.Count);
                }
            }
            touchscreenMutex.ReleaseMutex();
        }
 public void processEventFrame(Provider.FrameEventArgs e)
 {
     this.TUIOHandler.processEventFrame(e);
 }