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 public class PropertyNotification : BaseHandle
30 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
32 internal PropertyNotification(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PropertyNotification_SWIGUpcast(cPtr), cMemoryOwn)
34 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
37 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyNotification obj)
39 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
45 /// <since_tizen> 3 </since_tizen>
46 protected override void Dispose(DisposeTypes type)
53 if (type == DisposeTypes.Explicit)
56 //Release your own managed resources here.
57 //You should release all of your own disposable objects here.
61 //Release your own unmanaged resources here.
62 //You should not access any managed member here except static instance.
63 //because the execution order of Finalizes is non-deterministic.
65 if (swigCPtr.Handle != global::System.IntPtr.Zero)
70 NDalicPINVOKE.delete_PropertyNotification(swigCPtr);
72 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
79 /// Event arguments that passed via Notify signal
81 public class NotifyEventArgs : EventArgs
83 private PropertyNotification _propertyNotification;
86 /// PropertyNotification - is the PropertyNotification handle that has the notification properties.
88 /// <since_tizen> 4 </since_tizen>
89 public PropertyNotification PropertyNotification
93 return _propertyNotification;
97 _propertyNotification = value;
102 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
103 private delegate void NotifyEventCallbackDelegate(IntPtr propertyNotification);
104 private DaliEventHandler<object, NotifyEventArgs> _propertyNotificationNotifyEventHandler;
105 private NotifyEventCallbackDelegate _propertyNotificationNotifyEventCallbackDelegate;
108 /// Event for Notified signal which can be used to subscribe/unsubscribe the event handler
109 /// Notified signal is emitted when the notification upon a condition of the property being met, has occurred.
111 /// <since_tizen> 4 </since_tizen>
112 public event DaliEventHandler<object, NotifyEventArgs> Notified
118 // Restricted to only one listener
119 if (_propertyNotificationNotifyEventHandler == null)
121 _propertyNotificationNotifyEventHandler += value;
123 _propertyNotificationNotifyEventCallbackDelegate = new NotifyEventCallbackDelegate(OnPropertyNotificationNotify);
124 this.NotifySignal().Connect(_propertyNotificationNotifyEventCallbackDelegate);
133 if (_propertyNotificationNotifyEventHandler != null)
135 this.NotifySignal().Disconnect(_propertyNotificationNotifyEventCallbackDelegate);
138 _propertyNotificationNotifyEventHandler -= value;
143 // Callback for PropertyNotification NotifySignal
144 private void OnPropertyNotificationNotify(IntPtr propertyNotification)
146 NotifyEventArgs e = new NotifyEventArgs();
147 e.PropertyNotification = GetPropertyNotificationFromPtr(propertyNotification);
149 if (_propertyNotificationNotifyEventHandler != null)
151 //here we send all data to user event handlers
152 _propertyNotificationNotifyEventHandler(this, e);
157 /// Get property notification from Intptr.<br/>
158 /// This should be internal, please do not use.
160 /// <param name="cPtr">An object of IntPtr type.</param>
161 /// <returns>An object of the PropertyNotification type.</returns>
162 /// <since_tizen> 4 </since_tizen>
163 public static PropertyNotification GetPropertyNotificationFromPtr(global::System.IntPtr cPtr)
165 PropertyNotification ret = new PropertyNotification(cPtr, false);
166 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
171 /// Create a instance of PropertyNotification.
173 /// <since_tizen> 4 </since_tizen>
174 public PropertyNotification() : this(NDalicPINVOKE.new_PropertyNotification__SWIG_0(), true)
176 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
180 /// Downcast a PropertyNotification instance.
182 /// <param name="handle">Handle to an object of BaseHandle type.</param>
183 /// <returns>Handle to an object of the PropertyNotification type.</returns>
184 /// <since_tizen> 4 </since_tizen>
185 public static PropertyNotification DownCast(BaseHandle handle)
187 PropertyNotification ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PropertyNotification;
188 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
193 /// Create a instance of PropertyNotification.
195 /// <since_tizen> 4 </since_tizen>
196 public PropertyNotification(PropertyNotification handle) : this(NDalicPINVOKE.new_PropertyNotification__SWIG_1(PropertyNotification.getCPtr(handle)), true)
198 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
204 /// <param name="rhs">A reference to the copied handle.</param>
205 /// <returns>A reference to this.</returns>
206 /// <since_tizen> 4 </since_tizen>
207 public PropertyNotification Assign(PropertyNotification rhs)
209 PropertyNotification ret = new PropertyNotification(NDalicPINVOKE.PropertyNotification_Assign(swigCPtr, PropertyNotification.getCPtr(rhs)), false);
210 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215 /// Gets the condition of this notification.
217 /// <returns>The condition is returned.</returns>
218 /// <since_tizen> 4 </since_tizen>
219 public PropertyCondition GetCondition()
221 PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.PropertyNotification_GetCondition__SWIG_0(swigCPtr), true);
222 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
227 /// Gets the target handle that this notification is observing.
229 /// <since_tizen> 4 </since_tizen>
230 public Animatable GetTarget()
232 Animatable ret = new Animatable(NDalicPINVOKE.PropertyNotification_GetTarget(swigCPtr), true);
233 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
238 /// Gets the target handle's property index that this notification.
240 /// <returns>The target property index.</returns>
241 /// <since_tizen> 4 </since_tizen>
242 public int GetTargetProperty()
244 int ret = NDalicPINVOKE.PropertyNotification_GetTargetProperty(swigCPtr);
245 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
250 /// Sets the Notification mode.
252 /// <param name="mode">mode Notification mode (Default is PropertyNotification::NotifyOnTrue).</param>
253 /// <since_tizen> 4 </since_tizen>
254 public void SetNotifyMode(PropertyNotification.NotifyMode mode)
256 NDalicPINVOKE.PropertyNotification_SetNotifyMode(swigCPtr, (int)mode);
257 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
261 /// Retrieves the current Notification mode.
263 /// <returns>Notification mode.</returns>
264 /// <since_tizen> 4 </since_tizen>
265 public PropertyNotification.NotifyMode GetNotifyMode()
267 PropertyNotification.NotifyMode ret = (PropertyNotification.NotifyMode)NDalicPINVOKE.PropertyNotification_GetNotifyMode(swigCPtr);
268 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
273 /// Gets the result of the last condition check that caused a signal emit,
274 /// useful when using NotifyOnChanged mode and need to know what it changed to.
276 /// <since_tizen> 4 </since_tizen>
277 public bool GetNotifyResult()
279 bool ret = NDalicPINVOKE.PropertyNotification_GetNotifyResult(swigCPtr);
280 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
285 /// Connects to this signal to be notified when the notification has occurred.
287 /// <returns>A signal object to Connect() with</returns>
288 public PropertyNotifySignal NotifySignal()
290 PropertyNotifySignal ret = new PropertyNotifySignal(NDalicPINVOKE.PropertyNotification_NotifySignal(swigCPtr), false);
291 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296 /// Enumeration for description of how to check condition.
298 /// <since_tizen> 4 </since_tizen>
299 public enum NotifyMode
302 /// Don't notify, regardless of result of Condition
304 /// <since_tizen> 3 </since_tizen>
307 /// Notify whenever condition changes from false to true.
309 /// <since_tizen> 3 </since_tizen>
312 /// Notify whenever condition changes from true to false.
314 /// <since_tizen> 3 </since_tizen>
317 /// Notify whenever condition changes (false to true, and true to false)
319 /// <since_tizen> 3 </since_tizen>