Пример #1
0
        public void OnImportsSatisfied()
        {
            PositionOut.SliceCount    = 0;
            IdOut.SliceCount          = 0;
            ContactAreaOut.SliceCount = 0;
            IsNewOut.SliceCount       = 0;
            FSubscription             = new Subscription <TouchDevice, TouchNotification>(
                touchDevice =>
            {
                return(touchDevice.Notifications);
            },
                (touchDevice, n) =>
            {
                var position           = new Vector2D(n.Position.X, n.Position.Y);
                var clientArea         = new Vector2D(n.ClientArea.Width, n.ClientArea.Height);
                var normalizedPosition = VMath.Map(position, Vector2D.Zero, clientArea, new Vector2D(-1, 1), new Vector2D(1, -1), TMapMode.Float);
                var contactArea        = new Vector2D(n.ContactArea.Width, n.ContactArea.Height);
                var index = IdOut.IndexOf(n.Id);
                switch (n.Kind)
                {
                case TouchNotificationKind.TouchDown:
                    if (index < 0)
                    {
                        IdOut.Add(n.Id);
                        PositionOut.Add(normalizedPosition);
                        ContactAreaOut.Add(contactArea);
                        IsNewOut.Add(true);
                    }
                    break;

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

                case TouchNotificationKind.TouchMove:
                    if (index >= 0)
                    {
                        PositionOut[index]    = normalizedPosition;
                        ContactAreaOut[index] = contactArea;
                        IsNewOut[index]       = false;
                    }
                    break;

                default:
                    throw new NotImplementedException();
                }
            },
                FScheduler
                );
        }
Пример #2
0
        public virtual void OnImportsSatisfied()
        {
            FGestureFilterKind = SetGestureKindFilter();

            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)
                {
                    var position           = new Vector2D(g.Position.X, g.Position.Y);
                    var clientArea         = new Vector2D(g.ClientArea.Width, g.ClientArea.Height);
                    var normalizedPosition = VMath.Map(position, Vector2D.Zero, clientArea, new Vector2D(-1, 1), new Vector2D(1, -1), TMapMode.Float);

                    if (index < 0)
                    {
                        PositionOut.Add(normalizedPosition);
                        IdOut.Add(g.Id);
                        DeviceIDOut.Add(g.GestureDeviceID);
                    }
                    else
                    {
                        PositionOut[index] = normalizedPosition;
                        IdOut[index]       = g.Id;
                        DeviceIDOut[index] = g.GestureDeviceID;
                    }
                }
                else if (index >= 0)
                {
                    PositionOut.RemoveAt(index);
                    IdOut.RemoveAt(index);
                    DeviceIDOut.RemoveAt(index);
                }
            },
                FScheduler
                );
        }
Пример #3
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
                );
        }
Пример #4
0
 protected virtual int Index(ISpread <T> spread, T item)
 {
     return(spread.IndexOf(item));
 }
Пример #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
                );
        }