1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
21 using System.Runtime.InteropServices;
22 using Tizen.NUI.BaseComponents;
24 internal class LongPressGestureDetector : GestureDetector
26 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
28 internal LongPressGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.LongPressGestureDetector_SWIGUpcast(cPtr), cMemoryOwn)
30 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
33 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LongPressGestureDetector obj)
35 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
38 protected override void Dispose(DisposeTypes type)
45 if (type == DisposeTypes.Explicit)
48 //Release your own managed resources here.
49 //You should release all of your own disposable objects here.
53 //Release your own unmanaged resources here.
54 //You should not access any managed member here except static instance.
55 //because the execution order of Finalizes is non-deterministic.
57 if (swigCPtr.Handle != global::System.IntPtr.Zero)
62 NDalicPINVOKE.delete_LongPressGestureDetector(swigCPtr);
64 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
71 public class DetectedEventArgs : EventArgs
74 private LongPressGesture _longPressGesture;
88 public LongPressGesture LongPressGesture
92 return _longPressGesture;
96 _longPressGesture = value;
101 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
102 private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr longPressGesture);
103 private DaliEventHandler<object, DetectedEventArgs> _longPressGestureEventHandler;
104 private DetectedCallbackDelegate _longPressGestureCallbackDelegate;
107 public event DaliEventHandler<object, DetectedEventArgs> Detected
113 // Restricted to only one listener
114 if (_longPressGestureEventHandler == null)
116 _longPressGestureEventHandler += value;
118 _longPressGestureCallbackDelegate = new DetectedCallbackDelegate(OnLongPressGestureDetected);
119 this.DetectedSignal().Connect(_longPressGestureCallbackDelegate);
128 if (_longPressGestureEventHandler != null)
130 this.DetectedSignal().Disconnect(_longPressGestureCallbackDelegate);
133 _longPressGestureEventHandler -= value;
138 private void OnLongPressGestureDetected(IntPtr actor, IntPtr longPressGesture)
140 DetectedEventArgs e = new DetectedEventArgs();
142 // Populate all members of "e" (LongPressGestureEventArgs) with real data
143 e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
144 e.LongPressGesture = Tizen.NUI.LongPressGesture.GetLongPressGestureFromPtr(longPressGesture);
146 if (_longPressGestureEventHandler != null)
148 //here we send all data to user event handlers
149 _longPressGestureEventHandler(this, e);
155 public static LongPressGestureDetector GetLongPressGestureDetectorFromPtr(global::System.IntPtr cPtr)
157 LongPressGestureDetector ret = new LongPressGestureDetector(cPtr, false);
158 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
163 public LongPressGestureDetector() : this(NDalicPINVOKE.LongPressGestureDetector_New__SWIG_0(), true)
165 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
168 public LongPressGestureDetector(uint touchesRequired) : this(NDalicPINVOKE.LongPressGestureDetector_New__SWIG_1(touchesRequired), true)
170 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173 public LongPressGestureDetector(uint minTouches, uint maxTouches) : this(NDalicPINVOKE.LongPressGestureDetector_New__SWIG_2(minTouches, maxTouches), true)
175 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178 public new static LongPressGestureDetector DownCast(BaseHandle handle)
180 LongPressGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as LongPressGestureDetector;
181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
185 public LongPressGestureDetector(LongPressGestureDetector handle) : this(NDalicPINVOKE.new_LongPressGestureDetector__SWIG_1(LongPressGestureDetector.getCPtr(handle)), true)
187 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190 public LongPressGestureDetector Assign(LongPressGestureDetector rhs)
192 LongPressGestureDetector ret = new LongPressGestureDetector(NDalicPINVOKE.LongPressGestureDetector_Assign(swigCPtr, LongPressGestureDetector.getCPtr(rhs)), false);
193 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
197 public void SetTouchesRequired(uint touches)
199 NDalicPINVOKE.LongPressGestureDetector_SetTouchesRequired__SWIG_0(swigCPtr, touches);
200 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
203 public void SetTouchesRequired(uint minTouches, uint maxTouches)
205 NDalicPINVOKE.LongPressGestureDetector_SetTouchesRequired__SWIG_1(swigCPtr, minTouches, maxTouches);
206 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
209 public uint GetMinimumTouchesRequired()
211 uint ret = NDalicPINVOKE.LongPressGestureDetector_GetMinimumTouchesRequired(swigCPtr);
212 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
216 public uint GetMaximumTouchesRequired()
218 uint ret = NDalicPINVOKE.LongPressGestureDetector_GetMaximumTouchesRequired(swigCPtr);
219 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
223 internal LongPressGestureDetectedSignal DetectedSignal()
225 LongPressGestureDetectedSignal ret = new LongPressGestureDetectedSignal(NDalicPINVOKE.LongPressGestureDetector_DetectedSignal(swigCPtr), false);
226 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();