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 TIMER_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
21 using System.Runtime.InteropServices;
26 %define TIMER_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
27 %typemap(cscode) NameSpace::ClassName %{
30 * @brief Event arguments that passed via Tick signal
33 public class TickEventArgs : EventArgs
37 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
38 public delegate bool TickEventHandler(object source, TickEventArgs e);
40 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
41 private delegate bool TickCallbackDelegate(IntPtr data);
42 private TickEventHandler _timerTickEventHandler;
43 private TickCallbackDelegate _timerTickCallbackDelegate;
46 * @brief Event for Ticked signal which can be used to subscribe/unsubscribe the event handler
47 * (in the type of TickEventHandler) provided by the user.
48 * Ticked signal is emitted after specified time interval.
50 public event TickEventHandler Ticked
56 // Restricted to only one listener
57 if (_timerTickEventHandler == null)
59 _timerTickEventHandler += value;
61 _timerTickCallbackDelegate = new TickCallbackDelegate(OnTick);
62 this.TickSignal().Connect(_timerTickCallbackDelegate);
71 if (_timerTickEventHandler != null)
73 this.TickSignal().Disconnect(_timerTickCallbackDelegate);
76 _timerTickEventHandler -= value;
81 // Callback for Timer Tick signal
82 private bool OnTick(IntPtr data)
84 TickEventArgs e = new TickEventArgs();
86 if (_timerTickEventHandler != null)
88 //here we send all data to user event handlers
89 return _timerTickEventHandler(this, e);
99 %define DALI_TIMER_EVENTHANDLER_PARAM( NameSpace, ClassName)
101 TIMER_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
102 TIMER_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
108 DALI_TIMER_EVENTHANDLER_PARAM( Dali::Adaptor, Timer);