2 * Copyright (c) 2016 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.
18 %define PROPERTYNOTIFICATION_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
21 using System.Runtime.InteropServices;
28 %define PROPERTYNOTIFICATION_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
29 %typemap(cscode) NameSpace::ClassName %{
32 * @brief Event arguments that passed via Notify signal
35 public class NotifyEventArgs : EventArgs
37 private PropertyNotification _propertyNotification;
40 * @brief PropertyNotification - is the PropertyNotification handle that has the notification properties.
43 public PropertyNotification PropertyNotification
47 return _propertyNotification;
51 _propertyNotification = value;
56 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
57 public delegate void NotifyEventHandler(object source, NotifyEventArgs e);
59 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
60 private delegate void NotifyEventCallbackDelegate(IntPtr propertyNotification);
61 private NotifyEventHandler _propertyNotificationNotifyEventHandler;
62 private NotifyEventCallbackDelegate _propertyNotificationNotifyEventCallbackDelegate;
65 * @brief Event for Notified signal which can be used to subscribe/unsubscribe the event handler
66 * (in the type of NotifyEventHandler) provided by the user.
67 * Notified signal is emitted when the notification upon a condition of the property being met, has occurred.
69 public event NotifyEventHandler 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;
100 // Callback for PropertyNotification NotifySignal
101 private void OnPropertyNotificationNotify(IntPtr propertyNotification)
103 NotifyEventArgs e = new NotifyEventArgs();
104 e.PropertyNotification = GetPropertyNotificationFromPtr(propertyNotification);
106 if (_propertyNotificationNotifyEventHandler != null)
108 //here we send all data to user event handlers
109 _propertyNotificationNotifyEventHandler(this, e);
113 public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) {
114 ClassName ret = new ClassName(cPtr, false);
115 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
122 %define DALI_PROPERTYNOTIFICATION_EVENTHANDLER_PARAM( NameSpace, ClassName)
123 PROPERTYNOTIFICATION_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
124 PROPERTYNOTIFICATION_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
129 DALI_PROPERTYNOTIFICATION_EVENTHANDLER_PARAM( Dali, PropertyNotification);