[NUI] Disconnect all native signals of Window class when application is terminated...
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Application.cs
1 /*
2  * Copyright(c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 namespace Tizen.NUI
19 {
20
21     using System;
22     using System.Collections.Generic;
23     using System.Collections.ObjectModel;
24     using System.ComponentModel;
25     using System.Runtime.InteropServices;
26     using System.Threading;
27     using System.Threading.Tasks;
28     using Tizen.NUI.Binding;
29     using Tizen.NUI.Binding.Internals;
30
31     /**
32       * @brief Event arguments that passed via NUIApplicationInit signal
33       *
34       */
35     internal class NUIApplicationInitEventArgs : EventArgs
36     {
37         private Application _application;
38
39         /**
40           * @brief Application - is the application that is being initialized
41           *
42           */
43         public Application Application
44         {
45             get
46             {
47                 return _application;
48             }
49             set
50             {
51                 _application = value;
52             }
53         }
54     }
55
56     /**
57       * @brief Event arguments that passed via NUIApplicationTerminate signal
58       *
59       */
60     internal class NUIApplicationTerminatingEventArgs : EventArgs
61     {
62         private Application _application;
63         /**
64           * @brief Application - is the application that is being Terminated
65           *
66           */
67         public Application Application
68         {
69             get
70             {
71                 return _application;
72             }
73             set
74             {
75                 _application = value;
76             }
77         }
78     }
79
80     /**
81       * @brief Event arguments that passed via NUIApplicationPause signal
82       *
83       */
84     internal class NUIApplicationPausedEventArgs : EventArgs
85     {
86         private Application _application;
87         /**
88           * @brief Application - is the application that is being Paused
89           *
90           */
91         public Application Application
92         {
93             get
94             {
95                 return _application;
96             }
97             set
98             {
99                 _application = value;
100             }
101         }
102     }
103
104     /**
105       * @brief Event arguments that passed via NUIApplicationResume signal
106       *
107       */
108     internal class NUIApplicationResumedEventArgs : EventArgs
109     {
110         private Application _application;
111         /**
112           * @brief Application - is the application that is being Resumed
113           *
114           */
115         public Application Application
116         {
117             get
118             {
119                 return _application;
120             }
121             set
122             {
123                 _application = value;
124             }
125         }
126     }
127
128     /**
129       * @brief Event arguments that passed via NUIApplicationReset signal
130       *
131       */
132     internal class NUIApplicationResetEventArgs : EventArgs
133     {
134         private Application _application;
135         /**
136           * @brief Application - is the application that is being Reset
137           *
138           */
139         public Application Application
140         {
141             get
142             {
143                 return _application;
144             }
145             set
146             {
147                 _application = value;
148             }
149         }
150     }
151
152     /**
153       * @brief Event arguments that passed via NUIApplicationResize signal
154       *
155       */
156     internal class NUIApplicationResizedEventArgs : EventArgs
157     {
158         private Application _application;
159         /**
160           * @brief Application - is the application that is being Resized
161           *
162           */
163         public Application Application
164         {
165             get
166             {
167                 return _application;
168             }
169             set
170             {
171                 _application = value;
172             }
173         }
174     }
175
176     /**
177       * @brief Event arguments that passed via NUIApplicationLanguageChanged signal
178       *
179       */
180     internal class NUIApplicationLanguageChangedEventArgs : EventArgs
181     {
182         private Application _application;
183         /**
184           * @brief Application - is the application that is being affected with Device's language change
185           *
186           */
187         public Application Application
188         {
189             get
190             {
191                 return _application;
192             }
193             set
194             {
195                 _application = value;
196             }
197         }
198     }
199
200     /**
201       * @brief Event arguments that passed via NUIApplicationRegionChanged signal
202       *
203       */
204     internal class NUIApplicationRegionChangedEventArgs : EventArgs
205     {
206         private Application _application;
207         /**
208           * @brief Application - is the application that is being affected with Device's region change
209           *
210           */
211         public Application Application
212         {
213             get
214             {
215                 return _application;
216             }
217             set
218             {
219                 _application = value;
220             }
221         }
222     }
223
224     /**
225       * @brief Event arguments that passed via NUIApplicationBatteryLow signal
226       *
227       */
228     internal class NUIApplicationBatteryLowEventArgs : EventArgs
229     {
230         private Application.BatteryStatus _status;
231         /**
232           * @brief Application - is the application that is being affected when the battery level of the device is low
233           *
234           */
235         public Application.BatteryStatus BatteryStatus
236         {
237             get
238             {
239                 return _status;
240             }
241             set
242             {
243                 _status = value;
244             }
245         }
246     }
247
248     /**
249       * @brief Event arguments that passed via NUIApplicationMemoryLow signal
250       *
251       */
252     internal class NUIApplicationMemoryLowEventArgs : EventArgs
253     {
254         private Application.MemoryStatus _status;
255         /**
256           * @brief Application - is the application that is being affected when the memory level of the device is low
257           *
258           */
259         public Application.MemoryStatus MemoryStatus
260         {
261             get
262             {
263                 return _status;
264             }
265             set
266             {
267                 _status = value;
268             }
269         }
270     }
271
272     /**
273       * @brief Event arguments that passed via NUIApplicationAppControl  signal
274       *
275       */
276     internal class NUIApplicationAppControlEventArgs : EventArgs
277     {
278         private Application _application;
279         private IntPtr _voidp;
280         /**
281           * @brief Application - is the application that is receiving the launch request from another application
282           *
283           */
284         public Application Application
285         {
286             get
287             {
288                 return _application;
289             }
290             set
291             {
292                 _application = value;
293             }
294         }
295         /**
296           * @brief VoidP - contains the information about why the application is launched
297           *
298           */
299         public IntPtr VoidP
300         {
301             get
302             {
303                 return _voidp;
304             }
305             set
306             {
307                 _voidp = value;
308             }
309         }
310     }
311
312     public class GetResourcesProvider
313     {
314         static public IResourcesProvider Get()
315         {
316             return Tizen.NUI.Application.Current;
317         }
318     }
319
320     internal class Application : BaseHandle, IResourcesProvider, IApplicationController, IElementConfiguration<Application>
321     {
322         static Application s_current;
323         Task<IDictionary<string, object>> _propertiesTask;
324         readonly Lazy<PlatformConfigurationRegistry<Application>> _platformConfigurationRegistry;
325
326         IAppIndexingProvider _appIndexProvider;
327
328         ReadOnlyCollection<Element> _logicalChildren;
329
330         Page _mainPage;
331
332         static SemaphoreSlim SaveSemaphore = new SemaphoreSlim(1, 1);
333
334         public IAppLinks AppLinks
335         {
336             get
337             {
338                 if (_appIndexProvider == null)
339                     throw new ArgumentException("No IAppIndexingProvider was provided");
340                 if (_appIndexProvider.AppLinks == null)
341                     throw new ArgumentException("No AppLinks implementation was found, if in Android make sure you installed the Xamarin.Forms.AppLinks");
342                 return _appIndexProvider.AppLinks;
343             }
344         }
345
346         [EditorBrowsable(EditorBrowsableState.Never)]
347         public static void SetCurrentApplication(Application value) => Current = value;
348
349         public static Application Current
350         {
351             get { return s_current; }
352             set
353             {
354                 if (s_current == value)
355                     return;
356                 if (value == null)
357                     s_current = null; //Allow to reset current for unittesting
358                 s_current = value;
359             }
360         }
361
362         public Page MainPage
363         {
364             get { return _mainPage; }
365             set
366             {
367                 if (value == null)
368                     throw new ArgumentNullException("value");
369
370                 if (_mainPage == value)
371                     return;
372
373                 OnPropertyChanging();
374                 if (_mainPage != null)
375                 {
376                     InternalChildren.Remove(_mainPage);
377                     _mainPage.Parent = null;
378                 }
379
380                 _mainPage = value;
381
382                 if (_mainPage != null)
383                 {
384                     _mainPage.Parent = this;
385                     _mainPage.NavigationProxy.Inner = NavigationProxy;
386                     InternalChildren.Add(_mainPage);
387                 }
388                 OnPropertyChanged();
389             }
390         }
391
392         public IDictionary<string, object> Properties
393         {
394             get
395             {
396                 if (_propertiesTask == null)
397                 {
398                     _propertiesTask = GetPropertiesAsync();
399                 }
400
401                 return _propertiesTask.Result;
402             }
403         }
404
405         internal override ReadOnlyCollection<Element> LogicalChildrenInternal
406         {
407             get { return _logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(InternalChildren)); }
408         }
409
410         [EditorBrowsable(EditorBrowsableState.Never)]
411         public NavigationProxy NavigationProxy { get; }
412
413         [EditorBrowsable(EditorBrowsableState.Never)]
414         public int PanGestureId { get; set; }
415
416         internal IResourceDictionary SystemResources { get; }
417
418         ObservableCollection<Element> InternalChildren { get; } = new ObservableCollection<Element>();
419
420         [EditorBrowsable(EditorBrowsableState.Never)]
421         public void SetAppIndexingProvider(IAppIndexingProvider provider)
422         {
423             _appIndexProvider = provider;
424         }
425
426         ResourceDictionary _resources;
427         public bool IsResourcesCreated => _resources != null;
428
429         public delegate void resChangeCb (object sender, ResourcesChangedEventArgs e);
430
431         static private Dictionary<object, Dictionary<resChangeCb, int>> resourceChangeCallbackDict = new Dictionary<object, Dictionary<resChangeCb, int>>();
432         static public void AddResourceChangedCallback(object handle, resChangeCb cb)
433         {
434             Dictionary<resChangeCb, int> cbDict;
435             resourceChangeCallbackDict.TryGetValue(handle, out cbDict);
436
437             if (null == cbDict)
438             {
439                 cbDict = new Dictionary<resChangeCb, int>();
440                 resourceChangeCallbackDict.Add(handle, cbDict);
441             }
442
443             if (false == cbDict.ContainsKey(cb))
444             {
445                 cbDict.Add(cb, 0);
446             }
447         }
448
449         internal override void OnResourcesChanged(object sender, ResourcesChangedEventArgs e)
450         {
451             base.OnResourcesChanged(sender, e);
452
453             foreach (KeyValuePair<object, Dictionary<resChangeCb, int>> resourcePair in resourceChangeCallbackDict)
454             {
455                 foreach (KeyValuePair<resChangeCb, int> cbPair in resourcePair.Value)
456                 {
457                     cbPair.Key(sender, e);
458                 }
459             }
460         }
461
462         public ResourceDictionary XamlResources
463         {
464             get
465             {
466                 if (_resources != null)
467                     return _resources;
468
469                 _resources = new ResourceDictionary();
470                 int hashCode = _resources.GetHashCode();
471                 ((IResourceDictionary)_resources).ValuesChanged += OnResourcesChanged;
472                 return _resources;
473             }
474             set
475             {
476                 if (_resources == value)
477                     return;
478                 OnPropertyChanging();
479
480                 if (_resources != null)
481                     ((IResourceDictionary)_resources).ValuesChanged -= OnResourcesChanged;
482                 _resources = value;
483                 OnResourcesChanged(value);
484                 if (_resources != null)
485                     ((IResourceDictionary)_resources).ValuesChanged += OnResourcesChanged;
486
487                 OnPropertyChanged();
488             }
489         }
490
491         public event EventHandler<ModalPoppedEventArgs> ModalPopped;
492
493         public event EventHandler<ModalPoppingEventArgs> ModalPopping;
494
495         public event EventHandler<ModalPushedEventArgs> ModalPushed;
496
497         public event EventHandler<ModalPushingEventArgs> ModalPushing;
498
499         public event EventHandler<Page> PageAppearing;
500
501         public event EventHandler<Page> PageDisappearing;
502
503
504         async void SaveProperties()
505         {
506             try
507             {
508                 await SetPropertiesAsync();
509             }
510             catch (Exception exc)
511             {
512                 Console.WriteLine(nameof(Application), $"Exception while saving Application Properties: {exc}");
513             }
514         }
515
516         public async Task SavePropertiesAsync()
517         {
518             if (Device.IsInvokeRequired)
519             {
520                 Device.BeginInvokeOnMainThread(SaveProperties);
521             }
522             else
523             {
524                 await SetPropertiesAsync();
525             }
526         }
527
528         // Don't use this unless there really is no better option
529         internal void SavePropertiesAsFireAndForget()
530         {
531             if (Device.IsInvokeRequired)
532             {
533                 Device.BeginInvokeOnMainThread(SaveProperties);
534             }
535             else
536             {
537                 SaveProperties();
538             }
539         }
540
541         public IPlatformElementConfiguration<T, Application> On<T>() where T : IConfigPlatform
542         {
543             return _platformConfigurationRegistry.Value.On<T>();
544         }
545
546         protected virtual void OnAppLinkRequestReceived(Uri uri)
547         {
548         }
549
550         protected override void OnParentSet()
551         {
552             throw new InvalidOperationException("Setting a Parent on Application is invalid.");
553         }
554
555         protected virtual void OnResume()
556         {
557         }
558
559         protected virtual void OnSleep()
560         {
561         }
562
563         protected virtual void OnStart()
564         {
565         }
566
567         [EditorBrowsable(EditorBrowsableState.Never)]
568         public static void ClearCurrent()
569         {
570             s_current = null;
571         }
572
573         [EditorBrowsable(EditorBrowsableState.Never)]
574         public static bool IsApplicationOrNull(Element element)
575         {
576             return element == null || element is Application;
577         }
578
579         internal override void OnParentResourcesChanged(IEnumerable<KeyValuePair<string, object>> values)
580         {
581             if (!((IResourcesProvider)this).IsResourcesCreated || XamlResources.Count == 0)
582             {
583                 base.OnParentResourcesChanged(values);
584                 return;
585             }
586
587             var innerKeys = new HashSet<string>();
588             var changedResources = new List<KeyValuePair<string, object>>();
589             foreach (KeyValuePair<string, object> c in XamlResources)
590                 innerKeys.Add(c.Key);
591             foreach (KeyValuePair<string, object> value in values)
592             {
593                 if (innerKeys.Add(value.Key))
594                     changedResources.Add(value);
595             }
596             OnResourcesChanged(changedResources);
597         }
598
599         internal event EventHandler PopCanceled;
600
601         [EditorBrowsable(EditorBrowsableState.Never)]
602         public void SendOnAppLinkRequestReceived(Uri uri)
603         {
604             OnAppLinkRequestReceived(uri);
605         }
606
607         [EditorBrowsable(EditorBrowsableState.Never)]
608         public void SendResume()
609         {
610             s_current = this;
611             OnResume();
612         }
613
614         [EditorBrowsable(EditorBrowsableState.Never)]
615         public void SendSleep()
616         {
617             OnSleep();
618             SavePropertiesAsFireAndForget();
619         }
620
621         [EditorBrowsable(EditorBrowsableState.Never)]
622         public Task SendSleepAsync()
623         {
624             OnSleep();
625             return SavePropertiesAsync();
626         }
627
628         [EditorBrowsable(EditorBrowsableState.Never)]
629         public void SendStart()
630         {
631             OnStart();
632         }
633
634         async Task<IDictionary<string, object>> GetPropertiesAsync()
635         {
636             var deserializer = DependencyService.Get<IDeserializer>();
637             if (deserializer == null)
638             {
639                 Console.WriteLine("Startup", "No IDeserialzier was found registered");
640                 return new Dictionary<string, object>(4);
641             }
642
643             IDictionary<string, object> properties = await deserializer.DeserializePropertiesAsync().ConfigureAwait(false);
644             if (properties == null)
645                 properties = new Dictionary<string, object>(4);
646
647             return properties;
648         }
649
650         internal void OnPageAppearing(Page page)
651             => PageAppearing?.Invoke(this, page);
652
653         internal void OnPageDisappearing(Page page)
654             => PageDisappearing?.Invoke(this, page);
655
656         void OnModalPopped(Page modalPage)
657             => ModalPopped?.Invoke(this, new ModalPoppedEventArgs(modalPage));
658
659         bool OnModalPopping(Page modalPage)
660         {
661             var args = new ModalPoppingEventArgs(modalPage);
662             ModalPopping?.Invoke(this, args);
663             return args.Cancel;
664         }
665
666         void OnModalPushed(Page modalPage)
667             => ModalPushed?.Invoke(this, new ModalPushedEventArgs(modalPage));
668
669         void OnModalPushing(Page modalPage)
670             => ModalPushing?.Invoke(this, new ModalPushingEventArgs(modalPage));
671
672         void OnPopCanceled()
673             => PopCanceled?.Invoke(this, EventArgs.Empty);
674
675         async Task SetPropertiesAsync()
676         {
677             await SaveSemaphore.WaitAsync();
678             try
679             {
680                 await DependencyService.Get<IDeserializer>().SerializePropertiesAsync(Properties);
681             }
682             finally
683             {
684                 SaveSemaphore.Release();
685             }
686
687         }
688
689         class NavigationImpl : NavigationProxy
690         {
691             readonly Application _owner;
692
693             public NavigationImpl(Application owner)
694             {
695                 _owner = owner;
696             }
697
698             protected override async Task<Page> OnPopModal(bool animated)
699             {
700                 Page modal = ModalStack[ModalStack.Count - 1];
701                 if (_owner.OnModalPopping(modal))
702                 {
703                     _owner.OnPopCanceled();
704                     return null;
705                 }
706                 Page result = await base.OnPopModal(animated);
707                 result.Parent = null;
708                 _owner.OnModalPopped(result);
709                 return result;
710             }
711
712             protected override async Task OnPushModal(Page modal, bool animated)
713             {
714                 _owner.OnModalPushing(modal);
715
716                 modal.Parent = _owner;
717
718                 if (modal.NavigationProxy.ModalStack.Count == 0)
719                 {
720                     modal.NavigationProxy.Inner = this;
721                     await base.OnPushModal(modal, animated);
722                 }
723                 else
724                 {
725                     await base.OnPushModal(modal, animated);
726                     modal.NavigationProxy.Inner = this;
727                 }
728
729                 _owner.OnModalPushed(modal);
730             }
731         }
732
733         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
734
735         internal Application(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Application_SWIGUpcast(cPtr), cMemoryOwn)
736         {
737             NavigationProxy = new NavigationImpl(this);
738             SetCurrentApplication(this);
739
740             _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Application>>(() => new PlatformConfigurationRegistry<Application>(this));
741             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
742
743             SendResume();
744         }
745
746         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Application obj)
747         {
748             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
749         }
750
751         protected override void Dispose(DisposeTypes type)
752         {
753             if (disposed)
754             {
755                 return;
756             }
757
758             if (type == DisposeTypes.Explicit)
759             {
760                 //Called by User
761                 //Release your own managed resources here.
762                 //You should release all of your own disposable objects here.
763
764             }
765
766             //Release your own unmanaged resources here.
767             //You should not access any managed member here except static instance.
768             //because the execution order of Finalizes is non-deterministic.
769
770             if (_applicationInitEventCallbackDelegate != null)
771             {
772                 this.InitSignal().Disconnect(_applicationInitEventCallbackDelegate);
773             }
774
775             if (_applicationTerminateEventCallbackDelegate != null)
776             {
777                 this.TerminateSignal().Disconnect(_applicationTerminateEventCallbackDelegate);
778             }
779
780             if (_applicationPauseEventCallbackDelegate != null)
781             {
782                 this.PauseSignal().Disconnect(_applicationPauseEventCallbackDelegate);
783             }
784
785             if (_applicationResumeEventCallbackDelegate != null)
786             {
787                 this.ResumeSignal().Disconnect(_applicationResumeEventCallbackDelegate);
788             }
789
790             if (_applicationResetEventCallbackDelegate != null)
791             {
792                 this.ResetSignal().Disconnect(_applicationResetEventCallbackDelegate);
793             }
794
795             if (_applicationResizeEventCallbackDelegate != null)
796             {
797                 this.ResizeSignal().Disconnect(_applicationResizeEventCallbackDelegate);
798             }
799
800             if (_applicationLanguageChangedEventCallbackDelegate != null)
801             {
802                 this.LanguageChangedSignal().Disconnect(_applicationLanguageChangedEventCallbackDelegate);
803             }
804
805             if (_applicationRegionChangedEventCallbackDelegate != null)
806             {
807                 this.RegionChangedSignal().Disconnect(_applicationRegionChangedEventCallbackDelegate);
808             }
809
810             if (_applicationBatteryLowEventCallbackDelegate != null)
811             {
812                 this.BatteryLowSignal().Disconnect(_applicationBatteryLowEventCallbackDelegate);
813             }
814
815             if (_applicationMemoryLowEventCallbackDelegate != null)
816             {
817                 this.MemoryLowSignal().Disconnect(_applicationMemoryLowEventCallbackDelegate);
818             }
819
820             if (_applicationAppControlEventCallbackDelegate != null)
821             {
822                 this.AppControlSignal().Disconnect(_applicationAppControlEventCallbackDelegate);
823             }
824
825             if (swigCPtr.Handle != global::System.IntPtr.Zero)
826             {
827                 if (swigCMemOwn)
828                 {
829                     swigCMemOwn = false;
830                     NDalicPINVOKE.delete_Application(swigCPtr);
831                 }
832                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
833             }
834
835             base.Dispose(type);
836         }
837
838         /// <since_tizen> 4 </since_tizen>
839         public enum BatteryStatus
840         {
841             Normal,
842             CriticallyLow,
843             PowerOff
844         };
845
846         /// <since_tizen> 4 </since_tizen>
847         public enum MemoryStatus
848         {
849             Normal,
850             Low,
851             CriticallyLow
852         };
853
854         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
855         private delegate void NUIApplicationInitEventCallbackDelegate(IntPtr application);
856         private DaliEventHandler<object, NUIApplicationInitEventArgs> _applicationInitEventHandler;
857         private NUIApplicationInitEventCallbackDelegate _applicationInitEventCallbackDelegate;
858
859
860         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
861         private delegate void NUIApplicationTerminateEventCallbackDelegate(IntPtr application);
862         private DaliEventHandler<object, NUIApplicationTerminatingEventArgs> _applicationTerminateEventHandler;
863         private NUIApplicationTerminateEventCallbackDelegate _applicationTerminateEventCallbackDelegate;
864
865
866         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
867         private delegate void NUIApplicationPauseEventCallbackDelegate(IntPtr application);
868         private DaliEventHandler<object, NUIApplicationPausedEventArgs> _applicationPauseEventHandler;
869         private NUIApplicationPauseEventCallbackDelegate _applicationPauseEventCallbackDelegate;
870
871         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
872         private delegate void NUIApplicationResumeEventCallbackDelegate(IntPtr application);
873         private DaliEventHandler<object, NUIApplicationResumedEventArgs> _applicationResumeEventHandler;
874         private NUIApplicationResumeEventCallbackDelegate _applicationResumeEventCallbackDelegate;
875
876         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
877         private delegate void NUIApplicationResetEventCallbackDelegate(IntPtr application);
878         private DaliEventHandler<object, NUIApplicationResetEventArgs> _applicationResetEventHandler;
879         private NUIApplicationResetEventCallbackDelegate _applicationResetEventCallbackDelegate;
880
881         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
882         private delegate void NUIApplicationResizeEventCallbackDelegate(IntPtr application);
883         private DaliEventHandler<object, NUIApplicationResizedEventArgs> _applicationResizeEventHandler;
884         private NUIApplicationResizeEventCallbackDelegate _applicationResizeEventCallbackDelegate;
885
886         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
887         private delegate void NUIApplicationLanguageChangedEventCallbackDelegate(IntPtr application);
888         private DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> _applicationLanguageChangedEventHandler;
889         private NUIApplicationLanguageChangedEventCallbackDelegate _applicationLanguageChangedEventCallbackDelegate;
890
891
892         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
893         private delegate void NUIApplicationRegionChangedEventCallbackDelegate(IntPtr application);
894         private DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> _applicationRegionChangedEventHandler;
895         private NUIApplicationRegionChangedEventCallbackDelegate _applicationRegionChangedEventCallbackDelegate;
896
897         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
898         private delegate void NUIApplicationBatteryLowEventCallbackDelegate(BatteryStatus status);
899         private DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> _applicationBatteryLowEventHandler;
900         private NUIApplicationBatteryLowEventCallbackDelegate _applicationBatteryLowEventCallbackDelegate;
901
902         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
903         private delegate void NUIApplicationMemoryLowEventCallbackDelegate(MemoryStatus status);
904         private DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> _applicationMemoryLowEventHandler;
905         private NUIApplicationMemoryLowEventCallbackDelegate _applicationMemoryLowEventCallbackDelegate;
906
907         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
908         private delegate void NUIApplicationAppControlEventCallbackDelegate(IntPtr application, IntPtr voidp);
909         private DaliEventHandler<object, NUIApplicationAppControlEventArgs> _applicationAppControlEventHandler;
910         private NUIApplicationAppControlEventCallbackDelegate _applicationAppControlEventCallbackDelegate;
911
912         /**
913           * @brief Event for Initialized signal which can be used to subscribe/unsubscribe the event handler
914           *  provided by the user. Initialized signal is emitted when application is initialised
915           */
916         public event DaliEventHandler<object, NUIApplicationInitEventArgs> Initialized
917         {
918             add
919             {
920                 lock (this)
921                 {
922                     // Restricted to only one listener
923                     if (_applicationInitEventHandler == null)
924                     {
925                         _applicationInitEventHandler += value;
926
927                         _applicationInitEventCallbackDelegate = new NUIApplicationInitEventCallbackDelegate(OnApplicationInit);
928                         this.InitSignal().Connect(_applicationInitEventCallbackDelegate);
929                     }
930                 }
931             }
932
933             remove
934             {
935                 lock (this)
936                 {
937                     if (_applicationInitEventHandler != null)
938                     {
939                         this.InitSignal().Disconnect(_applicationInitEventCallbackDelegate);
940                     }
941
942                     _applicationInitEventHandler -= value;
943                 }
944             }
945         }
946
947         // Callback for Application InitSignal
948         private void OnApplicationInit(IntPtr data)
949         {
950             // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread.
951             DisposeQueue.Instance.Initialize();
952
953             if(_applicationInitEventHandler != null)
954             {
955                 NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs();
956                 e.Application = this;
957                 _applicationInitEventHandler.Invoke(this, e);
958             }
959         }
960
961         /**
962           * @brief Event for Terminated signal which can be used to subscribe/unsubscribe the event handler
963           *  provided by the user. Terminated signal is emitted when application is terminating
964           */
965         public event DaliEventHandler<object, NUIApplicationTerminatingEventArgs> Terminating
966         {
967             add
968             {
969                 lock (this)
970                 {
971                     // Restricted to only one listener
972                     if (_applicationTerminateEventHandler == null)
973                     {
974                         _applicationTerminateEventHandler += value;
975
976                         _applicationTerminateEventCallbackDelegate = new NUIApplicationTerminateEventCallbackDelegate(OnNUIApplicationTerminate);
977                         this.TerminateSignal().Connect(_applicationTerminateEventCallbackDelegate);
978                     }
979                 }
980             }
981
982             remove
983             {
984                 lock (this)
985                 {
986                     if (_applicationTerminateEventHandler != null)
987                     {
988                         this.TerminateSignal().Disconnect(_applicationTerminateEventCallbackDelegate);
989                     }
990
991                     _applicationTerminateEventHandler -= value;
992                 }
993             }
994         }
995
996         // Callback for Application TerminateSignal
997         private void OnNUIApplicationTerminate(IntPtr data)
998         {
999             if(_applicationTerminateEventHandler != null)
1000             {
1001                 NUIApplicationTerminatingEventArgs e = new NUIApplicationTerminatingEventArgs();
1002                 e.Application = this;
1003                 _applicationTerminateEventHandler.Invoke(this, e);
1004             }
1005
1006             Window.Instance.DisconnectNativeSignals();
1007         }
1008
1009         /**
1010           * @brief Event for Paused signal which can be used to subscribe/unsubscribe the event handler
1011           * provided by the user. Paused signal is emitted when application is paused
1012           */
1013         public event DaliEventHandler<object, NUIApplicationPausedEventArgs> Paused
1014         {
1015             add
1016             {
1017                 lock (this)
1018                 {
1019                     // Restricted to only one listener
1020                     if (_applicationPauseEventHandler == null)
1021                     {
1022                         _applicationPauseEventHandler += value;
1023
1024                         _applicationPauseEventCallbackDelegate = new NUIApplicationPauseEventCallbackDelegate(OnNUIApplicationPause);
1025                         this.PauseSignal().Connect(_applicationPauseEventCallbackDelegate);
1026                     }
1027                 }
1028             }
1029
1030             remove
1031             {
1032                 lock (this)
1033                 {
1034                     if (_applicationPauseEventHandler != null)
1035                     {
1036                         this.PauseSignal().Disconnect(_applicationPauseEventCallbackDelegate);
1037                     }
1038
1039                     _applicationPauseEventHandler -= value;
1040                 }
1041             }
1042         }
1043
1044         // Callback for Application PauseSignal
1045         private void OnNUIApplicationPause(IntPtr data)
1046         {
1047             if(_applicationPauseEventHandler != null)
1048             {
1049                 NUIApplicationPausedEventArgs e = new NUIApplicationPausedEventArgs();
1050                 e.Application = this;
1051                 _applicationPauseEventHandler.Invoke(this, e);
1052             }
1053         }
1054
1055         /**
1056           * @brief Event for Resumed signal which can be used to subscribe/unsubscribe the event handler
1057           *  provided by the user. Resumed signal is emitted when application is resumed
1058           */
1059         public event DaliEventHandler<object, NUIApplicationResumedEventArgs> Resumed
1060         {
1061             add
1062             {
1063                 lock (this)
1064                 {
1065                     // Restricted to only one listener
1066                     if (_applicationResumeEventHandler == null)
1067                     {
1068                         _applicationResumeEventHandler += value;
1069
1070                         _applicationResumeEventCallbackDelegate = new NUIApplicationResumeEventCallbackDelegate(OnNUIApplicationResume);
1071                         this.ResumeSignal().Connect(_applicationResumeEventCallbackDelegate);
1072                     }
1073                 }
1074             }
1075
1076             remove
1077             {
1078                 lock (this)
1079                 {
1080                     if (_applicationResumeEventHandler != null)
1081                     {
1082                         this.ResumeSignal().Disconnect(_applicationResumeEventCallbackDelegate);
1083                     }
1084
1085                     _applicationResumeEventHandler -= value;
1086                 }
1087             }
1088         }
1089
1090         // Callback for Application ResumeSignal
1091         private void OnNUIApplicationResume(IntPtr data)
1092         {
1093             if(_applicationResumeEventHandler != null)
1094             {
1095                 NUIApplicationResumedEventArgs e = new NUIApplicationResumedEventArgs();
1096                 e.Application = this;
1097                 _applicationResumeEventHandler.Invoke(this, e);
1098             }
1099         }
1100
1101         /**
1102           * @brief Event for Reset signal which can be used to subscribe/unsubscribe the event handler
1103           *  provided by the user. Reset signal is emitted when application is reset
1104           */
1105         public new event DaliEventHandler<object, NUIApplicationResetEventArgs> Reset
1106         {
1107             add
1108             {
1109                 lock (this)
1110                 {
1111                     // Restricted to only one listener
1112                     if (_applicationResetEventHandler == null)
1113                     {
1114                         _applicationResetEventHandler += value;
1115
1116                         _applicationResetEventCallbackDelegate = new NUIApplicationResetEventCallbackDelegate(OnNUIApplicationReset);
1117                         this.ResetSignal().Connect(_applicationResetEventCallbackDelegate);
1118                     }
1119                 }
1120             }
1121
1122             remove
1123             {
1124                 lock (this)
1125                 {
1126                     if (_applicationResetEventHandler != null)
1127                     {
1128                         this.ResetSignal().Disconnect(_applicationResetEventCallbackDelegate);
1129                     }
1130
1131                     _applicationResetEventHandler -= value;
1132                 }
1133             }
1134         }
1135
1136         // Callback for Application ResetSignal
1137         private void OnNUIApplicationReset(IntPtr data)
1138         {
1139             if(_applicationResetEventHandler != null)
1140             {
1141                 NUIApplicationResetEventArgs e = new NUIApplicationResetEventArgs();
1142                 e.Application = this;
1143                 _applicationResetEventHandler.Invoke(this, e);
1144             }
1145         }
1146
1147         /**
1148           * @brief Event for Resized signal which can be used to subscribe/unsubscribe the event handler
1149           *  provided by the user. Resized signal is emitted when application is resized
1150           */
1151         public event DaliEventHandler<object, NUIApplicationResizedEventArgs> Resized
1152         {
1153             add
1154             {
1155                 lock (this)
1156                 {
1157                     // Restricted to only one listener
1158                     if (_applicationResizeEventHandler == null)
1159                     {
1160                         _applicationResizeEventHandler += value;
1161
1162                         _applicationResizeEventCallbackDelegate = new NUIApplicationResizeEventCallbackDelegate(OnNUIApplicationResize);
1163                         this.ResizeSignal().Connect(_applicationResizeEventCallbackDelegate);
1164                     }
1165                 }
1166             }
1167
1168             remove
1169             {
1170                 lock (this)
1171                 {
1172                     if (_applicationResizeEventHandler != null)
1173                     {
1174                         this.ResizeSignal().Disconnect(_applicationResizeEventCallbackDelegate);
1175                     }
1176
1177                     _applicationResizeEventHandler -= value;
1178                 }
1179             }
1180         }
1181
1182         // Callback for Application ResizeSignal
1183         private void OnNUIApplicationResize(IntPtr data)
1184         {
1185             if(_applicationResizeEventHandler != null)
1186             {
1187                 NUIApplicationResizedEventArgs e = new NUIApplicationResizedEventArgs();
1188                 e.Application = this;
1189                 _applicationResizeEventHandler.Invoke(this, e);
1190             }
1191         }
1192
1193         /**
1194           * @brief Event for LanguageChanged signal which can be used to subscribe/unsubscribe the event handler
1195           *  provided by the user. LanguageChanged signal is emitted when the region of the device is changed.
1196           */
1197         public event DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> LanguageChanged
1198         {
1199             add
1200             {
1201                 lock (this)
1202                 {
1203                     // Restricted to only one listener
1204                     if (_applicationLanguageChangedEventHandler == null)
1205                     {
1206                         _applicationLanguageChangedEventHandler += value;
1207
1208                         _applicationLanguageChangedEventCallbackDelegate = new NUIApplicationLanguageChangedEventCallbackDelegate(OnNUIApplicationLanguageChanged);
1209                         this.LanguageChangedSignal().Connect(_applicationLanguageChangedEventCallbackDelegate);
1210                     }
1211                 }
1212             }
1213
1214             remove
1215             {
1216                 lock (this)
1217                 {
1218                     if (_applicationLanguageChangedEventHandler != null)
1219                     {
1220                         this.LanguageChangedSignal().Disconnect(_applicationLanguageChangedEventCallbackDelegate);
1221                     }
1222
1223                     _applicationLanguageChangedEventHandler -= value;
1224                 }
1225             }
1226         }
1227
1228         // Callback for Application LanguageChangedSignal
1229         private void OnNUIApplicationLanguageChanged(IntPtr data)
1230         {
1231             if(_applicationLanguageChangedEventHandler != null)
1232             {
1233                 NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs();
1234                 e.Application = this;
1235                 _applicationLanguageChangedEventHandler.Invoke(this, e);
1236             }
1237         }
1238
1239         /**
1240           * @brief Event for RegionChanged signal which can be used to subscribe/unsubscribe the event handler
1241           *  provided by the user. RegionChanged signal is emitted when the region of the device is changed.
1242           */
1243         public event DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> RegionChanged
1244         {
1245             add
1246             {
1247                 lock (this)
1248                 {
1249                     // Restricted to only one listener
1250                     if (_applicationRegionChangedEventHandler == null)
1251                     {
1252                         _applicationRegionChangedEventHandler += value;
1253
1254                         _applicationRegionChangedEventCallbackDelegate = new NUIApplicationRegionChangedEventCallbackDelegate(OnNUIApplicationRegionChanged);
1255                         this.RegionChangedSignal().Connect(_applicationRegionChangedEventCallbackDelegate);
1256                     }
1257                 }
1258             }
1259
1260             remove
1261             {
1262                 lock (this)
1263                 {
1264                     if (_applicationRegionChangedEventHandler != null)
1265                     {
1266                         this.RegionChangedSignal().Disconnect(_applicationRegionChangedEventCallbackDelegate);
1267                     }
1268
1269                     _applicationRegionChangedEventHandler -= value;
1270                 }
1271             }
1272         }
1273
1274         // Callback for Application RegionChangedSignal
1275         private void OnNUIApplicationRegionChanged(IntPtr data)
1276         {
1277             if(_applicationRegionChangedEventHandler != null)
1278             {
1279                 NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs();
1280                 e.Application = this;
1281                 _applicationRegionChangedEventHandler.Invoke(this, e);
1282             }
1283         }
1284
1285         /**
1286           * @brief Event for BatteryLow signal which can be used to subscribe/unsubscribe the event handler
1287           * provided by the user. BatteryLow signal is emitted when the battery level of the device is low.
1288           */
1289         public event DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> BatteryLow
1290         {
1291             add
1292             {
1293                 lock (this)
1294                 {
1295                     // Restricted to only one listener
1296                     if (_applicationBatteryLowEventHandler == null)
1297                     {
1298                         _applicationBatteryLowEventHandler += value;
1299
1300                         _applicationBatteryLowEventCallbackDelegate = new NUIApplicationBatteryLowEventCallbackDelegate(OnNUIApplicationBatteryLow);
1301                         this.BatteryLowSignal().Connect(_applicationBatteryLowEventCallbackDelegate);
1302                     }
1303                 }
1304             }
1305
1306             remove
1307             {
1308                 lock (this)
1309                 {
1310                     if (_applicationBatteryLowEventHandler != null)
1311                     {
1312                         this.BatteryLowSignal().Disconnect(_applicationBatteryLowEventCallbackDelegate);
1313                     }
1314
1315                     _applicationBatteryLowEventHandler -= value;
1316                 }
1317             }
1318         }
1319
1320         // Callback for Application BatteryLowSignal
1321         private void OnNUIApplicationBatteryLow(BatteryStatus status)
1322         {
1323             NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
1324
1325             // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
1326             e.BatteryStatus = status;
1327             _applicationBatteryLowEventHandler?.Invoke(this, e);
1328         }
1329
1330         /**
1331           * @brief Event for MemoryLow signal which can be used to subscribe/unsubscribe the event handler
1332           *  provided by the user. MemoryLow signal is emitted when the memory level of the device is low.
1333           */
1334         public event DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> MemoryLow
1335         {
1336             add
1337             {
1338                 lock (this)
1339                 {
1340                     // Restricted to only one listener
1341                     if (_applicationMemoryLowEventHandler == null)
1342                     {
1343                         _applicationMemoryLowEventHandler += value;
1344
1345                         _applicationMemoryLowEventCallbackDelegate = new NUIApplicationMemoryLowEventCallbackDelegate(OnNUIApplicationMemoryLow);
1346                         this.MemoryLowSignal().Connect(_applicationMemoryLowEventCallbackDelegate);
1347                     }
1348                 }
1349             }
1350
1351             remove
1352             {
1353                 lock (this)
1354                 {
1355                     if (_applicationMemoryLowEventHandler != null)
1356                     {
1357                         this.MemoryLowSignal().Disconnect(_applicationMemoryLowEventCallbackDelegate);
1358                     }
1359
1360                     _applicationMemoryLowEventHandler -= value;
1361                 }
1362             }
1363         }
1364
1365         // Callback for Application MemoryLowSignal
1366         private void OnNUIApplicationMemoryLow(MemoryStatus status)
1367         {
1368             NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
1369
1370             // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
1371             e.MemoryStatus = status;
1372             _applicationMemoryLowEventHandler?.Invoke(this, e);
1373         }
1374
1375         /**
1376           * @brief Event for AppControl signal which can be used to subscribe/unsubscribe the event handler
1377           *  provided by the user. AppControl signal is emitted when another application sends a launch request to the application.
1378           */
1379         public event DaliEventHandler<object, NUIApplicationAppControlEventArgs> AppControl
1380         {
1381             add
1382             {
1383                 lock (this)
1384                 {
1385                     // Restricted to only one listener
1386                     if (_applicationAppControlEventHandler == null)
1387                     {
1388                         _applicationAppControlEventHandler += value;
1389
1390                         _applicationAppControlEventCallbackDelegate = new NUIApplicationAppControlEventCallbackDelegate(OnNUIApplicationAppControl);
1391                         this.AppControlSignal().Connect(_applicationAppControlEventCallbackDelegate);
1392                     }
1393                 }
1394             }
1395
1396             remove
1397             {
1398                 lock (this)
1399                 {
1400                     if (_applicationAppControlEventHandler != null)
1401                     {
1402                         this.AppControlSignal().Disconnect(_applicationAppControlEventCallbackDelegate);
1403                     }
1404
1405                     _applicationAppControlEventHandler -= value;
1406                 }
1407             }
1408         }
1409
1410         // Callback for Application AppControlSignal
1411         private void OnNUIApplicationAppControl(IntPtr application, IntPtr voidp)
1412         {
1413             if(_applicationAppControlEventHandler != null)
1414             {
1415                 NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs();
1416                 e.VoidP = voidp;
1417                 e.Application = this;
1418                 _applicationAppControlEventHandler.Invoke(this, e);
1419             }
1420         }
1421
1422         private static Application _instance; // singleton
1423
1424         public static Application Instance
1425         {
1426             get
1427             {
1428                 return _instance;
1429             }
1430         }
1431
1432         public static Application GetApplicationFromPtr(global::System.IntPtr cPtr)
1433         {
1434             if (cPtr == global::System.IntPtr.Zero)
1435             {
1436                 return null;
1437             }
1438
1439             Application ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Application;
1440             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1441             return ret;
1442         }
1443
1444         public static Application NewApplication()
1445         {
1446             return NewApplication("", Application.WindowMode.Opaque);
1447         }
1448
1449         public static Application NewApplication(string stylesheet)
1450         {
1451             return NewApplication(stylesheet, Application.WindowMode.Opaque);
1452         }
1453
1454         public static Application NewApplication(string stylesheet, Application.WindowMode windowMode)
1455         {
1456             // register all Views with the type registry, so that can be created / styled via JSON
1457             //ViewRegistryHelper.Initialize(); //moved to Application side.
1458
1459             Application ret = New(1, stylesheet, windowMode);
1460             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1461
1462             // set the singleton
1463             _instance = ret;
1464             return ret;
1465         }
1466
1467
1468         public static Application NewApplication(string[] args, string stylesheet, Application.WindowMode windowMode)
1469         {
1470             Application ret = New(args, stylesheet, (Application.WindowMode)windowMode);
1471             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1472
1473             // set the singleton
1474             _instance = ret;
1475             return _instance;
1476         }
1477
1478         /// <summary>
1479         /// Ensures that the function passed in is called from the main loop when it is idle.
1480         /// </summary>
1481         /// <param name="func">The function to call</param>
1482         /// <returns>true if added successfully, false otherwise</returns>
1483         public bool AddIdle(System.Delegate func)
1484         {
1485             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
1486             System.IntPtr ip2 = NDalicManualPINVOKE.MakeCallback(new System.Runtime.InteropServices.HandleRef(this, ip));
1487
1488             bool ret = NDalicPINVOKE.Application_AddIdle(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip2));
1489
1490             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1491             return ret;
1492         }
1493
1494         /**
1495         * Outer::outer_method(int)
1496         */
1497         public static Application New()
1498         {
1499             Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_0(), true);
1500             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1501             return ret;
1502         }
1503
1504         public static Application New(int argc)
1505         {
1506             Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_1(argc), true);
1507             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1508             return ret;
1509         }
1510
1511         public static Application New(int argc, string stylesheet)
1512         {
1513             Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_2(argc, stylesheet), true);
1514             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1515             return ret;
1516         }
1517
1518         public static Application New(int argc, string stylesheet, Application.WindowMode windowMode)
1519         {
1520             Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_3(argc, stylesheet, (int)windowMode), true);
1521             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1522             ret.SendResume();
1523             return ret;
1524         }
1525
1526         public static Application New(string[] args, string stylesheet, Application.WindowMode windowMode)
1527         {
1528             int argc = args.Length;
1529             string argvStr = string.Join(" ", args);
1530
1531             Application ret = new Application(NDalicPINVOKE.Application_New__MANUAL_4(argc, argvStr, stylesheet, (int)windowMode), true);
1532             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1533             return ret;
1534         }
1535
1536         public static Application New(int argc, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1537         {
1538             Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_4(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1539             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1540             return ret;
1541         }
1542
1543         public Application() : this(NDalicPINVOKE.new_Application__SWIG_0(), true)
1544         {
1545             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1546         }
1547
1548         public Application(Application application) : this(NDalicPINVOKE.new_Application__SWIG_1(Application.getCPtr(application)), true)
1549         {
1550             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1551         }
1552
1553         public Application Assign(Application application)
1554         {
1555             Application ret = new Application(NDalicPINVOKE.Application_Assign(swigCPtr, Application.getCPtr(application)), false);
1556             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1557             return ret;
1558         }
1559
1560         public void MainLoop()
1561         {
1562             NDalicPINVOKE.Application_MainLoop__SWIG_0(swigCPtr);
1563             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1564         }
1565
1566         internal void MainLoop(SWIGTYPE_p_Configuration__ContextLoss configuration)
1567         {
1568             NDalicPINVOKE.Application_MainLoop__SWIG_1(swigCPtr, SWIGTYPE_p_Configuration__ContextLoss.getCPtr(configuration));
1569             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1570         }
1571
1572         public void Lower()
1573         {
1574             NDalicPINVOKE.Application_Lower(swigCPtr);
1575             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1576         }
1577
1578         public void Quit()
1579         {
1580             NDalicPINVOKE.Application_Quit(swigCPtr);
1581             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1582         }
1583
1584         internal bool AddIdle(SWIGTYPE_p_Dali__CallbackBase callback)
1585         {
1586             bool ret = NDalicPINVOKE.Application_AddIdle(swigCPtr, SWIGTYPE_p_Dali__CallbackBase.getCPtr(callback));
1587             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1588             return ret;
1589         }
1590
1591         public Window GetWindow()
1592         {
1593             Window ret = new Window(NDalicPINVOKE.Application_GetWindow(swigCPtr), true);
1594             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1595             return ret;
1596         }
1597
1598         public void ReplaceWindow(Rectangle windowPosition, string name)
1599         {
1600             NDalicPINVOKE.Application_ReplaceWindow(swigCPtr, Rectangle.getCPtr(windowPosition), name);
1601             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1602         }
1603
1604         public static string GetResourcePath()
1605         {
1606             string ret = NDalicPINVOKE.Application_GetResourcePath();
1607             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1608             return ret;
1609         }
1610
1611         internal void SetViewMode(ViewMode viewMode)
1612         {
1613             NDalicPINVOKE.Application_SetViewMode(swigCPtr, (int)viewMode);
1614             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1615         }
1616
1617         internal ViewMode GetViewMode()
1618         {
1619             ViewMode ret = (ViewMode)NDalicPINVOKE.Application_GetViewMode(swigCPtr);
1620             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1621             return ret;
1622         }
1623
1624         public void SetStereoBase(float stereoBase)
1625         {
1626             NDalicPINVOKE.Application_SetStereoBase(swigCPtr, stereoBase);
1627             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1628         }
1629
1630         public float GetStereoBase()
1631         {
1632             float ret = NDalicPINVOKE.Application_GetStereoBase(swigCPtr);
1633             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1634             return ret;
1635         }
1636
1637         public string GetLanguage()
1638         {
1639             string ret = NDalicPINVOKE.Application_GetLanguage(swigCPtr);
1640             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1641             return ret;
1642         }
1643
1644         public string GetRegion()
1645         {
1646             string ret = NDalicPINVOKE.Application_GetRegion(swigCPtr);
1647             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1648             return ret;
1649         }
1650
1651
1652         internal ApplicationSignal InitSignal()
1653         {
1654             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_InitSignal(swigCPtr), false);
1655             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1656             return ret;
1657         }
1658
1659         internal ApplicationSignal TerminateSignal()
1660         {
1661             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_TerminateSignal(swigCPtr), false);
1662             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1663             return ret;
1664         }
1665
1666         internal ApplicationSignal PauseSignal()
1667         {
1668             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_PauseSignal(swigCPtr), false);
1669             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1670             return ret;
1671         }
1672
1673         internal ApplicationSignal ResumeSignal()
1674         {
1675             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_ResumeSignal(swigCPtr), false);
1676             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1677             return ret;
1678         }
1679
1680         internal ApplicationSignal ResetSignal()
1681         {
1682             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_ResetSignal(swigCPtr), false);
1683             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1684             return ret;
1685         }
1686
1687         internal ApplicationSignal ResizeSignal()
1688         {
1689             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_ResizeSignal(swigCPtr), false);
1690             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1691             return ret;
1692         }
1693
1694         internal ApplicationControlSignal AppControlSignal()
1695         {
1696             ApplicationControlSignal ret = new ApplicationControlSignal(NDalicPINVOKE.Application_AppControlSignal(swigCPtr), false);
1697             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1698             return ret;
1699         }
1700
1701         internal ApplicationSignal LanguageChangedSignal()
1702         {
1703             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_LanguageChangedSignal(swigCPtr), false);
1704             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1705             return ret;
1706         }
1707
1708         internal ApplicationSignal RegionChangedSignal()
1709         {
1710             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_RegionChangedSignal(swigCPtr), false);
1711             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1712             return ret;
1713         }
1714
1715         internal LowBatterySignalType BatteryLowSignal()
1716         {
1717             LowBatterySignalType ret = new LowBatterySignalType(NDalicPINVOKE.Application_LowBatterySignal(swigCPtr), false);
1718             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1719             return ret;
1720         }
1721
1722         internal LowMemorySignalType MemoryLowSignal()
1723         {
1724             LowMemorySignalType ret = new LowMemorySignalType(NDalicPINVOKE.Application_LowMemorySignal(swigCPtr), false);
1725             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1726             return ret;
1727         }
1728
1729         /// <since_tizen> 3 </since_tizen>
1730         public enum WindowMode
1731         {
1732             Opaque = 0,
1733             Transparent = 1
1734         }
1735
1736     }
1737
1738 }