1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
21 using System.Runtime.InteropServices;
24 /// Issues a notification upon a condition of the property being met.
25 /// See PropertyCondition for available defined conditions.
27 public class PropertyNotification : BaseHandle
29 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
31 internal PropertyNotification(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PropertyNotification_SWIGUpcast(cPtr), cMemoryOwn)
33 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
36 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyNotification obj)
38 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
41 protected override void Dispose(DisposeTypes type)
48 if (type == DisposeTypes.Explicit)
51 //Release your own managed resources here.
52 //You should release all of your own disposable objects here.
56 //Release your own unmanaged resources here.
57 //You should not access any managed member here except static instance.
58 //because the execution order of Finalizes is non-deterministic.
60 if (swigCPtr.Handle != global::System.IntPtr.Zero)
65 NDalicPINVOKE.delete_PropertyNotification(swigCPtr);
67 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
74 * @brief Event arguments that passed via Notify signal
77 public class NotifyEventArgs : EventArgs
79 private PropertyNotification _propertyNotification;
82 * @brief PropertyNotification - is the PropertyNotification handle that has the notification properties.
85 public PropertyNotification PropertyNotification
89 return _propertyNotification;
93 _propertyNotification = value;
98 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
99 private delegate void NotifyEventCallbackDelegate(IntPtr propertyNotification);
100 private DaliEventHandler<object, NotifyEventArgs> _propertyNotificationNotifyEventHandler;
101 private NotifyEventCallbackDelegate _propertyNotificationNotifyEventCallbackDelegate;
104 * @brief Event for Notified signal which can be used to subscribe/unsubscribe the event handler
105 * (in the type of NotifyEventHandler-DaliEventHandler<object,NotifyEventArgs>) provided by the user.
106 * Notified signal is emitted when the notification upon a condition of the property being met, has occurred.
108 public event DaliEventHandler<object, NotifyEventArgs> Notified
114 // Restricted to only one listener
115 if (_propertyNotificationNotifyEventHandler == null)
117 _propertyNotificationNotifyEventHandler += value;
119 _propertyNotificationNotifyEventCallbackDelegate = new NotifyEventCallbackDelegate(OnPropertyNotificationNotify);
120 this.NotifySignal().Connect(_propertyNotificationNotifyEventCallbackDelegate);
129 if (_propertyNotificationNotifyEventHandler != null)
131 this.NotifySignal().Disconnect(_propertyNotificationNotifyEventCallbackDelegate);
134 _propertyNotificationNotifyEventHandler -= value;
139 // Callback for PropertyNotification NotifySignal
140 private void OnPropertyNotificationNotify(IntPtr propertyNotification)
142 NotifyEventArgs e = new NotifyEventArgs();
143 e.PropertyNotification = GetPropertyNotificationFromPtr(propertyNotification);
145 if (_propertyNotificationNotifyEventHandler != null)
147 //here we send all data to user event handlers
148 _propertyNotificationNotifyEventHandler(this, e);
152 public static PropertyNotification GetPropertyNotificationFromPtr(global::System.IntPtr cPtr)
154 PropertyNotification ret = new PropertyNotification(cPtr, false);
155 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160 public PropertyNotification() : this(NDalicPINVOKE.new_PropertyNotification__SWIG_0(), true)
162 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
165 public static PropertyNotification DownCast(BaseHandle handle)
167 PropertyNotification ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PropertyNotification;
168 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
172 public PropertyNotification(PropertyNotification handle) : this(NDalicPINVOKE.new_PropertyNotification__SWIG_1(PropertyNotification.getCPtr(handle)), true)
174 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
177 public PropertyNotification Assign(PropertyNotification rhs)
179 PropertyNotification ret = new PropertyNotification(NDalicPINVOKE.PropertyNotification_Assign(swigCPtr, PropertyNotification.getCPtr(rhs)), false);
180 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184 public PropertyCondition GetCondition()
186 PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.PropertyNotification_GetCondition__SWIG_0(swigCPtr), true);
187 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191 public Animatable GetTarget()
193 Animatable ret = new Animatable(NDalicPINVOKE.PropertyNotification_GetTarget(swigCPtr), true);
194 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198 public int GetTargetProperty()
200 int ret = NDalicPINVOKE.PropertyNotification_GetTargetProperty(swigCPtr);
201 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
205 public void SetNotifyMode(PropertyNotification.NotifyMode mode)
207 NDalicPINVOKE.PropertyNotification_SetNotifyMode(swigCPtr, (int)mode);
208 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
211 public PropertyNotification.NotifyMode GetNotifyMode()
213 PropertyNotification.NotifyMode ret = (PropertyNotification.NotifyMode)NDalicPINVOKE.PropertyNotification_GetNotifyMode(swigCPtr);
214 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
218 public bool GetNotifyResult()
220 bool ret = NDalicPINVOKE.PropertyNotification_GetNotifyResult(swigCPtr);
221 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225 public PropertyNotifySignal NotifySignal()
227 PropertyNotifySignal ret = new PropertyNotifySignal(NDalicPINVOKE.PropertyNotification_NotifySignal(swigCPtr), false);
228 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232 public enum NotifyMode