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 private delegate bool TickCallbackDelegate(IntPtr data);
39 private DaliEventHandlerWithReturnType<object,TickEventArgs,bool> _timerTickEventHandler;
40 private TickCallbackDelegate _timerTickCallbackDelegate;
43 * @brief Event for Ticked signal which can be used to subscribe/unsubscribe the event handler
44 * (in the type of TickEventHandler-DaliEventHandlerWithReturnType<object,TickEventArgs,bool>)
45 * provided by the user. Ticked signal is emitted after specified time interval.
47 public event DaliEventHandlerWithReturnType<object,TickEventArgs,bool> Tick
53 // Restricted to only one listener
54 if (_timerTickEventHandler == null)
56 _timerTickEventHandler += value;
58 _timerTickCallbackDelegate = new TickCallbackDelegate(OnTick);
59 this.TickSignal().Connect(_timerTickCallbackDelegate);
68 if (_timerTickEventHandler != null)
70 this.TickSignal().Disconnect(_timerTickCallbackDelegate);
73 _timerTickEventHandler -= value;
78 // Callback for Timer Tick signal
79 private bool OnTick(IntPtr data)
81 TickEventArgs e = new TickEventArgs();
83 if (_timerTickEventHandler != null)
85 //here we send all data to user event handlers
86 return _timerTickEventHandler(this, e);
96 %define DALI_TIMER_EVENTHANDLER_PARAM( NameSpace, ClassName)
98 TIMER_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
99 TIMER_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
105 DALI_TIMER_EVENTHANDLER_PARAM( Dali, Timer);