private void MTouch_Pinch(object sender, TouchPinchActionEventArgs args)
        {
            var zoomX  = (float)args.Pinch.ZoomX;
            var zoomY  = (float)args.Pinch.ZoomY;
            var Center = args.Pinch.Center;

            Data.Axis.Zoom(zoomX, zoomY, (float)Center.X, (float)Center.Y);
        }
        private void MTouch_Pinch(object sender, TouchPinchActionEventArgs args)
        {
            var zoomX      = (float)args.Pinch.ZoomX;
            var zoomY      = (float)args.Pinch.ZoomY;
            var zoomCenter = args.Pinch.Center;

            foreach (var Element in ChartElements)
            {
                if (Element.GetType() == typeof(ChartAxis))
                {
                    var element = (Element as ChartAxis);
                    if (element.Orientation == ChartAxis.AxisOrientation.Horizontal)
                    {
                        element.Zoom(zoomX, zoomY, zoomCenter.ToSKPoint());
                    }
                }
            }
        }
Example #3
0
        void ProcessCursor(TouchActionEventArgs args)
        {
            if (!Cursors.ContainsKey(args.ID))
            {
                Cursors.Add(args.ID, new TouchCursor(args.Location));
                if (Cursors.Count >= 2)
                {
                    Mode = TouchMode.Pinch;
                }
            }
            else
            {
                var         item1 = Cursors[args.ID];
                TouchCursor item2 = item1;
                foreach (var cursor in Cursors)
                {
                    if (cursor.Key != args.ID)
                    {
                        item2 = cursor.Value;
                    }
                }

                var dx = args.Location.Position.X - item1.Position.X;
                var dy = args.Location.Position.Y - item1.Position.Y;

                item1.Position = args.Location.Position;
                switch (Cursors.Count)
                {
                case 0:
                    Mode = TouchMode.Normal;
                    break;

                case 1:
                {
                    var temp = new TouchPanActionEventArgs(dx, dy);
                    var dist = temp.Distance;
                    if (dist > 0)
                    {
                        if (Mode == TouchMode.Pan || temp.Distance > GestureThreshold)
                        {
                            TapCancel();
                            Debug.WriteLine("Pan Enabled");
                            Mode = TouchMode.Pan;
                            Pan?.Invoke(this, temp);
                        }
                    }
                }   break;

                case 2:
                {
                    var temp = new TouchPinchActionEventArgs(PinchProcessor);
                    if (temp.Pinch.DistanceDelta >= 0)
                    {
                        Mode = TouchMode.Pinch;
                        if (PinchProcessor.Set(item1.Position, item2.Position))
                        {
                            TapCancel();
                            Pinch?.Invoke(this, temp);
                        }
                    }
                }   break;

                default:
                    Debug.WriteLine("To many cursors.");
                    break;
                }
            }
        }