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.
19 using System.Runtime.InteropServices;
20 using System.ComponentModel;
27 /// Issues a notification upon a condition of the property being met.
28 /// See PropertyCondition for available defined conditions.
30 /// <since_tizen> 4 </since_tizen>
31 public class PropertyNotification : BaseHandle
33 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
35 private DaliEventHandler<object, NotifyEventArgs> _propertyNotificationNotifyEventHandler;
36 private NotifyEventCallbackDelegate _propertyNotificationNotifyEventCallbackDelegate;
39 /// Create a instance of PropertyNotification.
41 /// <since_tizen> 4 </since_tizen>
42 public PropertyNotification() : this(Interop.PropertyNotification.new_PropertyNotification__SWIG_0(), true)
44 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
48 /// Create a instance of PropertyNotification.
50 /// <since_tizen> 4 </since_tizen>
51 public PropertyNotification(PropertyNotification handle) : this(Interop.PropertyNotification.new_PropertyNotification__SWIG_1(PropertyNotification.getCPtr(handle)), true)
53 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
56 internal PropertyNotification(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.PropertyNotification.PropertyNotification_SWIGUpcast(cPtr), cMemoryOwn)
58 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
61 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
62 private delegate void NotifyEventCallbackDelegate(IntPtr propertyNotification);
65 /// Event for Notified signal which can be used to subscribe/unsubscribe the event handler
66 /// Notified signal is emitted when the notification upon a condition of the property being met, has occurred.
68 /// <since_tizen> 4 </since_tizen>
69 public event DaliEventHandler<object, NotifyEventArgs> Notified
75 // Restricted to only one listener
76 if (_propertyNotificationNotifyEventHandler == null)
78 _propertyNotificationNotifyEventHandler += value;
80 _propertyNotificationNotifyEventCallbackDelegate = new NotifyEventCallbackDelegate(OnPropertyNotificationNotify);
81 this.NotifySignal().Connect(_propertyNotificationNotifyEventCallbackDelegate);
90 if (_propertyNotificationNotifyEventHandler != null)
92 this.NotifySignal().Disconnect(_propertyNotificationNotifyEventCallbackDelegate);
95 _propertyNotificationNotifyEventHandler -= value;
101 /// Enumeration for description of how to check condition.
103 /// <since_tizen> 3 </since_tizen>
104 public enum NotifyMode
107 /// Don't notify, regardless of result of Condition
109 /// <since_tizen> 3 </since_tizen>
112 /// Notify whenever condition changes from false to true.
114 /// <since_tizen> 3 </since_tizen>
117 /// Notify whenever condition changes from true to false.
119 /// <since_tizen> 3 </since_tizen>
122 /// Notify whenever condition changes (false to true, and true to false)
124 /// <since_tizen> 3 </since_tizen>
129 /// Get property notification from Intptr.<br/>
130 /// This should be internal, please do not use.
132 /// <param name="cPtr">An object of IntPtr type.</param>
133 /// <returns>An object of the PropertyNotification type.</returns>
134 /// <since_tizen> 4 </since_tizen>
135 public static PropertyNotification GetPropertyNotificationFromPtr(global::System.IntPtr cPtr)
137 PropertyNotification ret = new PropertyNotification(cPtr, false);
138 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
143 /// Downcast a PropertyNotification instance.
145 /// <param name="handle">Handle to an object of BaseHandle type.</param>
146 /// <returns>Handle to an object of the PropertyNotification type.</returns>
147 /// <since_tizen> 4 </since_tizen>
148 public static PropertyNotification DownCast(BaseHandle handle)
150 PropertyNotification ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PropertyNotification;
151 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
158 /// <param name="rhs">A reference to the copied handle.</param>
159 /// <returns>A reference to this.</returns>
160 /// <since_tizen> 4 </since_tizen>
161 public PropertyNotification Assign(PropertyNotification rhs)
163 PropertyNotification ret = new PropertyNotification(Interop.PropertyNotification.PropertyNotification_Assign(swigCPtr, PropertyNotification.getCPtr(rhs)), false);
164 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
169 /// Gets the condition of this notification.
171 /// <returns>The condition is returned.</returns>
172 /// <since_tizen> 4 </since_tizen>
173 public PropertyCondition GetCondition()
175 PropertyCondition ret = new PropertyCondition(Interop.PropertyNotification.PropertyNotification_GetCondition__SWIG_0(swigCPtr), true);
176 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
181 /// Gets the target handle that this notification is observing.
183 /// <since_tizen> 4 </since_tizen>
184 public Animatable GetTarget()
186 Animatable ret = new Animatable(Interop.PropertyNotification.PropertyNotification_GetTarget(swigCPtr), true);
187 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
192 /// Gets the target handle's property index that this notification.
194 /// <returns>The target property index.</returns>
195 /// <since_tizen> 4 </since_tizen>
196 public int GetTargetProperty()
198 int ret = Interop.PropertyNotification.PropertyNotification_GetTargetProperty(swigCPtr);
199 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
204 /// Sets the Notification mode.
206 /// <param name="mode">mode Notification mode (Default is PropertyNotification::NotifyOnTrue).</param>
207 /// <since_tizen> 4 </since_tizen>
208 public void SetNotifyMode(PropertyNotification.NotifyMode mode)
210 Interop.PropertyNotification.PropertyNotification_SetNotifyMode(swigCPtr, (int)mode);
211 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215 /// Retrieves the current Notification mode.
217 /// <returns>Notification mode.</returns>
218 /// <since_tizen> 4 </since_tizen>
219 public PropertyNotification.NotifyMode GetNotifyMode()
221 PropertyNotification.NotifyMode ret = (PropertyNotification.NotifyMode)Interop.PropertyNotification.PropertyNotification_GetNotifyMode(swigCPtr);
222 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
227 /// Gets the result of the last condition check that caused a signal emit,
228 /// useful when using NotifyOnChanged mode and need to know what it changed to.
230 /// <since_tizen> 4 </since_tizen>
231 public bool GetNotifyResult()
233 bool ret = Interop.PropertyNotification.PropertyNotification_GetNotifyResult(swigCPtr);
234 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
239 /// Connects to this signal to be notified when the notification has occurred.
241 /// <returns>A signal object to Connect() with</returns>
242 /// <since_tizen> 4 </since_tizen>
243 public PropertyNotifySignal NotifySignal()
245 PropertyNotifySignal ret = new PropertyNotifySignal(Interop.PropertyNotification.PropertyNotification_NotifySignal(swigCPtr), false);
246 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
250 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyNotification obj)
252 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
258 /// <since_tizen> 4 </since_tizen>
259 protected override void Dispose(DisposeTypes type)
266 //Release your own unmanaged resources here.
267 //You should not access any managed member here except static instance.
268 //because the execution order of Finalizes is non-deterministic.
270 if (swigCPtr.Handle != global::System.IntPtr.Zero)
275 Interop.PropertyNotification.delete_PropertyNotification(swigCPtr);
277 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
283 // Callback for PropertyNotification NotifySignal
284 private void OnPropertyNotificationNotify(IntPtr propertyNotification)
286 NotifyEventArgs e = new NotifyEventArgs();
287 e.PropertyNotification = GetPropertyNotificationFromPtr(propertyNotification);
289 if (_propertyNotificationNotifyEventHandler != null)
291 //here we send all data to user event handlers
292 _propertyNotificationNotifyEventHandler(this, e);
297 /// Event arguments that passed via Notify signal
299 /// <since_tizen> 3 </since_tizen>
300 public class NotifyEventArgs : EventArgs
302 private PropertyNotification _propertyNotification;
305 /// PropertyNotification - is the PropertyNotification handle that has the notification properties.
307 /// <since_tizen> 3 </since_tizen>
308 public PropertyNotification PropertyNotification
312 return _propertyNotification;
316 _propertyNotification = value;