public bool OnDoubleTap(Android.Views.MotionEvent ev) { if (photoViewAttacher == null) { return(false); } try { float scale = photoViewAttacher.GetScale(); float x = ev.GetX(); float y = ev.GetY(); if (scale > photoViewAttacher.GetMinimumScale()) { photoViewAttacher.SetScale(photoViewAttacher.GetMinimumScale(), x, y, true); } else { photoViewAttacher.SetScale(photoViewAttacher.GetMediumScale(), x, y, true); } /* * if (scale < photoViewAttacher.GetMediumScale()) { * photoViewAttacher.SetScale(photoViewAttacher.GetMediumScale(), x, y, true); * } else if (scale >= photoViewAttacher.GetMediumScale() && scale < photoViewAttacher.GetMaximumScale()) { * photoViewAttacher.SetScale(photoViewAttacher.GetMaximumScale(), x, y, true); * } else { * photoViewAttacher.SetScale(photoViewAttacher.GetMinimumScale(), x, y, true); * }*/ } catch (Java.Lang.ArrayIndexOutOfBoundsException e) { // Can sometimes happen when getX() and getY() is called } return(true); }
protected async override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName == "IsActive" && _photoViewAttacher != null) { // Reset zoom scale when image gets active (visible) _photoViewAttacher.SetScale(_photoViewAttacher.GetMinimumScale(), 0, 0, false); } if (e.PropertyName == "ImageName" && string.IsNullOrWhiteSpace(_view.ImageName) == false) { var fileSystem = new FileSystem(); var filePath = fileSystem.GetFilePath(_view.ImageName); await InitializeRenderer(_view, filePath); } }
public void SetScale(float scale) { mAttacher.SetScale(scale); }