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