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;
25 internal class PinchGestureDetector : GestureDetector
27 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29 internal PinchGestureDetector(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PinchGestureDetector_SWIGUpcast(cPtr), cMemoryOwn)
31 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
34 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PinchGestureDetector obj)
36 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
40 protected override void Dispose(DisposeTypes type)
47 if (type == DisposeTypes.Explicit)
50 //Release your own managed resources here.
51 //You should release all of your own disposable objects here.
55 //Release your own unmanaged resources here.
56 //You should not access any managed member here except static instance.
57 //because the execution order of Finalizes is non-deterministic.
60 if (swigCPtr.Handle != global::System.IntPtr.Zero)
65 NDalicPINVOKE.delete_PinchGestureDetector(swigCPtr);
67 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
74 public class DetectedEventArgs : EventArgs
77 private PinchGesture _pinchGesture;
91 public PinchGesture PinchGesture
99 _pinchGesture = value;
104 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
105 private delegate void DetectedCallbackDelegate(IntPtr actor, IntPtr pinchGesture);
106 private DaliEventHandler<object, DetectedEventArgs> _pinchGestureEventHandler;
107 private DetectedCallbackDelegate _pinchGestureCallbackDelegate;
110 public event DaliEventHandler<object, DetectedEventArgs> Detected
116 // Restricted to only one listener
117 if (_pinchGestureEventHandler == null)
119 _pinchGestureEventHandler += value;
121 _pinchGestureCallbackDelegate = new DetectedCallbackDelegate(OnPinchGestureDetected);
122 this.DetectedSignal().Connect(_pinchGestureCallbackDelegate);
131 if (_pinchGestureEventHandler != null)
133 this.DetectedSignal().Disconnect(_pinchGestureCallbackDelegate);
136 _pinchGestureEventHandler -= value;
141 private void OnPinchGestureDetected(IntPtr actor, IntPtr pinchGesture)
143 DetectedEventArgs e = new DetectedEventArgs();
145 // Populate all members of "e" (DetectedEventArgs) with real data
146 e.View = Registry.GetManagedBaseHandleFromNativePtr(actor) as View;
147 e.PinchGesture = Tizen.NUI.PinchGesture.GetPinchGestureFromPtr(pinchGesture);
149 if (_pinchGestureEventHandler != null)
151 //here we send all data to user event handlers
152 _pinchGestureEventHandler(this, e);
158 public static PinchGestureDetector GetPinchGestureDetectorFromPtr(global::System.IntPtr cPtr)
160 PinchGestureDetector ret = new PinchGestureDetector(cPtr, false);
161 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
166 public PinchGestureDetector() : this(NDalicPINVOKE.PinchGestureDetector_New(), true)
168 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
171 public new static PinchGestureDetector DownCast(BaseHandle handle)
173 PinchGestureDetector ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PinchGestureDetector;
174 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178 public PinchGestureDetector(PinchGestureDetector handle) : this(NDalicPINVOKE.new_PinchGestureDetector__SWIG_1(PinchGestureDetector.getCPtr(handle)), true)
180 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
183 public PinchGestureDetector Assign(PinchGestureDetector rhs)
185 PinchGestureDetector ret = new PinchGestureDetector(NDalicPINVOKE.PinchGestureDetector_Assign(swigCPtr, PinchGestureDetector.getCPtr(rhs)), false);
186 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190 internal PinchGestureDetectedSignal DetectedSignal()
192 PinchGestureDetectedSignal ret = new PinchGestureDetectedSignal(NDalicPINVOKE.PinchGestureDetector_DetectedSignal(swigCPtr), false);
193 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();