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 public class DetectedEventArgs : EventArgs
78 private PinchGesture _pinchGesture;
92 public PinchGesture PinchGesture
100 _pinchGesture = value;
105 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
106 private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr pinchGesture);
107 private DaliEventHandler<object, DetectedEventArgs> _pinchGestureEventHandler;
108 private DetectedCallbackDelegate _pinchGestureCallbackDelegate;
111 public event DaliEventHandler<object, DetectedEventArgs> Detected
117 // Restricted to only one listener
118 if (_pinchGestureEventHandler == null)
120 _pinchGestureEventHandler += value;
122 _pinchGestureCallbackDelegate = new DetectedCallbackDelegate(OnPinchGestureDetected);
123 this.DetectedSignal().Connect(_pinchGestureCallbackDelegate);
132 if (_pinchGestureEventHandler != null)
134 this.DetectedSignal().Disconnect(_pinchGestureCallbackDelegate);
137 _pinchGestureEventHandler -= value;
142 private void OnPinchGestureDetected(IntPtr actor, IntPtr pinchGesture)
144 DetectedEventArgs e = new DetectedEventArgs();
146 // Populate all members of "e" (DetectedEventArgs) with real data
147 e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
148 e.PinchGesture = Tizen.NUI.PinchGesture.GetPinchGestureFromPtr(pinchGesture);
150 if (_pinchGestureEventHandler != null)
152 //here we send all data to user event handlers
153 _pinchGestureEventHandler(this, e);
159 public static PinchGestureDetector GetPinchGestureDetectorFromPtr(global::System.IntPtr cPtr)
161 PinchGestureDetector ret = new PinchGestureDetector(cPtr, false);
162 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
167 public PinchGestureDetector() : this(NDalicPINVOKE.PinchGestureDetector_New(), true)
169 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
172 public new static PinchGestureDetector DownCast(BaseHandle handle)
174 PinchGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PinchGestureDetector;
175 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
179 public PinchGestureDetector(PinchGestureDetector handle) : this(NDalicPINVOKE.new_PinchGestureDetector__SWIG_1(PinchGestureDetector.getCPtr(handle)), true)
181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184 public PinchGestureDetector Assign(PinchGestureDetector rhs)
186 PinchGestureDetector ret = new PinchGestureDetector(NDalicPINVOKE.PinchGestureDetector_Assign(swigCPtr, PinchGestureDetector.getCPtr(rhs)), false);
187 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191 internal PinchGestureDetectedSignal DetectedSignal()
193 PinchGestureDetectedSignal ret = new PinchGestureDetectedSignal(NDalicPINVOKE.PinchGestureDetector_DetectedSignal(swigCPtr), false);
194 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();