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