Esempio n. 1
0
        public ImageCropView()
        {
            HorizontalOptions = LayoutOptions.Center;
            VerticalOptions   = LayoutOptions.Center;

            _crop = new CropTransformation();

            _image = new CustomCachedImage()
            {
                LoadingDelay      = 0,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                InputTransparent  = true,
                Aspect            = Aspect.Fill,
                Transformations   = new List <ITransformation>()
                {
                    _crop
                },
            };

            _root = new Grid()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                InputTransparent  = true,
                Children          =
                {
                    _image
                }
            };

            var pinchGesture = new PinchGestureRecognizer();

            pinchGesture.PinchUpdated += PinchGesture_PinchUpdated;;

            var panGesture = new PanGestureRecognizer();

            panGesture.PanUpdated += PanGesture_PanUpdated;

            GestureRecognizers.Clear();
            GestureRecognizers.Add(pinchGesture);
            GestureRecognizers.Add(panGesture);

            _pinchObservable = Observable.FromEventPattern <PinchGestureUpdatedEventArgs>(pinchGesture, "PinchUpdated")
                               .Select(v => v.EventArgs).Where(v => v.Status == GestureStatus.Running);

            _panObservable = Observable.FromEventPattern <PanUpdatedEventArgs>(panGesture, "PanUpdated")
                             .Select(v => v.EventArgs).Where(v => v.StatusType == GestureStatus.Running);

            HandlePreviewTransformations(null, PreviewTransformations);
            Content = _root;
            ResetCrop();

            SetDelay();
        }
        public ImageCropView()
        {
            HorizontalOptions = LayoutOptions.Center;
            VerticalOptions   = LayoutOptions.Center;

            _crop = new CropTransformation();

            _image = new CustomCachedImage()
            {
                LoadingDelay      = 0,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                InputTransparent  = true,
                Aspect            = Aspect,
                Transformations   = new List <ITransformation>()
                {
                    _crop
                },
                FadeAnimationEnabled = false,
            };

            SetupImageView(_image);

            _root = new Grid()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                InputTransparent  = true,
                Children          =
                {
                    _image
                }
            };

            _intervalThrottle = new IntervalThrottle(Delay,
                                                     _image.LoadImage, _image.LoadImage, _image.LoadRefinedImage);

            _pinchGesture = new PinchGestureRecognizer();
            _pinchGesture.PinchUpdated += PinchGesture_PinchUpdated;;

            _panGesture             = new PanGestureRecognizer();
            _panGesture.PanUpdated += PanGesture_PanUpdated;

            GestureRecognizers.Clear();
            GestureRecognizers.Add(_pinchGesture);
            GestureRecognizers.Add(_panGesture);

            HandlePreviewTransformations(null, PreviewTransformations);
            Content = _root;
            ResetCrop();
        }