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.
159 /// <since_tizen> 4 </since_tizen>
160 public static PropertyNotification GetPropertyNotificationFromPtr(global::System.IntPtr cPtr)
162 PropertyNotification ret = new PropertyNotification(cPtr, false);
163 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
168 /// Create a instance of PropertyNotification.
170 /// <since_tizen> 4 </since_tizen>
171 public PropertyNotification() : this(NDalicPINVOKE.new_PropertyNotification__SWIG_0(), true)
173 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
177 /// Downcast a PropertyNotification instance.
179 /// <since_tizen> 4 </since_tizen>
180 public static PropertyNotification DownCast(BaseHandle handle)
182 PropertyNotification ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PropertyNotification;
183 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
188 /// Create a instance of PropertyNotification.
190 /// <since_tizen> 4 </since_tizen>
191 public PropertyNotification(PropertyNotification handle) : this(NDalicPINVOKE.new_PropertyNotification__SWIG_1(PropertyNotification.getCPtr(handle)), true)
193 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
199 /// <since_tizen> 4 </since_tizen>
200 public PropertyNotification Assign(PropertyNotification rhs)
202 PropertyNotification ret = new PropertyNotification(NDalicPINVOKE.PropertyNotification_Assign(swigCPtr, PropertyNotification.getCPtr(rhs)), false);
203 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
208 /// Gets the condition of this notification.
210 /// <since_tizen> 4 </since_tizen>
211 public PropertyCondition GetCondition()
213 PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.PropertyNotification_GetCondition__SWIG_0(swigCPtr), true);
214 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
219 /// Gets the target handle that this notification is observing.
221 /// <since_tizen> 4 </since_tizen>
222 public Animatable GetTarget()
224 Animatable ret = new Animatable(NDalicPINVOKE.PropertyNotification_GetTarget(swigCPtr), true);
225 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
230 /// Gets the target handle's property index that this notification.
232 /// <since_tizen> 4 </since_tizen>
233 public int GetTargetProperty()
235 int ret = NDalicPINVOKE.PropertyNotification_GetTargetProperty(swigCPtr);
236 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
241 /// Sets the Notification mode.
243 /// <since_tizen> 4 </since_tizen>
244 public void SetNotifyMode(PropertyNotification.NotifyMode mode)
246 NDalicPINVOKE.PropertyNotification_SetNotifyMode(swigCPtr, (int)mode);
247 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
251 /// Retrieves the current Notification mode.
253 /// <since_tizen> 4 </since_tizen>
254 public PropertyNotification.NotifyMode GetNotifyMode()
256 PropertyNotification.NotifyMode ret = (PropertyNotification.NotifyMode)NDalicPINVOKE.PropertyNotification_GetNotifyMode(swigCPtr);
257 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262 /// Gets the result of the last condition check that caused a signal emit,
263 /// useful when using NotifyOnChanged mode and need to know what it changed to.
265 /// <since_tizen> 4 </since_tizen>
266 public bool GetNotifyResult()
268 bool ret = NDalicPINVOKE.PropertyNotification_GetNotifyResult(swigCPtr);
269 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
274 /// Connects to this signal to be notified when the notification has occurred.
276 /// <returns>A signal object to Connect() with</returns>
277 public PropertyNotifySignal NotifySignal()
279 PropertyNotifySignal ret = new PropertyNotifySignal(NDalicPINVOKE.PropertyNotification_NotifySignal(swigCPtr), false);
280 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
285 /// Enumeration for description of how to check condition.
287 /// <since_tizen> 4 </since_tizen>
288 public enum NotifyMode
291 /// Don't notify, regardless of result of Condition
293 /// <since_tizen> 3 </since_tizen>
296 /// Notify whenever condition changes from false to true.
298 /// <since_tizen> 3 </since_tizen>
301 /// Notify whenever condition changes from true to false.
303 /// <since_tizen> 3 </since_tizen>
306 /// Notify whenever condition changes (false to true, and true to false)
308 /// <since_tizen> 3 </since_tizen>