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;
25 /// Issues a notification upon a condition of the property being met.
26 /// See PropertyCondition for available defined conditions.
28 /// <since_tizen> 4 </since_tizen>
29 public class PropertyNotification : BaseHandle
31 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
33 internal PropertyNotification(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PropertyNotification_SWIGUpcast(cPtr), cMemoryOwn)
35 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
38 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyNotification obj)
40 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
46 /// <since_tizen> 4 </since_tizen>
47 protected override void Dispose(DisposeTypes type)
54 if (type == DisposeTypes.Explicit)
57 //Release your own managed resources here.
58 //You should release all of your own disposable objects here.
62 //Release your own unmanaged resources here.
63 //You should not access any managed member here except static instance.
64 //because the execution order of Finalizes is non-deterministic.
66 if (swigCPtr.Handle != global::System.IntPtr.Zero)
71 NDalicPINVOKE.delete_PropertyNotification(swigCPtr);
73 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
80 /// Event arguments that passed via Notify signal
82 /// <since_tizen> 3 </since_tizen>
83 public class NotifyEventArgs : EventArgs
85 private PropertyNotification _propertyNotification;
88 /// PropertyNotification - is the PropertyNotification handle that has the notification properties.
90 /// <since_tizen> 3 </since_tizen>
91 public PropertyNotification PropertyNotification
95 return _propertyNotification;
99 _propertyNotification = value;
104 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
105 private delegate void NotifyEventCallbackDelegate(IntPtr propertyNotification);
106 private DaliEventHandler<object, NotifyEventArgs> _propertyNotificationNotifyEventHandler;
107 private NotifyEventCallbackDelegate _propertyNotificationNotifyEventCallbackDelegate;
110 /// Event for Notified signal which can be used to subscribe/unsubscribe the event handler
111 /// Notified signal is emitted when the notification upon a condition of the property being met, has occurred.
113 /// <since_tizen> 4 </since_tizen>
114 public event DaliEventHandler<object, NotifyEventArgs> Notified
120 // Restricted to only one listener
121 if (_propertyNotificationNotifyEventHandler == null)
123 _propertyNotificationNotifyEventHandler += value;
125 _propertyNotificationNotifyEventCallbackDelegate = new NotifyEventCallbackDelegate(OnPropertyNotificationNotify);
126 this.NotifySignal().Connect(_propertyNotificationNotifyEventCallbackDelegate);
135 if (_propertyNotificationNotifyEventHandler != null)
137 this.NotifySignal().Disconnect(_propertyNotificationNotifyEventCallbackDelegate);
140 _propertyNotificationNotifyEventHandler -= value;
145 // Callback for PropertyNotification NotifySignal
146 private void OnPropertyNotificationNotify(IntPtr propertyNotification)
148 NotifyEventArgs e = new NotifyEventArgs();
149 e.PropertyNotification = GetPropertyNotificationFromPtr(propertyNotification);
151 if (_propertyNotificationNotifyEventHandler != null)
153 //here we send all data to user event handlers
154 _propertyNotificationNotifyEventHandler(this, e);
159 /// Get property notification from Intptr.<br/>
160 /// This should be internal, please do not use.
162 /// <param name="cPtr">An object of IntPtr type.</param>
163 /// <returns>An object of the PropertyNotification type.</returns>
164 /// <since_tizen> 4 </since_tizen>
165 public static PropertyNotification GetPropertyNotificationFromPtr(global::System.IntPtr cPtr)
167 PropertyNotification ret = new PropertyNotification(cPtr, false);
168 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173 /// Create a instance of PropertyNotification.
175 /// <since_tizen> 4 </since_tizen>
176 public PropertyNotification() : this(NDalicPINVOKE.new_PropertyNotification__SWIG_0(), true)
178 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
182 /// Downcast a PropertyNotification instance.
184 /// <param name="handle">Handle to an object of BaseHandle type.</param>
185 /// <returns>Handle to an object of the PropertyNotification type.</returns>
186 /// <since_tizen> 4 </since_tizen>
187 public static PropertyNotification DownCast(BaseHandle handle)
189 PropertyNotification ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PropertyNotification;
190 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
195 /// Create a instance of PropertyNotification.
197 /// <since_tizen> 4 </since_tizen>
198 public PropertyNotification(PropertyNotification handle) : this(NDalicPINVOKE.new_PropertyNotification__SWIG_1(PropertyNotification.getCPtr(handle)), true)
200 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
206 /// <param name="rhs">A reference to the copied handle.</param>
207 /// <returns>A reference to this.</returns>
208 /// <since_tizen> 4 </since_tizen>
209 public PropertyNotification Assign(PropertyNotification rhs)
211 PropertyNotification ret = new PropertyNotification(NDalicPINVOKE.PropertyNotification_Assign(swigCPtr, PropertyNotification.getCPtr(rhs)), false);
212 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
217 /// Gets the condition of this notification.
219 /// <returns>The condition is returned.</returns>
220 /// <since_tizen> 4 </since_tizen>
221 public PropertyCondition GetCondition()
223 PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.PropertyNotification_GetCondition__SWIG_0(swigCPtr), true);
224 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
229 /// Gets the target handle that this notification is observing.
231 /// <since_tizen> 4 </since_tizen>
232 public Animatable GetTarget()
234 Animatable ret = new Animatable(NDalicPINVOKE.PropertyNotification_GetTarget(swigCPtr), true);
235 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
240 /// Gets the target handle's property index that this notification.
242 /// <returns>The target property index.</returns>
243 /// <since_tizen> 4 </since_tizen>
244 public int GetTargetProperty()
246 int ret = NDalicPINVOKE.PropertyNotification_GetTargetProperty(swigCPtr);
247 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
252 /// Sets the Notification mode.
254 /// <param name="mode">mode Notification mode (Default is PropertyNotification::NotifyOnTrue).</param>
255 /// <since_tizen> 4 </since_tizen>
256 public void SetNotifyMode(PropertyNotification.NotifyMode mode)
258 NDalicPINVOKE.PropertyNotification_SetNotifyMode(swigCPtr, (int)mode);
259 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
263 /// Retrieves the current Notification mode.
265 /// <returns>Notification mode.</returns>
266 /// <since_tizen> 4 </since_tizen>
267 public PropertyNotification.NotifyMode GetNotifyMode()
269 PropertyNotification.NotifyMode ret = (PropertyNotification.NotifyMode)NDalicPINVOKE.PropertyNotification_GetNotifyMode(swigCPtr);
270 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
275 /// Gets the result of the last condition check that caused a signal emit,
276 /// useful when using NotifyOnChanged mode and need to know what it changed to.
278 /// <since_tizen> 4 </since_tizen>
279 public bool GetNotifyResult()
281 bool ret = NDalicPINVOKE.PropertyNotification_GetNotifyResult(swigCPtr);
282 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
287 /// Connects to this signal to be notified when the notification has occurred.
289 /// <returns>A signal object to Connect() with</returns>
290 /// <since_tizen> 4 </since_tizen>
291 public PropertyNotifySignal NotifySignal()
293 PropertyNotifySignal ret = new PropertyNotifySignal(NDalicPINVOKE.PropertyNotification_NotifySignal(swigCPtr), false);
294 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
299 /// Enumeration for description of how to check condition.
301 /// <since_tizen> 3 </since_tizen>
302 public enum NotifyMode
305 /// Don't notify, regardless of result of Condition
307 /// <since_tizen> 3 </since_tizen>
310 /// Notify whenever condition changes from false to true.
312 /// <since_tizen> 3 </since_tizen>
315 /// Notify whenever condition changes from true to false.
317 /// <since_tizen> 3 </since_tizen>
320 /// Notify whenever condition changes (false to true, and true to false)
322 /// <since_tizen> 3 </since_tizen>