98ea1031ccbf26f2f763fc05253539e97c7efda0
[platform/core/csapi/nui.git] / Tizen.NUI / src / public / Timer.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.\r
2 *\r
3 * Licensed under the Apache License, Version 2.0 (the "License");\r
4 * you may not use this file except in compliance with the License.\r
5 * You may obtain a copy of the License at\r
6 *\r
7 * http://www.apache.org/licenses/LICENSE-2.0\r
8 *\r
9 * Unless required by applicable law or agreed to in writing, software\r
10 * distributed under the License is distributed on an "AS IS" BASIS,\r
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
12 * See the License for the specific language governing permissions and\r
13 * limitations under the License.\r
14 *\r
15 */\r
16 // This File has been auto-generated by SWIG and then modified using DALi Ruby Scripts\r
17 //------------------------------------------------------------------------------\r
18 // <auto-generated />\r
19 //\r
20 // This file was automatically generated by SWIG (http://www.swig.org).\r
21 // Version 3.0.9\r
22 //\r
23 // Do not make changes to this file unless you know what you are doing--modify\r
24 // the SWIG interface file instead.\r
25 //------------------------------------------------------------------------------\r
26 \r
27 namespace Tizen.NUI\r
28 {\r
29     using System;\r
30     using System.Runtime.InteropServices;\r
31 \r
32 \r
33     public class Timer : BaseHandle\r
34     {\r
35         private global::System.Runtime.InteropServices.HandleRef swigCPtr;\r
36 \r
37         internal Timer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Timer_SWIGUpcast(cPtr), cMemoryOwn)\r
38         {\r
39             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);\r
40         }\r
41 \r
42         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Timer obj)\r
43         {\r
44             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;\r
45         }\r
46 \r
47         ~Timer()\r
48         {\r
49             DisposeQueue.Instance.Add(this);\r
50         }\r
51 \r
52         public override void Dispose()\r
53         {\r
54             if (!Stage.IsInstalled())\r
55             {\r
56                 DisposeQueue.Instance.Add(this);\r
57                 return;\r
58             }\r
59 \r
60             lock (this)\r
61             {\r
62                 if (swigCPtr.Handle != global::System.IntPtr.Zero)\r
63                 {\r
64                     if (swigCMemOwn)\r
65                     {\r
66                         swigCMemOwn = false;\r
67                         NDalicPINVOKE.delete_Timer(swigCPtr);\r
68                     }\r
69                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);\r
70                 }\r
71                 global::System.GC.SuppressFinalize(this);\r
72                 base.Dispose();\r
73             }\r
74         }\r
75 \r
76 \r
77         public Timer(uint milliSec) : this(NDalicPINVOKE.Timer_New(milliSec), true)\r
78         {\r
79             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
80 \r
81         }\r
82         internal Timer(Timer timer) : this(NDalicPINVOKE.new_Timer__SWIG_1(Timer.getCPtr(timer)), true)\r
83         {\r
84             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
85         }\r
86 \r
87         internal Timer Assign(Timer timer)\r
88         {\r
89             Timer ret = new Timer(NDalicPINVOKE.Timer_Assign(swigCPtr, Timer.getCPtr(timer)), false);\r
90             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
91             return ret;\r
92         }\r
93 \r
94         public static Timer DownCast(BaseHandle handle)\r
95         {\r
96             Timer ret = new Timer(NDalicPINVOKE.Timer_DownCast(BaseHandle.getCPtr(handle)), true);\r
97             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
98             return ret;\r
99         }\r
100 \r
101         public void Start()\r
102         {\r
103             NDalicPINVOKE.Timer_Start(swigCPtr);\r
104             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
105         }\r
106 \r
107         public void Stop()\r
108         {\r
109             NDalicPINVOKE.Timer_Stop(swigCPtr);\r
110             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
111         }\r
112 \r
113         public uint Interval\r
114         {\r
115             set\r
116             {\r
117                 SetInterval(value);\r
118             }\r
119             get\r
120             {\r
121                 return GetInterval();\r
122             }\r
123         }\r
124 \r
125         internal void SetInterval(uint milliSec)\r
126         {\r
127             NDalicPINVOKE.Timer_SetInterval(swigCPtr, milliSec);\r
128             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
129         }\r
130 \r
131         internal uint GetInterval()\r
132         {\r
133             uint ret = NDalicPINVOKE.Timer_GetInterval(swigCPtr);\r
134             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
135             return ret;\r
136         }\r
137 \r
138         public bool Running\r
139         {\r
140             get\r
141             {\r
142                 return IsRunning();\r
143             }\r
144         }\r
145 \r
146         internal bool IsRunning()\r
147         {\r
148             bool ret = NDalicPINVOKE.Timer_IsRunning(swigCPtr);\r
149             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
150             return ret;\r
151         }\r
152 \r
153 \r
154 \r
155 \r
156         public TimerSignalType TickSignal()\r
157         {\r
158             TimerSignalType ret = new TimerSignalType(NDalicPINVOKE.Timer_TickSignal(swigCPtr), false);\r
159             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();\r
160             return ret;\r
161         }\r
162 \r
163         private DaliEventHandlerWithReturnType<object, EventArgs, bool> _tickEventHandler;\r
164         [UnmanagedFunctionPointer(CallingConvention.StdCall)]\r
165         internal delegate bool TickCallbackType();\r
166         private TickCallbackType _tickCallBack;\r
167 \r
168         public event DaliEventHandlerWithReturnType<object, EventArgs, bool> Tick\r
169         {\r
170             add\r
171             {\r
172                 if (_tickCallBack == null)\r
173                 {\r
174                     _tickCallBack = OnTick;\r
175                     this.TickSignal().Connect(_tickCallBack);\r
176                 }\r
177                 _tickEventHandler += value;\r
178             }\r
179             remove\r
180             {\r
181                 if (_tickCallBack != null)\r
182                 {\r
183                     this.TickSignal().Disconnect(_tickCallBack);\r
184                     _tickCallBack = null;\r
185                 }\r
186                 _tickEventHandler -= value;\r
187             }\r
188         }\r
189         private bool OnTick()\r
190         {\r
191             if (_tickEventHandler != null)\r
192             {\r
193                 return _tickEventHandler(this, null);\r
194             }\r
195             return false;\r
196         }\r
197 \r
198 \r
199     }\r
200 \r
201 }\r