2 * Copyright (c) 2017 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.
19 using System.Runtime.InteropServices;
22 internal class WatchApplication : Application
24 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
26 internal WatchApplication(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
28 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
31 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WatchApplication obj)
33 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
36 protected override void Dispose(DisposeTypes type)
43 if (type == DisposeTypes.Explicit)
46 //Release your own managed resources here.
47 //You should release all of your own disposable objects here.
51 //Release your own unmanaged resources here.
52 //You should not access any managed member here except static instance.
53 //because the execution order of Finalizes is non-deterministic.
54 DisConnectFromSignals();
56 if (swigCPtr.Handle != global::System.IntPtr.Zero)
61 Interop.Watch.delete_WatchApplication(swigCPtr);
63 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
69 private void DisConnectFromSignals()
71 if (_timeTickCallback != null)
73 this.TimeTickSignal().Disconnect(_timeTickCallback);
75 if (_ambientTickCallback != null)
77 this.AmbientTickSignal().Disconnect(_ambientTickCallback);
79 if (_ambientChangedCallback != null)
81 this.AmbientChangedSignal().Disconnect(_ambientChangedCallback);
85 public new static WatchApplication Instance
93 public static WatchApplication NewWatchApplication()
95 WatchApplication ret = New();
96 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
97 // we've got an application now connect the signals
102 public static WatchApplication NewWatchApplication(string[] args)
104 WatchApplication ret = New(args);
105 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
110 public static WatchApplication NewWatchApplication(string[] args, string stylesheet)
112 WatchApplication ret = New(args, stylesheet);
113 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
118 public new static WatchApplication New()
120 WatchApplication ret = new WatchApplication(Interop.Watch.WatchApplication_New__SWIG_0(), true);
121 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125 public static WatchApplication New(string[] args)
127 int argc = args.Length;
128 string argvStr = string.Join(" ", args);
130 WatchApplication ret = new WatchApplication(Interop.Watch.WatchApplication_New__SWIG_1(argc, argvStr), true);
131 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
135 public static WatchApplication New(string[] args, string stylesheet)
137 int argc = args.Length;
138 string argvStr = string.Join(" ", args);
140 WatchApplication ret = new WatchApplication(Interop.Watch.WatchApplication_New__SWIG_2(argc, argvStr, stylesheet), true);
141 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
145 internal WatchApplication(WatchApplication implementation) : this(Interop.Watch.new_WatchApplication__SWIG_1(WatchApplication.getCPtr(implementation)), true)
147 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
151 /// Event arguments that passed via time tick event signal.
153 /// <since_tizen> 4 </since_tizen>
154 public class TimeTickEventArgs : EventArgs
159 /// <since_tizen> 4 </since_tizen>
160 public Application Application
169 /// <since_tizen> 4 </since_tizen>
170 public WatchTime WatchTime
177 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
178 private delegate void TimeTickCallbackType(IntPtr application, IntPtr watchTime);
179 private TimeTickCallbackType _timeTickCallback;
180 private DaliEventHandler<object,TimeTickEventArgs> _timeTickEventHandler;
185 public event DaliEventHandler<object, TimeTickEventArgs> TimeTick
189 if (_timeTickEventHandler == null)
191 _timeTickCallback = new TimeTickCallbackType( OnTimeTick);
192 TimeTickSignal().Connect(_timeTickCallback);
195 _timeTickEventHandler += value;
200 _timeTickEventHandler -= value;
202 if (_timeTickEventHandler == null && TimeTickSignal().Empty() == false)
204 TimeTickSignal().Disconnect(_timeTickCallback);
209 private void OnTimeTick(IntPtr application, IntPtr watchTime)
211 TimeTickEventArgs e = new TimeTickEventArgs();
212 e.Application = this;
213 e.WatchTime = WatchTime.GetWatchTimeFromPtr(watchTime);
215 _timeTickEventHandler?.Invoke(this, e);
219 internal WatchTimeSignal TimeTickSignal()
221 WatchTimeSignal ret = new WatchTimeSignal(Interop.Watch.WatchApplication_TimeTickSignal(swigCPtr), false);
222 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
227 /// Event arguments that passed via ambient tick event signal.
229 /// <since_tizen> 4 </since_tizen>
230 public class AmbientTickEventArgs : EventArgs
235 /// <since_tizen> 4 </since_tizen>
236 public Application Application
245 /// <since_tizen> 4 </since_tizen>
246 public WatchTime WatchTime
253 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
254 private delegate void AmbientTickCallbackType(IntPtr application, IntPtr watchTime);
255 private AmbientTickCallbackType _ambientTickCallback;
256 private DaliEventHandler<object,AmbientTickEventArgs> _ambientTickEventHandler;
259 /// AmbientTick event.
261 public event DaliEventHandler<object, AmbientTickEventArgs> AmbientTick
265 if (_ambientTickEventHandler == null)
267 _ambientTickCallback = new AmbientTickCallbackType( OnAmbientTick);
268 AmbientTickSignal().Connect(_ambientTickCallback);
271 _ambientTickEventHandler += value;
276 _ambientTickEventHandler -= value;
278 if (_ambientTickEventHandler == null && AmbientTickSignal().Empty() == false)
280 AmbientTickSignal().Disconnect(_ambientTickCallback);
285 private void OnAmbientTick(IntPtr application, IntPtr watchTime)
287 AmbientTickEventArgs e = new AmbientTickEventArgs();
289 e.Application = this;
290 e.WatchTime = WatchTime.GetWatchTimeFromPtr(watchTime);
291 _ambientTickEventHandler?.Invoke(this, e);
294 internal WatchTimeSignal AmbientTickSignal()
296 WatchTimeSignal ret = new WatchTimeSignal(Interop.Watch.WatchApplication_AmbientTickSignal(swigCPtr), false);
297 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
302 /// Event arguments that passed via ambient tick event signal.
304 /// <since_tizen> 4 </since_tizen>
305 public class AmbientChangedEventArgs : EventArgs
310 /// <since_tizen> 4 </since_tizen>
311 public Application Application
320 /// <since_tizen> 4 </since_tizen>
328 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
329 private delegate void AmbientChangedCallbackType(IntPtr application, bool changed);
330 private AmbientChangedCallbackType _ambientChangedCallback;
331 private DaliEventHandler<object,AmbientChangedEventArgs> _ambientChangedEventHandler;
334 /// AmbientChanged event.
336 public event DaliEventHandler<object, AmbientChangedEventArgs> AmbientChanged
340 if (_ambientChangedEventHandler == null)
342 _ambientChangedCallback = new AmbientChangedCallbackType( OnAmbientChanged);
343 AmbientChangedSignal().Connect(_ambientChangedCallback);
346 _ambientChangedEventHandler += value;
351 _ambientChangedEventHandler -= value;
353 if (_ambientChangedEventHandler == null && AmbientChangedSignal().Empty() == false)
355 AmbientChangedSignal().Disconnect(_ambientChangedCallback);
360 private void OnAmbientChanged(IntPtr application, bool changed)
362 AmbientChangedEventArgs e = new AmbientChangedEventArgs();
363 e.Application = this;
365 _ambientChangedEventHandler?.Invoke(this, e);
368 internal WatchBoolSignal AmbientChangedSignal()
370 WatchBoolSignal ret = new WatchBoolSignal(Interop.Watch.WatchApplication_AmbientChangedSignal(swigCPtr), false);
371 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
375 private static WatchApplication _instance; //singleton