コード例 #1
0
        public ZoomCanvas()
        {
            overlaySurface.TransformationPivot = SKPoint.Empty;
            overlaySurface.AttachParent(this);
            this.GestureRecognizers.Add(panGesture);
            panGesture.PanUpdated += PanGesture_PanUpdated;

            this.GestureRecognizers.Add(pinchGesture);
            pinchGesture.PinchUpdated += OnPinchUpdated;
            ZoomCommand = new Command(o =>
            {
                float scaleFactor = 0;
                if (o is string)
                {
                    scaleFactor = float.Parse((string)o, CultureInfo.InvariantCulture);
                }
                else
                {
                    scaleFactor = Convert.ToSingle(o);
                }
                scaleTransformation    = SKMatrix.MakeScale((float)scaleFactor, (float)scaleFactor);
                surface.Transformation = translateTransformation.Concat(scaleTransformation);
            });
            IncrementalZoomCommand = new Command(o =>
            {
                float scaleFactor = 0;
                if (o is string)
                {
                    scaleFactor = float.Parse((string)o, CultureInfo.InvariantCulture);
                }
                else
                {
                    scaleFactor = Convert.ToSingle(o);
                }
                scaleTransformation = scaleTransformation
                                      .Scale(scaleFactor, scaleFactor);
                surface.Transformation = translateTransformation.Concat(scaleTransformation);
            });
        }