Beispiel #1
0
 public TapCircleImage()
 {
     gesture         = new TapGestureRecognizer();
     gesture.Tapped += gestureTapped;
     GestureRecognizers.Clear();
     GestureRecognizers.Add(gesture);
 }
Beispiel #2
0
 public TapImage()
 {
     gesture         = new TapGestureRecognizer();
     gesture.Tapped += gestureTapped;
     GestureRecognizers.Clear();
     GestureRecognizers.Add(gesture);
     CacheType = FFImageLoading.Cache.CacheType.Memory;
 }
Beispiel #3
0
 void UpdateCommand()
 {
     GestureRecognizers.Clear();
     GestureRecognizers.Add(new TapGestureRecognizer
     {
         Command = Command
     });
 }
Beispiel #4
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();
        }
Beispiel #5
0
 public void Dispose()
 {
     if (GestureRecognizers != null)
     {
         GestureRecognizers.Clear();
     }
     if (_toggleImage != null)
     {
         _toggleImage.Source = null;
     }
 }
        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();
        }
Beispiel #7
0
        public void Dispose()
        {
            if (_skiaView != null)
            {
                _skiaView.PaintSurface -= OnPaintSurface;
            }

            if (_tapGestureRecognizer != null)
            {
                _tapGestureRecognizer.Tapped -= OnTapped;
            }

            GestureRecognizers.Clear();
        }
        /// <summary>
        /// On ToggleOnTouch changed
        /// </summary>
        /// <param name="oldValue">Old Value</param>
        /// <param name="newValue">New Value</param>
        protected virtual void OnToggleOnTouchChanged(object oldValue, object newValue)
        {
            bool b = (bool)newValue;

            if (b)
            {
                GestureRecognizers.Add(new TapGestureRecognizer {
                    Command = new AtomCommand(() => {
                        IsChecked = !IsChecked;
                        return(Task.CompletedTask);
                    })
                });
            }
            else
            {
                GestureRecognizers.Clear();
            }
        }
Beispiel #9
0
        private void Initialize()
        {
            ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            RowDefinitions.Add(new RowDefinition()
            {
                Height = new GridLength(1, GridUnitType.Star)
            });

            ButtonFrame = new SupportFrame()
            {
                HasShadow         = Shadow,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Padding           = 0,
                CornerRadius      = CornerRadius
            };
            if (Device.RuntimePlatform == Device.iOS)
            {
                ButtonFrame.BackgroundColor = Color.Transparent;
            }
            else if (Device.RuntimePlatform == Device.Android)
            {
                ButtonFrame.BackgroundColor = FrameBackgroundColor;
            }


            ButtonTitleLabel = new Label();
            ButtonImage      = new Image();

            Children.Clear();
            Children.Add(ButtonFrame);

            tapGestureRecognizer         = new TapGestureRecognizer();
            tapGestureRecognizer.Tapped += (sender, e) => {
                ClickedCommand?.Execute(CommandParameter);
            };
            GestureRecognizers.Clear();
            GestureRecognizers.Add(tapGestureRecognizer);
        }
Beispiel #10
0
        public ImageButton()
        {
            Padding = 0;

            GestureRecognizers.Clear();
            GestureRecognizers.Add(new TapGestureRecognizer());

            _image = new CachedImage()
            {
                HorizontalOptions    = LayoutOptions.Center,
                VerticalOptions      = LayoutOptions.Center,
                FadeAnimationEnabled = false,
            };

            HeightRequest = 36d;
            WidthRequest  = 36d;
            IconSize      = 25d;

            Content = _image;
        }
        public void Dispose()
        {
            foreach (var card in _cards)
            {
                if (card != null)
                {
                    ViewExtensions.CancelAnimations(card);
                }
            }

            GestureRecognizers.Clear();

            if (this.ItemsSource != null)
            {
                var observable = this.ItemsSource as INotifyCollectionChanged;
                if (observable != null)
                {
                    observable.CollectionChanged -= this.OnItemSourceCollectionChanged;
                }
            }
        }
Beispiel #12
0
        public ToggleButton()
        {
            Image = new CachedImage()
            {
                HorizontalOptions    = LayoutOptions.Center,
                VerticalOptions      = LayoutOptions.Center,
                FadeAnimationEnabled = false,
            };

            State = false;

            Padding = 0;
            GestureRecognizers.Clear();
            GestureRecognizers.Add(new TapGestureRecognizer());
            (GestureRecognizers.First() as TapGestureRecognizer).Tapped += tap;

            HeightRequest = 36d;
            WidthRequest  = 36d;
            IconSize      = 25d;

            Content = Image;
        }
Beispiel #13
0
 public AnimatedTapLabel()
 {
     tap.Tapped += tapTapped;
     GestureRecognizers.Clear();
     GestureRecognizers.Add(tap);
 }
Beispiel #14
0
        protected override void OnPropertyChanged(string propertyName = null)
        {
            base.OnPropertyChanged(propertyName);

            if (propertyName == PreviewTransformationsProperty.PropertyName)
            {
                ResetCrop();
                SetPreviewTransformations();
            }
            else if (propertyName == SourceProperty.PropertyName)
            {
                ResetCrop();
                _image.SetSource(Source);
            }
            else if (propertyName == FrameViewProperty.PropertyName)
            {
                if (_frame != null)
                {
                    _root.Children.Remove(_frame);
                }

                _frame = FrameView;

                if (FrameView != null)
                {
                    FrameView.InputTransparent  = true;
                    FrameView.HorizontalOptions = LayoutOptions.FillAndExpand;
                    FrameView.VerticalOptions   = LayoutOptions.FillAndExpand;
                    _root.Children.Add(FrameView);
                }
            }
            else if (propertyName == DelayProperty.PropertyName)
            {
                _intervalThrottle.Delay = Delay;
            }
            else if (propertyName == PreviewMaxResolutionProperty.PropertyName)
            {
                _image.PreviewResolution = PreviewMaxResolution;
            }
            else if (propertyName == RefinedMaxResolutionProperty.PropertyName)
            {
                _image.RefinedResolution = RefinedMaxResolution;
            }
            else if (propertyName == TouchGesturesEnabledProperty.PropertyName)
            {
                GestureRecognizers.Clear();

                if (TouchGesturesEnabled)
                {
                    GestureRecognizers.Add(_pinchGesture);
                    GestureRecognizers.Add(_panGesture);
                }
            }
            else if (propertyName == ManualZoomProperty.PropertyName)
            {
                _crop.ZoomFactor = Clamp(ManualZoom, MIN_SCALE, MaxZoom);
                _intervalThrottle.Handle();
            }
            else if (propertyName == ManualOffsetXProperty.PropertyName)
            {
                _crop.XOffset = Clamp(ManualOffsetX / _crop.CropWidthRatio, -Width / 2 / _crop.ZoomFactor, Width / 2 / _crop.ZoomFactor);
                _intervalThrottle.Handle();
            }
            else if (propertyName == ManualOffsetYProperty.PropertyName)
            {
                _crop.YOffset = Clamp(ManualOffsetY / _crop.CropHeightRatio, -Height / 2 / _crop.ZoomFactor, Height / 2 / _crop.ZoomFactor);
                _intervalThrottle.Handle();
            }
            else if (propertyName == ImageRotationProperty.PropertyName)
            {
                ResetCrop();
                _image.ImageRotation = ImageRotation;
            }
        }
Beispiel #15
0
 public void Dispose()
 {
     _skiaView.PaintSurface -= Handle_PaintSurface;
     GestureRecognizers.Clear();
 }