rename from Pixiview to Gallery
This commit is contained in:
		
							
								
								
									
										57
									
								
								Gallery.iOS/Effects/LongPressEffectImplement.cs
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										57
									
								
								Gallery.iOS/Effects/LongPressEffectImplement.cs
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,57 @@
 | 
			
		||||
using Gallery.iOS.Effects;
 | 
			
		||||
using Gallery.Utils;
 | 
			
		||||
using UIKit;
 | 
			
		||||
using Xamarin.Forms;
 | 
			
		||||
using Xamarin.Forms.Platform.iOS;
 | 
			
		||||
 | 
			
		||||
[assembly: ResolutionGroupName("Gallery")]
 | 
			
		||||
[assembly: ExportEffect(typeof(LongPressEffectImplement), "LongPressEffect")]
 | 
			
		||||
namespace Gallery.iOS.Effects
 | 
			
		||||
{
 | 
			
		||||
    public class LongPressEffectImplement : PlatformEffect
 | 
			
		||||
    {
 | 
			
		||||
        private bool attached;
 | 
			
		||||
        private readonly UILongPressGestureRecognizer longPressGesture;
 | 
			
		||||
 | 
			
		||||
        public LongPressEffectImplement()
 | 
			
		||||
        {
 | 
			
		||||
            longPressGesture = new UILongPressGestureRecognizer(OnLongPressed);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        protected override void OnAttached()
 | 
			
		||||
        {
 | 
			
		||||
            if (!attached)
 | 
			
		||||
            {
 | 
			
		||||
                attached = true;
 | 
			
		||||
                Container.AddGestureRecognizer(longPressGesture);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        protected override void OnDetached()
 | 
			
		||||
        {
 | 
			
		||||
            if (attached)
 | 
			
		||||
            {
 | 
			
		||||
                attached = false;
 | 
			
		||||
                Container.RemoveGestureRecognizer(longPressGesture);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void OnLongPressed(UILongPressGestureRecognizer e)
 | 
			
		||||
        {
 | 
			
		||||
            if (e.State != UIGestureRecognizerState.Began)
 | 
			
		||||
            {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            var element = Element;
 | 
			
		||||
            if (element != null)
 | 
			
		||||
            {
 | 
			
		||||
                var command = LongPressEffect.GetCommand(element);
 | 
			
		||||
                if (command != null)
 | 
			
		||||
                {
 | 
			
		||||
                    var o = LongPressEffect.GetCommandParameter(element);
 | 
			
		||||
                    command.Execute(o);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user