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 private DaliEventHandler<object, NotifyEventArgs> _propertyNotificationNotifyEventHandler;
34 private NotifyEventCallbackDelegate _propertyNotificationNotifyEventCallbackDelegate;
37 /// Create a instance of PropertyNotification.
39 /// <since_tizen> 4 </since_tizen>
40 public PropertyNotification() : this(NDalicPINVOKE.new_PropertyNotification__SWIG_0(), true)
42 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
46 /// Create a instance of PropertyNotification.
48 /// <since_tizen> 4 </since_tizen>
49 public PropertyNotification(PropertyNotification handle) : this(NDalicPINVOKE.new_PropertyNotification__SWIG_1(PropertyNotification.getCPtr(handle)), true)
51 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
54 internal PropertyNotification(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PropertyNotification_SWIGUpcast(cPtr), cMemoryOwn)
56 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
59 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
60 private delegate void NotifyEventCallbackDelegate(IntPtr propertyNotification);
63 /// Event for Notified signal which can be used to subscribe/unsubscribe the event handler
64 /// Notified signal is emitted when the notification upon a condition of the property being met, has occurred.
66 /// <since_tizen> 4 </since_tizen>
67 public event DaliEventHandler<object, NotifyEventArgs> Notified
73 // Restricted to only one listener
74 if (_propertyNotificationNotifyEventHandler == null)
76 _propertyNotificationNotifyEventHandler += value;
78 _propertyNotificationNotifyEventCallbackDelegate = new NotifyEventCallbackDelegate(OnPropertyNotificationNotify);
79 this.NotifySignal().Connect(_propertyNotificationNotifyEventCallbackDelegate);
88 if (_propertyNotificationNotifyEventHandler != null)
90 this.NotifySignal().Disconnect(_propertyNotificationNotifyEventCallbackDelegate);
93 _propertyNotificationNotifyEventHandler -= value;
99 /// Enumeration for description of how to check condition.
101 /// <since_tizen> 3 </since_tizen>
102 public enum NotifyMode
105 /// Don't notify, regardless of result of Condition
107 /// <since_tizen> 3 </since_tizen>
110 /// Notify whenever condition changes from false to true.
112 /// <since_tizen> 3 </since_tizen>
115 /// Notify whenever condition changes from true to false.
117 /// <since_tizen> 3 </since_tizen>
120 /// Notify whenever condition changes (false to true, and true to false)
122 /// <since_tizen> 3 </since_tizen>
127 /// Get property notification from Intptr.<br/>
128 /// This should be internal, please do not use.
130 /// <param name="cPtr">An object of IntPtr type.</param>
131 /// <returns>An object of the PropertyNotification type.</returns>
132 /// <since_tizen> 4 </since_tizen>
133 public static PropertyNotification GetPropertyNotificationFromPtr(global::System.IntPtr cPtr)
135 PropertyNotification ret = new PropertyNotification(cPtr, false);
136 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
141 /// Downcast a PropertyNotification instance.
143 /// <param name="handle">Handle to an object of BaseHandle type.</param>
144 /// <returns>Handle to an object of the PropertyNotification type.</returns>
145 /// <since_tizen> 4 </since_tizen>
146 public static PropertyNotification DownCast(BaseHandle handle)
148 PropertyNotification ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PropertyNotification;
149 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
156 /// <param name="rhs">A reference to the copied handle.</param>
157 /// <returns>A reference to this.</returns>
158 /// <since_tizen> 4 </since_tizen>
159 public PropertyNotification Assign(PropertyNotification rhs)
161 PropertyNotification ret = new PropertyNotification(NDalicPINVOKE.PropertyNotification_Assign(swigCPtr, PropertyNotification.getCPtr(rhs)), false);
162 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
167 /// Gets the condition of this notification.
169 /// <returns>The condition is returned.</returns>
170 /// <since_tizen> 4 </since_tizen>
171 public PropertyCondition GetCondition()
173 PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.PropertyNotification_GetCondition__SWIG_0(swigCPtr), true);
174 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
179 /// Gets the target handle that this notification is observing.
181 /// <since_tizen> 4 </since_tizen>
182 public Animatable GetTarget()
184 Animatable ret = new Animatable(NDalicPINVOKE.PropertyNotification_GetTarget(swigCPtr), true);
185 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190 /// Gets the target handle's property index that this notification.
192 /// <returns>The target property index.</returns>
193 /// <since_tizen> 4 </since_tizen>
194 public int GetTargetProperty()
196 int ret = NDalicPINVOKE.PropertyNotification_GetTargetProperty(swigCPtr);
197 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
202 /// Sets the Notification mode.
204 /// <param name="mode">mode Notification mode (Default is PropertyNotification::NotifyOnTrue).</param>
205 /// <since_tizen> 4 </since_tizen>
206 public void SetNotifyMode(PropertyNotification.NotifyMode mode)
208 NDalicPINVOKE.PropertyNotification_SetNotifyMode(swigCPtr, (int)mode);
209 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213 /// Retrieves the current Notification mode.
215 /// <returns>Notification mode.</returns>
216 /// <since_tizen> 4 </since_tizen>
217 public PropertyNotification.NotifyMode GetNotifyMode()
219 PropertyNotification.NotifyMode ret = (PropertyNotification.NotifyMode)NDalicPINVOKE.PropertyNotification_GetNotifyMode(swigCPtr);
220 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225 /// Gets the result of the last condition check that caused a signal emit,
226 /// useful when using NotifyOnChanged mode and need to know what it changed to.
228 /// <since_tizen> 4 </since_tizen>
229 public bool GetNotifyResult()
231 bool ret = NDalicPINVOKE.PropertyNotification_GetNotifyResult(swigCPtr);
232 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
237 /// Connects to this signal to be notified when the notification has occurred.
239 /// <returns>A signal object to Connect() with</returns>
240 /// <since_tizen> 4 </since_tizen>
241 public PropertyNotifySignal NotifySignal()
243 PropertyNotifySignal ret = new PropertyNotifySignal(NDalicPINVOKE.PropertyNotification_NotifySignal(swigCPtr), false);
244 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
248 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyNotification obj)
250 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
256 /// <since_tizen> 4 </since_tizen>
257 protected override void Dispose(DisposeTypes type)
264 if (type == DisposeTypes.Explicit)
267 //Release your own managed resources here.
268 //You should release all of your own disposable objects here.
272 //Release your own unmanaged resources here.
273 //You should not access any managed member here except static instance.
274 //because the execution order of Finalizes is non-deterministic.
276 if (swigCPtr.Handle != global::System.IntPtr.Zero)
281 NDalicPINVOKE.delete_PropertyNotification(swigCPtr);
283 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
289 // Callback for PropertyNotification NotifySignal
290 private void OnPropertyNotificationNotify(IntPtr propertyNotification)
292 NotifyEventArgs e = new NotifyEventArgs();
293 e.PropertyNotification = GetPropertyNotificationFromPtr(propertyNotification);
295 if (_propertyNotificationNotifyEventHandler != null)
297 //here we send all data to user event handlers
298 _propertyNotificationNotifyEventHandler(this, e);
303 /// Event arguments that passed via Notify signal
305 /// <since_tizen> 3 </since_tizen>
306 public class NotifyEventArgs : EventArgs
308 private PropertyNotification _propertyNotification;
311 /// PropertyNotification - is the PropertyNotification handle that has the notification properties.
313 /// <since_tizen> 3 </since_tizen>
314 public PropertyNotification PropertyNotification
318 return _propertyNotification;
322 _propertyNotification = value;