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 NDalicManualPINVOKE.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(NDalicManualPINVOKE.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(NDalicManualPINVOKE.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(NDalicManualPINVOKE.WatchApplication_New__SWIG_2(argc, argvStr, stylesheet), true);
141 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
145 internal WatchApplication(WatchApplication implementation) : this(NDalicManualPINVOKE.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 if (application != null)
214 e.Application = Application.GetApplicationFromPtr(application);
216 if(watchTime != null)
218 e.WatchTime = WatchTime.GetWatchTimeFromPtr(watchTime);
221 _timeTickEventHandler?.Invoke(this, e);
224 internal WatchTimeSignal TimeTickSignal()
226 WatchTimeSignal ret = new WatchTimeSignal(NDalicManualPINVOKE.WatchApplication_TimeTickSignal(swigCPtr), false);
227 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232 /// Event arguments that passed via ambient tick event signal.
234 /// <since_tizen> 4 </since_tizen>
235 public class AmbientTickEventArgs : EventArgs
240 /// <since_tizen> 4 </since_tizen>
241 public Application Application
250 /// <since_tizen> 4 </since_tizen>
251 public WatchTime WatchTime
258 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
259 private delegate void AmbientTickCallbackType(IntPtr application, IntPtr watchTime);
260 private AmbientTickCallbackType _ambientTickCallback;
261 private DaliEventHandler<object,AmbientTickEventArgs> _ambientTickEventHandler;
264 /// AmbientTick event.
266 public event DaliEventHandler<object, AmbientTickEventArgs> AmbientTick
270 if (_ambientTickEventHandler == null)
272 _ambientTickCallback = new AmbientTickCallbackType( OnAmbientTick);
273 AmbientTickSignal().Connect(_ambientTickCallback);
276 _ambientTickEventHandler += value;
281 _ambientTickEventHandler -= value;
283 if (_ambientTickEventHandler == null && AmbientTickSignal().Empty() == false)
285 AmbientTickSignal().Disconnect(_ambientTickCallback);
290 private void OnAmbientTick(IntPtr application, IntPtr watchTime)
292 AmbientTickEventArgs e = new AmbientTickEventArgs();
293 if (application != null)
295 e.Application = Application.GetApplicationFromPtr(application);
297 if (watchTime != null)
299 e.WatchTime = WatchTime.GetWatchTimeFromPtr(watchTime);
302 _ambientTickEventHandler?.Invoke(this, e);
305 internal WatchTimeSignal AmbientTickSignal()
307 WatchTimeSignal ret = new WatchTimeSignal(NDalicManualPINVOKE.WatchApplication_AmbientTickSignal(swigCPtr), false);
308 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
313 /// Event arguments that passed via ambient tick event signal.
315 /// <since_tizen> 4 </since_tizen>
316 public class AmbientChangedEventArgs : EventArgs
321 /// <since_tizen> 4 </since_tizen>
322 public Application Application
331 /// <since_tizen> 4 </since_tizen>
339 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
340 private delegate void AmbientChangedCallbackType(IntPtr application, bool changed);
341 private AmbientChangedCallbackType _ambientChangedCallback;
342 private DaliEventHandler<object,AmbientChangedEventArgs> _ambientChangedEventHandler;
345 /// AmbientChanged event.
347 public event DaliEventHandler<object, AmbientChangedEventArgs> AmbientChanged
351 if (_ambientChangedEventHandler == null)
353 _ambientChangedCallback = new AmbientChangedCallbackType( OnAmbientChanged);
354 AmbientChangedSignal().Connect(_ambientChangedCallback);
357 _ambientChangedEventHandler += value;
362 _ambientChangedEventHandler -= value;
364 if (_ambientChangedEventHandler == null && AmbientChangedSignal().Empty() == false)
366 AmbientChangedSignal().Disconnect(_ambientChangedCallback);
371 private void OnAmbientChanged(IntPtr application, bool changed)
373 AmbientChangedEventArgs e = new AmbientChangedEventArgs();
374 if (application != null)
376 e.Application = Application.GetApplicationFromPtr(application);
380 _ambientChangedEventHandler?.Invoke(this, e);
383 internal WatchBoolSignal AmbientChangedSignal()
385 WatchBoolSignal ret = new WatchBoolSignal(NDalicManualPINVOKE.WatchApplication_AmbientChangedSignal(swigCPtr), false);
386 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
390 private static WatchApplication _instance; //singleton