Created
April 8, 2016 12:32
-
-
Save adamped/eefab4549fc28829d364d185860e5df8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [assembly: ExportRenderer(typeof(Label), typeof(LabelRender))] | |
| namespace Mobile.Droid.Renderer | |
| { | |
| public class LabelRender: LabelRenderer | |
| { | |
| protected override void OnElementChanged(ElementChangedEventArgs<Label> e) | |
| { | |
| base.OnElementChanged(e); | |
| if (e.OldElement == null) | |
| { | |
| if (!e.NewElement.GestureRecognizers.Any()) | |
| return; | |
| if (e.NewElement.GestureRecognizers.Any(x => x.GetType() == typeof(PressedGestureRecognizer) | |
| || x.GetType() == typeof(ReleasedGestureRecognizer))) | |
| Control.Touch += Control_Touch; | |
| } | |
| } | |
| private void Control_Touch(object sender, TouchEventArgs e) | |
| { | |
| switch (e.Event.Action) | |
| { | |
| case MotionEventActions.Down: | |
| foreach (var recognizer in this.Element.GestureRecognizers.Where(x => x.GetType() == typeof(PressedGestureRecognizer))) | |
| { | |
| var gesture = recognizer as PressedGestureRecognizer; | |
| if (gesture != null) | |
| if (gesture.Command != null) | |
| gesture.Command.Execute(gesture.CommandParameter); | |
| } | |
| break; | |
| case MotionEventActions.Up: | |
| foreach (var recognizer in this.Element.GestureRecognizers.Where(x => x.GetType() == typeof(ReleasedGestureRecognizer))) | |
| { | |
| var gesture = recognizer as ReleasedGestureRecognizer; | |
| if (gesture != null) | |
| if (gesture.Command != null) | |
| gesture.Command.Execute(gesture.CommandParameter); | |
| } | |
| break; | |
| default: | |
| break; | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment