--- /dev/null
+using System;
+using ElmSharp;
+using Tizen.Xamarin.Forms.Extension;
+using Tizen.Xamarin.Forms.Extension.Renderer;
+using Xamarin.Forms;
+using Xamarin.Forms.Platform.Tizen;
+
+[assembly: ExportHandler(typeof(LongTapGestureRecognizer), typeof(LongTapGestureHandler))]
+
+namespace Tizen.Xamarin.Forms.Extension.Renderer
+{
+ public class LongTapGestureHandler : GestureHandler
+ {
+ public LongTapGestureHandler(IGestureRecognizer recognizer) : base(recognizer)
+ {
+ }
+
+ public override GestureLayer.GestureType Type
+ {
+ get
+ {
+ return GestureLayer.GestureType.LongTap;
+ }
+ }
+
+ public override double Timeout
+ {
+ get
+ {
+ return (Recognizer as LongTapGestureRecognizer).Timeout;
+ }
+ }
+
+ protected override void OnCanceled(View sender, object data)
+ {
+ (Recognizer as ILongTapGestureController).SendLongTapCanceled(sender, ((GestureLayer.TapData)data).Timestamp);
+ }
+
+ protected override void OnCompleted(View sender, object data)
+ {
+ (Recognizer as ILongTapGestureController).SendLongTapCompleted(sender, ((GestureLayer.TapData)data).Timestamp);
+ }
+
+ protected override void OnMoved(View sender, object data)
+ {
+ }
+
+ protected override void OnStarted(View sender, object data)
+ {
+ (Recognizer as ILongTapGestureController).SendLongTapStarted(sender, ((GestureLayer.TapData)data).Timestamp);
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+using System;
+using System.Windows.Input;
+using Xamarin.Forms;
+
+namespace Tizen.Xamarin.Forms.Extension
+{
+ /// <summary>
+ /// A recognizer for long-tap gesture.
+ /// </summary>
+ /// <example>
+ /// <code>
+ /// var image = new Image { Source = ImageSource.FromFile("picture.png") };
+ /// var longTapGesture = new LongTapGestureRecognizer
+ /// {
+ /// Timeout = 0.05
+ /// };
+ /// longTapGesture.LongTapUpdated += (sender, args) =>
+ /// {
+ /// Debug.WriteLine("LongTap updated : " + args.Status);
+ /// };
+ /// image.GestureRecognizers.Add(longTapGesture);
+ /// </code>
+ /// </example>
+ public class LongTapGestureRecognizer : Element, IGestureRecognizer, ILongTapGestureController
+ {
+ public static readonly BindableProperty TimeoutProperty = BindableProperty.Create("Timeout", typeof(double), typeof(LongTapGestureRecognizer), default(double));
+
+ public static readonly BindableProperty TapStartedCommandProperty = BindableProperty.Create("TapStartedCommand", typeof(ICommand), typeof(LongTapGestureRecognizer), null);
+
+ public static readonly BindableProperty TapCompletedCommandProperty = BindableProperty.Create("TapCompletedCommand", typeof(ICommand), typeof(LongTapGestureRecognizer), null);
+
+ public static readonly BindableProperty TapStartedCommandParameterProperty = BindableProperty.Create("TapStartedCommandParameter", typeof(object), typeof(LongTapGestureRecognizer), null);
+
+ public static readonly BindableProperty TapCompletedCommandParameterProperty = BindableProperty.Create("TapCompletedCommandParameter", typeof(object), typeof(LongTapGestureRecognizer), null);
+
+ /// <summary>
+ /// Event that is raised when the long-tap gesture updates.
+ /// </summary>
+ public event EventHandler<LongTapUpdatedEventArgs> LongTapUpdated;
+
+ /// <summary>
+ /// Event that is raised when the user presses the View
+ /// </summary>
+ public event EventHandler TapStarted;
+
+ /// <summary>
+ /// Event that is raised when the user releases the view after pressing the View.
+ /// </summary>
+ public event EventHandler TapCompleted;
+
+ /// <summary>
+ /// Event that is raised when the wrong gesture is detected after pressing the View.
+ /// </summary>
+ public event EventHandler TapCanceled;
+
+ /// <summary>
+ /// Gets or Sets the minimum time(seconds) the user should press the view for triggering long-tap event.
+ /// </summary>
+ /// <remarks>
+ /// The default value are defined in the system policy. In Tizen the default value is 0.33 seconds
+ /// </remarks>
+ public double Timeout
+ {
+ get { return (double)GetValue(TimeoutProperty); }
+ set { SetValue(TimeoutProperty, value); }
+ }
+
+ /// <summary>
+ /// Gets or sets the command to invoke when the Pressed event occurs
+ /// </summary>
+ public ICommand TapStartedCommand
+ {
+ get { return (ICommand)GetValue(TapStartedCommandProperty); }
+ set { SetValue(TapStartedCommandProperty, value); }
+ }
+
+ /// <summary>
+ /// Gests or sets an object to be passed when the PressedCommand is excuted.
+ /// </summary>
+ public object TapStartedCommandParameter
+ {
+ get { return GetValue(TapStartedCommandParameterProperty); }
+ set { SetValue(TapStartedCommandParameterProperty, value); }
+ }
+
+ /// <summary>
+ /// Gests or sets the command to invoke when the Released event occurs
+ /// </summary>
+ /// <remarks>
+ /// </remarks>
+ public ICommand TapCompletedCommand
+ {
+ get { return (ICommand)GetValue(TapCompletedCommandProperty); }
+ set { SetValue(TapCompletedCommandProperty, value); }
+ }
+
+ /// <summary>
+ /// Gests or sets an object to be passed when the ReleasedCommand is excuted.
+ /// </summary>
+ public object TapCompletedCommandParameter
+ {
+ get { return GetValue(TapCompletedCommandParameterProperty); }
+ set { SetValue(TapCompletedCommandParameterProperty, value); }
+ }
+
+ void ILongTapGestureController.SendLongTapStarted(Element sender, double timeStamp)
+ {
+ ICommand cmd = TapStartedCommand;
+ if (cmd != null && cmd.CanExecute(TapStartedCommandParameter))
+ cmd.Execute(TapStartedCommandParameter);
+
+ TapStarted?.Invoke(sender, EventArgs.Empty);
+ LongTapUpdated?.Invoke(sender, new LongTapUpdatedEventArgs(GestureStatus.Started, timeStamp));
+ }
+
+ void ILongTapGestureController.SendLongTapCompleted(Element sender, double timeStamp)
+ {
+ ICommand cmd = TapCompletedCommand;
+ if (cmd != null && cmd.CanExecute(TapCompletedCommandParameter))
+ cmd.Execute(TapCompletedCommandParameter);
+
+ TapCompleted?.Invoke(sender, EventArgs.Empty);
+ LongTapUpdated?.Invoke(sender, new LongTapUpdatedEventArgs(GestureStatus.Completed, timeStamp));
+ }
+
+ void ILongTapGestureController.SendLongTapCanceled(Element sender, double timeStamp)
+ {
+ TapCanceled?.Invoke(sender, EventArgs.Empty);
+ LongTapUpdated?.Invoke(sender, new LongTapUpdatedEventArgs(GestureStatus.Canceled, timeStamp));
+ }
+ }
+}
\ No newline at end of file