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 IMAGE_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
21 using System.Runtime.InteropServices;
26 %define IMAGE_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
27 %typemap(cscode) NameSpace::ClassName %{
31 * @brief Event arguments that passed via Uploaded signal
34 public class UploadedEventArgs : EventArgs
38 * @brief Image - is the image data that gets uploaded to GL.
54 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
55 public delegate void UploadedEventHandler(object source, UploadedEventArgs e);
57 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
58 private delegate void UploadedEventCallbackDelegate(IntPtr image);
59 private UploadedEventHandler _imageUploadedEventHandler;
60 private UploadedEventCallbackDelegate _imageUploadedEventCallbackDelegate;
63 * @brief Event for Uploaded signal which can be used to subscribe/unsubscribe the event handler
64 * (in the type of UploadedEventHandler) provided by the user.
65 * Uploaded signal is emitted when the image data gets uploaded to GL.
67 public event UploadedEventHandler Uploaded
73 // Restricted to only one listener
74 if (_imageUploadedEventHandler == null)
76 _imageUploadedEventHandler += value;
78 _imageUploadedEventCallbackDelegate = new UploadedEventCallbackDelegate(OnUploaded);
79 this.UploadedSignal().Connect(_imageUploadedEventCallbackDelegate);
88 if (_imageUploadedEventHandler != null)
90 this.UploadedSignal().Disconnect(_imageUploadedEventCallbackDelegate);
93 _imageUploadedEventHandler -= value;
98 // Callback for Image UploadedSignal
99 private void OnUploaded(IntPtr data)
101 UploadedEventArgs e = new UploadedEventArgs();
103 // Populate all members of "e" (UploadedEventArgs) with real data
104 e.Image = Image.GetImageFromPtr(data);
106 if (_imageUploadedEventHandler != null)
108 //here we send all data to user event handlers
109 _imageUploadedEventHandler(this, e);
114 public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) {
115 ClassName ret = new ClassName(cPtr, false);
116 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125 %define DALI_IMAGE_EVENTHANDLER_PARAM( NameSpace, ClassName)
126 IMAGE_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
127 IMAGE_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
132 DALI_IMAGE_EVENTHANDLER_PARAM( Dali, Image);