Ejemplo n.º 1
0
        async Task OnPanning(PannedEventArgs args)
        {
            using (await AsyncLock.Lock())
            {
                if (CanDragX || CanDragY)
                {
                    if (CanDragX && args.Touches == DragXTouches)
                    {
                        DragXBy(args.To.X - args.From.X);
                    }

                    if (CanDragY && args.Touches == DragYTouches)
                    {
                        DragYBy(args.To.Y - args.From.Y);
                    }
                }
                else
                {
                    if (CanRotateX && RotateXTouches == args.Touches)
                    {
                        RotateXBy((float)((args.To.X - args.From.X) * 0.5));
                    }

                    if (CanRotateY && RotateYTouches == args.Touches)
                    {
                        RotateYBy((float)((args.To.Y - args.From.Y) * 0.5));
                    }

                    if (CanRotateZ && RotateZTouches == args.Touches)
                    {
                        RotateZBy((float)(((args.To.X - args.From.X) - (args.To.Y - args.From.Y)) * 0.5));
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public Task OnPanning(PannedEventArgs arg)
        {
            var touches = arg.Touches;

            var xDiff = arg.To.X - arg.From.X;
            var yDiff = arg.To.Y - arg.From.Y;

            if (touches == 2)
            {
                ZRotation += xDiff / 2 + yDiff / 2;
                Phone.Rotation(ZRotation);
            }
            else
            {
                XRotation += xDiff;
                YRotation += yDiff;
                Phone.RotationY(XRotation).RotationX(YRotation);
            }

            EnvironmentSimulator.Gyroscope.Invoke(new MotionVector(XRotation, YRotation, ZRotation));
            EnvironmentSimulator.Compass.Invoke(ZRotation);

            // TODO: It should be time based, to calculate the speed.
            EnvironmentSimulator.Accelerometer.Invoke(new MotionVector(Phone.X.CurrentValue, Phone.Y.CurrentValue, 0));

            ShowValues();

            return(Task.CompletedTask);
        }