2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 using System.Runtime.InteropServices;
23 using Tizen.NUI.BaseComponents;
26 internal class PinchGestureDetector : GestureDetector
28 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30 internal PinchGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PinchGestureDetector_SWIGUpcast(cPtr), cMemoryOwn)
32 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
35 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PinchGestureDetector obj)
37 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
41 protected override void Dispose(DisposeTypes type)
48 if (type == DisposeTypes.Explicit)
51 //Release your own managed resources here.
52 //You should release all of your own disposable objects here.
56 //Release your own unmanaged resources here.
57 //You should not access any managed member here except static instance.
58 //because the execution order of Finalizes is non-deterministic.
61 if (swigCPtr.Handle != global::System.IntPtr.Zero)
66 NDalicPINVOKE.delete_PinchGestureDetector(swigCPtr);
68 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
75 /// <since_tizen> 3 </since_tizen>
76 public class DetectedEventArgs : EventArgs
79 private PinchGesture _pinchGesture;
81 /// <since_tizen> 3 </since_tizen>
94 /// <since_tizen> 3 </since_tizen>
95 public PinchGesture PinchGesture
103 _pinchGesture = value;
108 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
109 private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr pinchGesture);
110 private DaliEventHandler<object, DetectedEventArgs> _pinchGestureEventHandler;
111 private DetectedCallbackDelegate _pinchGestureCallbackDelegate;
114 public event DaliEventHandler<object, DetectedEventArgs> Detected
120 // Restricted to only one listener
121 if (_pinchGestureEventHandler == null)
123 _pinchGestureEventHandler += value;
125 _pinchGestureCallbackDelegate = new DetectedCallbackDelegate(OnPinchGestureDetected);
126 this.DetectedSignal().Connect(_pinchGestureCallbackDelegate);
135 if (_pinchGestureEventHandler != null)
137 this.DetectedSignal().Disconnect(_pinchGestureCallbackDelegate);
140 _pinchGestureEventHandler -= value;
145 private void OnPinchGestureDetected(IntPtr actor, IntPtr pinchGesture)
147 DetectedEventArgs e = new DetectedEventArgs();
149 // Populate all members of "e" (DetectedEventArgs) with real data
150 e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
151 e.PinchGesture = Tizen.NUI.PinchGesture.GetPinchGestureFromPtr(pinchGesture);
153 if (_pinchGestureEventHandler != null)
155 //here we send all data to user event handlers
156 _pinchGestureEventHandler(this, e);
162 public static PinchGestureDetector GetPinchGestureDetectorFromPtr(global::System.IntPtr cPtr)
164 PinchGestureDetector ret = new PinchGestureDetector(cPtr, false);
165 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
170 public PinchGestureDetector() : this(NDalicPINVOKE.PinchGestureDetector_New(), true)
172 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
175 public new static PinchGestureDetector DownCast(BaseHandle handle)
177 PinchGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PinchGestureDetector;
178 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
182 public PinchGestureDetector(PinchGestureDetector handle) : this(NDalicPINVOKE.new_PinchGestureDetector__SWIG_1(PinchGestureDetector.getCPtr(handle)), true)
184 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
187 public PinchGestureDetector Assign(PinchGestureDetector rhs)
189 PinchGestureDetector ret = new PinchGestureDetector(NDalicPINVOKE.PinchGestureDetector_Assign(swigCPtr, PinchGestureDetector.getCPtr(rhs)), false);
190 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
194 internal PinchGestureDetectedSignal DetectedSignal()
196 PinchGestureDetectedSignal ret = new PinchGestureDetectedSignal(NDalicPINVOKE.PinchGestureDetector_DetectedSignal(swigCPtr), false);
197 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();