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 internal class PropertyNotification : BaseHandle
26 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
28 internal PropertyNotification(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PropertyNotification_SWIGUpcast(cPtr), cMemoryOwn)
30 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
33 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyNotification obj)
35 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
38 protected override void Dispose(DisposeTypes type)
45 if (type == DisposeTypes.Explicit)
48 //Release your own managed resources here.
49 //You should release all of your own disposable objects here.
53 //Release your own unmanaged resources here.
54 //You should not access any managed member here except static instance.
55 //because the execution order of Finalizes is non-deterministic.
57 if (swigCPtr.Handle != global::System.IntPtr.Zero)
62 NDalicPINVOKE.delete_PropertyNotification(swigCPtr);
64 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
71 * @brief Event arguments that passed via Notify signal
74 public class NotifyEventArgs : EventArgs
76 private PropertyNotification _propertyNotification;
79 * @brief PropertyNotification - is the PropertyNotification handle that has the notification properties.
82 public PropertyNotification PropertyNotification
86 return _propertyNotification;
90 _propertyNotification = value;
95 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
96 private delegate void NotifyEventCallbackDelegate(IntPtr propertyNotification);
97 private DaliEventHandler<object, NotifyEventArgs> _propertyNotificationNotifyEventHandler;
98 private NotifyEventCallbackDelegate _propertyNotificationNotifyEventCallbackDelegate;
101 * @brief Event for Notified signal which can be used to subscribe/unsubscribe the event handler
102 * (in the type of NotifyEventHandler-DaliEventHandler<object,NotifyEventArgs>) provided by the user.
103 * Notified signal is emitted when the notification upon a condition of the property being met, has occurred.
105 public event DaliEventHandler<object, NotifyEventArgs> Notified
111 // Restricted to only one listener
112 if (_propertyNotificationNotifyEventHandler == null)
114 _propertyNotificationNotifyEventHandler += value;
116 _propertyNotificationNotifyEventCallbackDelegate = new NotifyEventCallbackDelegate(OnPropertyNotificationNotify);
117 this.NotifySignal().Connect(_propertyNotificationNotifyEventCallbackDelegate);
126 if (_propertyNotificationNotifyEventHandler != null)
128 this.NotifySignal().Disconnect(_propertyNotificationNotifyEventCallbackDelegate);
131 _propertyNotificationNotifyEventHandler -= value;
136 // Callback for PropertyNotification NotifySignal
137 private void OnPropertyNotificationNotify(IntPtr propertyNotification)
139 NotifyEventArgs e = new NotifyEventArgs();
140 e.PropertyNotification = GetPropertyNotificationFromPtr(propertyNotification);
142 if (_propertyNotificationNotifyEventHandler != null)
144 //here we send all data to user event handlers
145 _propertyNotificationNotifyEventHandler(this, e);
149 public static PropertyNotification GetPropertyNotificationFromPtr(global::System.IntPtr cPtr)
151 PropertyNotification ret = new PropertyNotification(cPtr, false);
152 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
157 public PropertyNotification() : this(NDalicPINVOKE.new_PropertyNotification__SWIG_0(), true)
159 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162 public static PropertyNotification DownCast(BaseHandle handle)
164 PropertyNotification ret = new PropertyNotification(NDalicPINVOKE.PropertyNotification_DownCast(BaseHandle.getCPtr(handle)), true);
165 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
169 public PropertyNotification(PropertyNotification handle) : this(NDalicPINVOKE.new_PropertyNotification__SWIG_1(PropertyNotification.getCPtr(handle)), true)
171 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
174 public PropertyNotification Assign(PropertyNotification rhs)
176 PropertyNotification ret = new PropertyNotification(NDalicPINVOKE.PropertyNotification_Assign(swigCPtr, PropertyNotification.getCPtr(rhs)), false);
177 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
181 public PropertyCondition GetCondition()
183 PropertyCondition ret = new PropertyCondition(NDalicPINVOKE.PropertyNotification_GetCondition__SWIG_0(swigCPtr), true);
184 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
188 public Animatable GetTarget()
190 Animatable ret = new Animatable(NDalicPINVOKE.PropertyNotification_GetTarget(swigCPtr), true);
191 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
195 public int GetTargetProperty()
197 int ret = NDalicPINVOKE.PropertyNotification_GetTargetProperty(swigCPtr);
198 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
202 public void SetNotifyMode(PropertyNotification.NotifyMode mode)
204 NDalicPINVOKE.PropertyNotification_SetNotifyMode(swigCPtr, (int)mode);
205 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
208 public PropertyNotification.NotifyMode GetNotifyMode()
210 PropertyNotification.NotifyMode ret = (PropertyNotification.NotifyMode)NDalicPINVOKE.PropertyNotification_GetNotifyMode(swigCPtr);
211 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215 public bool GetNotifyResult()
217 bool ret = NDalicPINVOKE.PropertyNotification_GetNotifyResult(swigCPtr);
218 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
222 public PropertyNotifySignal NotifySignal()
224 PropertyNotifySignal ret = new PropertyNotifySignal(NDalicPINVOKE.PropertyNotification_NotifySignal(swigCPtr), false);
225 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
229 public enum NotifyMode