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;
23 internal class WatchApplication : Application
26 internal WatchApplication(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
30 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WatchApplication obj)
32 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
35 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
37 Interop.Watch.delete_WatchApplication(swigCPtr);
40 private void DisConnectFromSignals()
42 if (_timeTickCallback != null)
44 this.TimeTickSignal().Disconnect(_timeTickCallback);
46 if (_ambientTickCallback != null)
48 this.AmbientTickSignal().Disconnect(_ambientTickCallback);
50 if (_ambientChangedCallback != null)
52 this.AmbientChangedSignal().Disconnect(_ambientChangedCallback);
56 public static WatchApplication NewWatchApplication()
58 WatchApplication ret = New();
59 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
60 // we've got an application now connect the signals
65 public static WatchApplication NewWatchApplication(string[] args)
67 WatchApplication ret = New(args);
68 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
73 public static WatchApplication NewWatchApplication(string[] args, string stylesheet)
75 WatchApplication ret = New(args, stylesheet);
76 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81 public new static WatchApplication New()
83 WatchApplication ret = new WatchApplication(Interop.Watch.WatchApplication_New__SWIG_0(), true);
84 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
88 public static WatchApplication New(string[] args)
90 int argc = args.Length;
91 string argvStr = string.Join(" ", args);
93 WatchApplication ret = new WatchApplication(Interop.Watch.WatchApplication_New__SWIG_1(argc, argvStr), true);
94 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
98 public static WatchApplication New(string[] args, string stylesheet)
100 int argc = args.Length;
101 string argvStr = string.Join(" ", args);
103 WatchApplication ret = new WatchApplication(Interop.Watch.WatchApplication_New__SWIG_2(argc, argvStr, stylesheet), true);
104 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
108 internal WatchApplication(WatchApplication implementation) : this(Interop.Watch.new_WatchApplication__SWIG_1(WatchApplication.getCPtr(implementation)), true)
110 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
114 /// Event arguments that passed via time tick event signal.
116 /// <since_tizen> 4 </since_tizen>
117 public class TimeTickEventArgs : EventArgs
122 /// <since_tizen> 4 </since_tizen>
123 public Application Application
132 /// <since_tizen> 4 </since_tizen>
133 public WatchTime WatchTime
140 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
141 private delegate void TimeTickCallbackType(IntPtr application, IntPtr watchTime);
142 private TimeTickCallbackType _timeTickCallback;
143 private DaliEventHandler<object, TimeTickEventArgs> _timeTickEventHandler;
148 public event DaliEventHandler<object, TimeTickEventArgs> TimeTick
152 if (_timeTickEventHandler == null)
154 _timeTickCallback = new TimeTickCallbackType(OnTimeTick);
155 TimeTickSignal().Connect(_timeTickCallback);
158 _timeTickEventHandler += value;
163 _timeTickEventHandler -= value;
165 if (_timeTickEventHandler == null && TimeTickSignal().Empty() == false)
167 TimeTickSignal().Disconnect(_timeTickCallback);
172 private void OnTimeTick(IntPtr application, IntPtr watchTime)
174 TimeTickEventArgs e = new TimeTickEventArgs();
175 e.Application = this;
176 e.WatchTime = WatchTime.GetWatchTimeFromPtr(watchTime);
178 _timeTickEventHandler?.Invoke(this, e);
182 internal WatchTimeSignal TimeTickSignal()
184 WatchTimeSignal ret = new WatchTimeSignal(Interop.Watch.WatchApplication_TimeTickSignal(swigCPtr), false);
185 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190 /// Event arguments that passed via ambient tick event signal.
192 /// <since_tizen> 4 </since_tizen>
193 public class AmbientTickEventArgs : EventArgs
198 /// <since_tizen> 4 </since_tizen>
199 public Application Application
208 /// <since_tizen> 4 </since_tizen>
209 public WatchTime WatchTime
216 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
217 private delegate void AmbientTickCallbackType(IntPtr application, IntPtr watchTime);
218 private AmbientTickCallbackType _ambientTickCallback;
219 private DaliEventHandler<object, AmbientTickEventArgs> _ambientTickEventHandler;
222 /// AmbientTick event.
224 public event DaliEventHandler<object, AmbientTickEventArgs> AmbientTick
228 if (_ambientTickEventHandler == null)
230 _ambientTickCallback = new AmbientTickCallbackType(OnAmbientTick);
231 AmbientTickSignal().Connect(_ambientTickCallback);
234 _ambientTickEventHandler += value;
239 _ambientTickEventHandler -= value;
241 if (_ambientTickEventHandler == null && AmbientTickSignal().Empty() == false)
243 AmbientTickSignal().Disconnect(_ambientTickCallback);
248 private void OnAmbientTick(IntPtr application, IntPtr watchTime)
250 AmbientTickEventArgs e = new AmbientTickEventArgs();
252 e.Application = this;
253 e.WatchTime = WatchTime.GetWatchTimeFromPtr(watchTime);
254 _ambientTickEventHandler?.Invoke(this, e);
257 internal WatchTimeSignal AmbientTickSignal()
259 WatchTimeSignal ret = new WatchTimeSignal(Interop.Watch.WatchApplication_AmbientTickSignal(swigCPtr), false);
260 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
265 /// Event arguments that passed via ambient tick event signal.
267 /// <since_tizen> 4 </since_tizen>
268 public class AmbientChangedEventArgs : EventArgs
273 /// <since_tizen> 4 </since_tizen>
274 public Application Application
283 /// <since_tizen> 4 </since_tizen>
291 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
292 private delegate void AmbientChangedCallbackType(IntPtr application, bool changed);
293 private AmbientChangedCallbackType _ambientChangedCallback;
294 private DaliEventHandler<object, AmbientChangedEventArgs> _ambientChangedEventHandler;
297 /// AmbientChanged event.
299 public event DaliEventHandler<object, AmbientChangedEventArgs> AmbientChanged
303 if (_ambientChangedEventHandler == null)
305 _ambientChangedCallback = new AmbientChangedCallbackType(OnAmbientChanged);
306 AmbientChangedSignal().Connect(_ambientChangedCallback);
309 _ambientChangedEventHandler += value;
314 _ambientChangedEventHandler -= value;
316 if (_ambientChangedEventHandler == null && AmbientChangedSignal().Empty() == false)
318 AmbientChangedSignal().Disconnect(_ambientChangedCallback);
323 private void OnAmbientChanged(IntPtr application, bool changed)
325 AmbientChangedEventArgs e = new AmbientChangedEventArgs();
326 e.Application = this;
328 _ambientChangedEventHandler?.Invoke(this, e);
331 internal WatchBoolSignal AmbientChangedSignal()
333 WatchBoolSignal ret = new WatchBoolSignal(Interop.Watch.WatchApplication_AmbientChangedSignal(swigCPtr), false);
334 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();