Esempio n. 1
0
        public void Evaluate(int spreadMax)
        {
            var notifications = FEnumerator.MoveNext()
                ? FEnumerator.Current
                : FEmptyList;

            GestureTypeOut.SliceCount = notifications.Count;
            PositionOut.SliceCount    = notifications.Count;
            PositionInProjectionSpaceOut.SliceCount      = notifications.Count;
            PositionInNormalizedProjectionOut.SliceCount = notifications.Count;
            PositionPixelOut.SliceCount = notifications.Count;
            IdOut.SliceCount            = notifications.Count;
            DeviceIDOut.SliceCount      = notifications.Count;
            for (int i = 0; i < notifications.Count; i++)
            {
                var n = notifications[i];
                GestureTypeOut[i] = n.Kind;

                Vector2D inNormalizedProjection, inProjection;

                SpaceHelpers.MapFromPixels(n.Position, n.Sender, n.ClientArea,
                                           out inNormalizedProjection, out inProjection);

                PositionOut[i] = MouseExtensions.GetLegacyMousePositon(n.Position, n.ClientArea);
                PositionInProjectionSpaceOut[i]      = inProjection;
                PositionInNormalizedProjectionOut[i] = inNormalizedProjection;
                PositionPixelOut[i] = new Vector2D(n.Position.X, n.Position.Y);

                IdOut[i]       = n.Id;
                DeviceIDOut[i] = n.GestureDeviceID;
            }
        }
Esempio n. 2
0
        public void Evaluate(int spreadMax)
        {
            var touchDevice = FInput[0] ?? TouchDevice.Empty;

            if (touchDevice != FTouchDevice)
            {
                Unsubscribe();
                FTouchDevice = touchDevice;
                Subscribe();
            }

            var notifications = FEnumerator.MoveNext()
                ? FEnumerator.Current
                : FEmptyList;

            FEventTypeOut.SliceCount                     = notifications.Count;
            PositionPixelOut.SliceCount                  = notifications.Count;
            PositionInProjectionSpaceOut.SliceCount      = notifications.Count;
            PositionInNormalizedProjectionOut.SliceCount = notifications.Count;
            PositionOut.SliceCount    = notifications.Count;
            IdOut.SliceCount          = notifications.Count;
            PrimaryOut.SliceCount     = notifications.Count;
            ContactAreaOut.SliceCount = notifications.Count;
            DeviceIDOut.SliceCount    = notifications.Count;

            for (int i = 0; i < notifications.Count; i++)
            {
                var n = notifications[i];
                FEventTypeOut[i] = n.Kind;
                Vector2D inNormalizedProjection, inProjection;

                SpaceHelpers.MapFromPixels(n.Position, n.Sender, n.ClientArea,
                                           out inNormalizedProjection, out inProjection);

                PositionOut[i] = MouseExtensions.GetLegacyMousePositon(n.Position, n.ClientArea);
                PositionInProjectionSpaceOut[i]      = inProjection;
                PositionInNormalizedProjectionOut[i] = inNormalizedProjection;

                PositionPixelOut[i] = new Vector2D(n.Position.X, n.Position.Y);
                IdOut[i]            = n.Id;
                PrimaryOut[i]       = n.Primary;
                ContactAreaOut[i]   = new Vector2D(n.ContactArea.Width, n.ContactArea.Height);
                DeviceIDOut[i]      = n.TouchDeviceID;
            }
        }
Esempio n. 3
0
        public void Evaluate(int spreadMax)
        {
            var gestureDevice = FInput[0] ?? GestureDevice.Empty;

            if (gestureDevice != FGestureDevice)
            {
                Unsubscribe();
                FGestureDevice = gestureDevice;
                Subscribe();
            }

            var notifications = FEnumerator.MoveNext()
                ? FEnumerator.Current
                : FEmptyList;

            var gestures = notifications.Where(g => (g.Kind == FGestureFilterKind) ||
                                               ((g.Kind == GestureNotificationKind.GestureEnd) && (IdOut.Contains(g.Id))))
                           .ToList();

            UseGestures(gestures);

            PositionOut.SliceCount = gestures.Count;
            PositionInProjectionSpaceOut.SliceCount      = gestures.Count;
            PositionInNormalizedProjectionOut.SliceCount = gestures.Count;
            PositionPixelOut.SliceCount = gestures.Count;
            IdOut.SliceCount            = gestures.Count;
            DeviceIDOut.SliceCount      = gestures.Count;
            for (int i = 0; i < gestures.Count; i++)
            {
                var      g = gestures[i];
                Vector2D inNormalizedProjection, inProjection;

                SpaceHelpers.MapFromPixels(g.Position, g.Sender, g.ClientArea,
                                           out inNormalizedProjection, out inProjection);

                PositionOut[i] = MouseExtensions.GetLegacyMousePositon(g.Position, g.ClientArea);
                PositionInProjectionSpaceOut[i]      = inProjection;
                PositionInNormalizedProjectionOut[i] = inNormalizedProjection;
                PositionPixelOut[i] = new Vector2D(g.Position.X, g.Position.Y);

                IdOut[i]       = g.Id;
                DeviceIDOut[i] = g.GestureDeviceID;
            }
        }
Esempio n. 4
0
        public virtual void OnImportsSatisfied()
        {
            FGestureFilterKind = SetGestureKindFilter();

            PositionPixelOut.SliceCount                  = 0;
            PositionInProjectionSpaceOut.SliceCount      = 0;
            PositionInNormalizedProjectionOut.SliceCount = 0;
            PositionOut.SliceCount = 0;
            IdOut.SliceCount       = 0;
            DeviceIDOut.SliceCount = 0;

            FSubscription = new Subscription <GestureDevice, GestureNotification>(
                gestureDevice =>
            {
                return(gestureDevice.Notifications.Where(g => (g.Kind == FGestureFilterKind) || (g.Kind == GestureNotificationKind.GestureEnd)));
            },
                (gestureDevice, g) =>
            {
                var index         = IdOut.IndexOf(g.Id);
                var isFilterMatch = g.Kind == FGestureFilterKind;
                UseGesture(g, isFilterMatch, index);
                if (isFilterMatch)
                {
                    Vector2D inNormalizedProjection, inProjection;
                    SpaceHelpers.MapFromPixels(g.Position, g.Sender, g.ClientArea,
                                               out inNormalizedProjection, out inProjection);
                    var normalizedPosition = MouseExtensions.GetLegacyMousePositon(g.Position, g.ClientArea);
                    var inPixels           = new Vector2D(g.Position.X, g.Position.Y);

                    if (index < 0)
                    {
                        PositionPixelOut.Add(inPixels);
                        PositionInProjectionSpaceOut.Add(inProjection);
                        PositionInNormalizedProjectionOut.Add(inNormalizedProjection);
                        PositionOut.Add(normalizedPosition);

                        IdOut.Add(g.Id);
                        DeviceIDOut.Add(g.GestureDeviceID);
                    }
                    else
                    {
                        PositionPixelOut[index]                  = inPixels;
                        PositionInProjectionSpaceOut[index]      = inProjection;
                        PositionInNormalizedProjectionOut[index] = inNormalizedProjection;
                        PositionOut[index] = normalizedPosition;
                        IdOut[index]       = g.Id;
                        DeviceIDOut[index] = g.GestureDeviceID;
                    }
                }
                else if (index >= 0)
                {
                    PositionPixelOut.RemoveAt(index);
                    PositionInProjectionSpaceOut.RemoveAt(index);
                    PositionInNormalizedProjectionOut.RemoveAt(index);
                    PositionOut.RemoveAt(index);
                    IdOut.RemoveAt(index);
                    DeviceIDOut.RemoveAt(index);
                }
            },
                FScheduler
                );
        }
Esempio n. 5
0
        public void OnImportsSatisfied()
        {
            PositionPixelOut.SliceCount                  = 0;
            PositionInProjectionSpaceOut.SliceCount      = 0;
            PositionInNormalizedProjectionOut.SliceCount = 0;
            PositionOut.SliceCount    = 0;
            IdOut.SliceCount          = 0;
            PrimaryOut.SliceCount     = 0;
            ContactAreaOut.SliceCount = 0;
            IsNewOut.SliceCount       = 0;
            DeviceIDOut.SliceCount    = 0;

            FSubscription = new Subscription <TouchDevice, TouchNotification>(
                touchDevice =>
            {
                return(touchDevice.Notifications);
            },
                (touchDevice, n) =>
            {
                Vector2D inNormalizedProjection, inProjection;
                SpaceHelpers.MapFromPixels(n.Position, n.Sender, n.ClientArea,
                                           out inNormalizedProjection, out inProjection);
                var normalizedPosition = MouseExtensions.GetLegacyMousePositon(n.Position, n.ClientArea);
                var inPixels           = new Vector2D(n.Position.X, n.Position.Y);

                var contactArea = new Vector2D(n.ContactArea.Width, n.ContactArea.Height);
                var index       = IdOut.IndexOf(n.Id);
                var primary     = n.Primary;
                var deviceid    = n.TouchDeviceID;
                switch (n.Kind)
                {
                case TouchNotificationKind.TouchDown:
                    if (index < 0)
                    {
                        IdOut.Add(n.Id);
                        PositionPixelOut.Add(inPixels);
                        PositionInProjectionSpaceOut.Add(inProjection);
                        PositionInNormalizedProjectionOut.Add(inNormalizedProjection);
                        PositionOut.Add(normalizedPosition);
                        PrimaryOut.Add(primary);
                        ContactAreaOut.Add(contactArea);
                        IsNewOut.Add(true);
                        DeviceIDOut.Add(deviceid);
                    }
                    break;

                case TouchNotificationKind.TouchUp:
                    if (index >= 0)
                    {
                        IdOut.RemoveAt(index);
                        PositionPixelOut.RemoveAt(index);
                        PositionInProjectionSpaceOut.RemoveAt(index);
                        PositionInNormalizedProjectionOut.RemoveAt(index);
                        PositionOut.RemoveAt(index);
                        PrimaryOut.RemoveAt(index);
                        ContactAreaOut.RemoveAt(index);
                        IsNewOut.RemoveAt(index);
                        DeviceIDOut.RemoveAt(index);
                    }
                    break;

                case TouchNotificationKind.TouchMove:
                    if (index >= 0)
                    {
                        PositionPixelOut[index]                  = inPixels;
                        PositionInProjectionSpaceOut[index]      = inProjection;
                        PositionInNormalizedProjectionOut[index] = inNormalizedProjection;
                        PositionOut[index]    = normalizedPosition;
                        PrimaryOut[index]     = primary;
                        ContactAreaOut[index] = contactArea;
                        IsNewOut[index]       = false;
                    }
                    break;

                default:
                    throw new NotImplementedException();
                }
            },
                FScheduler
                );
        }