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.
16 // This File has been auto-generated by SWIG and then modified using DALi Ruby Scripts
17 //------------------------------------------------------------------------------
20 // This file was automatically generated by SWIG (http://www.swig.org).
23 // Do not make changes to this file unless you know what you are doing--modify
24 // the SWIG interface file instead.
25 //------------------------------------------------------------------------------
30 using System.Runtime.InteropServices;
33 public class Timer : BaseHandle {
34 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
36 internal Timer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Timer_SWIGUpcast(cPtr), cMemoryOwn) {
37 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
40 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Timer obj) {
41 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
45 DisposeQueue.Instance.Add(this);
48 public override void Dispose() {
49 if (!Window.IsInstalled()) {
50 DisposeQueue.Instance.Add(this);
55 if (swigCPtr.Handle != global::System.IntPtr.Zero) {
58 NDalicPINVOKE.delete_Timer(swigCPtr);
60 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
62 global::System.GC.SuppressFinalize(this);
70 * @brief Event arguments that passed via Tick signal
73 public class TickEventArgs : EventArgs
77 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
78 private delegate bool TickCallbackDelegate(IntPtr data);
79 private DaliEventHandlerWithReturnType<object,TickEventArgs,bool> _timerTickEventHandler;
80 private TickCallbackDelegate _timerTickCallbackDelegate;
83 * @brief Event for Ticked signal which can be used to subscribe/unsubscribe the event handler
84 * (in the type of TickEventHandler-DaliEventHandlerWithReturnType<object,TickEventArgs,bool>)
85 * provided by the user. Ticked signal is emitted after specified time interval.
87 public event DaliEventHandlerWithReturnType<object,TickEventArgs,bool> Tick
93 // Restricted to only one listener
94 if (_timerTickEventHandler == null)
96 _timerTickEventHandler += value;
98 _timerTickCallbackDelegate = new TickCallbackDelegate(OnTick);
99 this.TickSignal().Connect(_timerTickCallbackDelegate);
108 if (_timerTickEventHandler != null)
110 this.TickSignal().Disconnect(_timerTickCallbackDelegate);
113 _timerTickEventHandler -= value;
118 // Callback for Timer Tick signal
119 private bool OnTick(IntPtr data)
121 TickEventArgs e = new TickEventArgs();
123 if (_timerTickEventHandler != null)
125 //here we send all data to user event handlers
126 return _timerTickEventHandler(this, e);
132 public Timer (uint milliSec) : this (NDalicPINVOKE.Timer_New(milliSec), true) {
133 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
136 public Timer(Timer timer) : this(NDalicPINVOKE.new_Timer__SWIG_1(Timer.getCPtr(timer)), true) {
137 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
140 public Timer Assign(Timer timer) {
141 Timer ret = new Timer(NDalicPINVOKE.Timer_Assign(swigCPtr, Timer.getCPtr(timer)), false);
142 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
146 public static Timer DownCast(BaseHandle handle) {
147 Timer ret = new Timer(NDalicPINVOKE.Timer_DownCast(BaseHandle.getCPtr(handle)), true);
148 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
152 public void Start() {
153 NDalicPINVOKE.Timer_Start(swigCPtr);
154 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
158 NDalicPINVOKE.Timer_Stop(swigCPtr);
159 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162 public void SetInterval(uint milliSec) {
163 NDalicPINVOKE.Timer_SetInterval(swigCPtr, milliSec);
164 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
167 public uint GetInterval() {
168 uint ret = NDalicPINVOKE.Timer_GetInterval(swigCPtr);
169 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
173 public bool IsRunning() {
174 bool ret = NDalicPINVOKE.Timer_IsRunning(swigCPtr);
175 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
179 public TimerSignalType TickSignal() {
180 TimerSignalType ret = new TimerSignalType(NDalicPINVOKE.Timer_TickSignal(swigCPtr), false);
181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();