[NUI] Update Widget / NUIWidgetApplication
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Application.cs
1 /*
2  * Copyright(c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 namespace Tizen.NUI
19 {
20
21     using System;
22     using System.Runtime.InteropServices;
23
24     /**
25       * @brief Event arguments that passed via NUIApplicationInit signal
26       *
27       */
28     internal class NUIApplicationInitEventArgs : EventArgs
29     {
30         private Application _application;
31
32         /**
33           * @brief Application - is the application that is being initialized
34           *
35           */
36         public Application Application
37         {
38             get
39             {
40                 return _application;
41             }
42             set
43             {
44                 _application = value;
45             }
46         }
47     }
48
49     /**
50       * @brief Event arguments that passed via NUIApplicationTerminate signal
51       *
52       */
53     internal class NUIApplicationTerminatingEventArgs : EventArgs
54     {
55         private Application _application;
56         /**
57           * @brief Application - is the application that is being Terminated
58           *
59           */
60         public Application Application
61         {
62             get
63             {
64                 return _application;
65             }
66             set
67             {
68                 _application = value;
69             }
70         }
71     }
72
73     /**
74       * @brief Event arguments that passed via NUIApplicationPause signal
75       *
76       */
77     internal class NUIApplicationPausedEventArgs : EventArgs
78     {
79         private Application _application;
80         /**
81           * @brief Application - is the application that is being Paused
82           *
83           */
84         public Application Application
85         {
86             get
87             {
88                 return _application;
89             }
90             set
91             {
92                 _application = value;
93             }
94         }
95     }
96
97     /**
98       * @brief Event arguments that passed via NUIApplicationResume signal
99       *
100       */
101     internal class NUIApplicationResumedEventArgs : EventArgs
102     {
103         private Application _application;
104         /**
105           * @brief Application - is the application that is being Resumed
106           *
107           */
108         public Application Application
109         {
110             get
111             {
112                 return _application;
113             }
114             set
115             {
116                 _application = value;
117             }
118         }
119     }
120
121     /**
122       * @brief Event arguments that passed via NUIApplicationReset signal
123       *
124       */
125     internal class NUIApplicationResetEventArgs : EventArgs
126     {
127         private Application _application;
128         /**
129           * @brief Application - is the application that is being Reset
130           *
131           */
132         public Application Application
133         {
134             get
135             {
136                 return _application;
137             }
138             set
139             {
140                 _application = value;
141             }
142         }
143     }
144
145     /**
146       * @brief Event arguments that passed via NUIApplicationResize signal
147       *
148       */
149     internal class NUIApplicationResizedEventArgs : EventArgs
150     {
151         private Application _application;
152         /**
153           * @brief Application - is the application that is being Resized
154           *
155           */
156         public Application Application
157         {
158             get
159             {
160                 return _application;
161             }
162             set
163             {
164                 _application = value;
165             }
166         }
167     }
168
169     /**
170       * @brief Event arguments that passed via NUIApplicationLanguageChanged signal
171       *
172       */
173     internal class NUIApplicationLanguageChangedEventArgs : EventArgs
174     {
175         private Application _application;
176         /**
177           * @brief Application - is the application that is being affected with Device's language change
178           *
179           */
180         public Application Application
181         {
182             get
183             {
184                 return _application;
185             }
186             set
187             {
188                 _application = value;
189             }
190         }
191     }
192
193     /**
194       * @brief Event arguments that passed via NUIApplicationRegionChanged signal
195       *
196       */
197     internal class NUIApplicationRegionChangedEventArgs : EventArgs
198     {
199         private Application _application;
200         /**
201           * @brief Application - is the application that is being affected with Device's region change
202           *
203           */
204         public Application Application
205         {
206             get
207             {
208                 return _application;
209             }
210             set
211             {
212                 _application = value;
213             }
214         }
215     }
216
217     /**
218       * @brief Event arguments that passed via NUIApplicationBatteryLow signal
219       *
220       */
221     internal class NUIApplicationBatteryLowEventArgs : EventArgs
222     {
223         private Application.BatteryStatus _status;
224         /**
225           * @brief Application - is the application that is being affected when the battery level of the device is low
226           *
227           */
228         public Application.BatteryStatus BatteryStatus
229         {
230             get
231             {
232                 return _status;
233             }
234             set
235             {
236                 _status = value;
237             }
238         }
239     }
240
241     /**
242       * @brief Event arguments that passed via NUIApplicationMemoryLow signal
243       *
244       */
245     internal class NUIApplicationMemoryLowEventArgs : EventArgs
246     {
247         private Application.MemoryStatus _status;
248         /**
249           * @brief Application - is the application that is being affected when the memory level of the device is low
250           *
251           */
252         public Application.MemoryStatus MemoryStatus
253         {
254             get
255             {
256                 return _status;
257             }
258             set
259             {
260                 _status = value;
261             }
262         }
263     }
264
265     /**
266       * @brief Event arguments that passed via NUIApplicationAppControl  signal
267       *
268       */
269     internal class NUIApplicationAppControlEventArgs : EventArgs
270     {
271         private Application _application;
272         private IntPtr _voidp;
273         /**
274           * @brief Application - is the application that is receiving the launch request from another application
275           *
276           */
277         public Application Application
278         {
279             get
280             {
281                 return _application;
282             }
283             set
284             {
285                 _application = value;
286             }
287         }
288         /**
289           * @brief VoidP - contains the information about why the application is launched
290           *
291           */
292         public IntPtr VoidP
293         {
294             get
295             {
296                 return _voidp;
297             }
298             set
299             {
300                 _voidp = value;
301             }
302         }
303     }
304
305     internal class Application : BaseHandle
306     {
307         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
308
309         internal Application(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Application_SWIGUpcast(cPtr), cMemoryOwn)
310         {
311             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
312         }
313
314         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Application obj)
315         {
316             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
317         }
318
319         protected override void Dispose(DisposeTypes type)
320         {
321             if (disposed)
322             {
323                 return;
324             }
325
326             if (type == DisposeTypes.Explicit)
327             {
328                 //Called by User
329                 //Release your own managed resources here.
330                 //You should release all of your own disposable objects here.
331
332             }
333
334             //Release your own unmanaged resources here.
335             //You should not access any managed member here except static instance.
336             //because the execution order of Finalizes is non-deterministic.
337
338             if (_applicationInitEventCallbackDelegate != null)
339             {
340                 this.InitSignal().Disconnect(_applicationInitEventCallbackDelegate);
341             }
342
343             if (_applicationTerminateEventCallbackDelegate != null)
344             {
345                 this.TerminateSignal().Disconnect(_applicationTerminateEventCallbackDelegate);
346             }
347
348             if (_applicationPauseEventCallbackDelegate != null)
349             {
350                 this.PauseSignal().Disconnect(_applicationPauseEventCallbackDelegate);
351             }
352
353             if (_applicationResumeEventCallbackDelegate != null)
354             {
355                 this.ResumeSignal().Disconnect(_applicationResumeEventCallbackDelegate);
356             }
357
358             if (_applicationResetEventCallbackDelegate != null)
359             {
360                 this.ResetSignal().Disconnect(_applicationResetEventCallbackDelegate);
361             }
362
363             if (_applicationResizeEventCallbackDelegate != null)
364             {
365                 this.ResizeSignal().Disconnect(_applicationResizeEventCallbackDelegate);
366             }
367
368             if (_applicationLanguageChangedEventCallbackDelegate != null)
369             {
370                 this.LanguageChangedSignal().Disconnect(_applicationLanguageChangedEventCallbackDelegate);
371             }
372
373             if (_applicationRegionChangedEventCallbackDelegate != null)
374             {
375                 this.RegionChangedSignal().Disconnect(_applicationRegionChangedEventCallbackDelegate);
376             }
377
378             if (_applicationBatteryLowEventCallbackDelegate != null)
379             {
380                 this.BatteryLowSignal().Disconnect(_applicationBatteryLowEventCallbackDelegate);
381             }
382
383             if (_applicationMemoryLowEventCallbackDelegate != null)
384             {
385                 this.MemoryLowSignal().Disconnect(_applicationMemoryLowEventCallbackDelegate);
386             }
387
388             if (_applicationAppControlEventCallbackDelegate != null)
389             {
390                 this.AppControlSignal().Disconnect(_applicationAppControlEventCallbackDelegate);
391             }
392
393             if (swigCPtr.Handle != global::System.IntPtr.Zero)
394             {
395                 if (swigCMemOwn)
396                 {
397                     swigCMemOwn = false;
398                     NDalicPINVOKE.delete_Application(swigCPtr);
399                 }
400                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
401             }
402
403             base.Dispose(type);
404         }
405
406         /// <since_tizen> 4 </since_tizen>
407         public enum BatteryStatus
408         {
409             Normal,
410             CriticallyLow,
411             PowerOff
412         };
413
414         /// <since_tizen> 4 </since_tizen>
415         public enum MemoryStatus
416         {
417             Normal,
418             Low,
419             CriticallyLow
420         };
421
422         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
423         private delegate void NUIApplicationInitEventCallbackDelegate(IntPtr application);
424         private DaliEventHandler<object, NUIApplicationInitEventArgs> _applicationInitEventHandler;
425         private NUIApplicationInitEventCallbackDelegate _applicationInitEventCallbackDelegate;
426
427
428         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
429         private delegate void NUIApplicationTerminateEventCallbackDelegate(IntPtr application);
430         private DaliEventHandler<object, NUIApplicationTerminatingEventArgs> _applicationTerminateEventHandler;
431         private NUIApplicationTerminateEventCallbackDelegate _applicationTerminateEventCallbackDelegate;
432
433
434         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
435         private delegate void NUIApplicationPauseEventCallbackDelegate(IntPtr application);
436         private DaliEventHandler<object, NUIApplicationPausedEventArgs> _applicationPauseEventHandler;
437         private NUIApplicationPauseEventCallbackDelegate _applicationPauseEventCallbackDelegate;
438
439         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
440         private delegate void NUIApplicationResumeEventCallbackDelegate(IntPtr application);
441         private DaliEventHandler<object, NUIApplicationResumedEventArgs> _applicationResumeEventHandler;
442         private NUIApplicationResumeEventCallbackDelegate _applicationResumeEventCallbackDelegate;
443
444         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
445         private delegate void NUIApplicationResetEventCallbackDelegate(IntPtr application);
446         private DaliEventHandler<object, NUIApplicationResetEventArgs> _applicationResetEventHandler;
447         private NUIApplicationResetEventCallbackDelegate _applicationResetEventCallbackDelegate;
448
449         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
450         private delegate void NUIApplicationResizeEventCallbackDelegate(IntPtr application);
451         private DaliEventHandler<object, NUIApplicationResizedEventArgs> _applicationResizeEventHandler;
452         private NUIApplicationResizeEventCallbackDelegate _applicationResizeEventCallbackDelegate;
453
454         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
455         private delegate void NUIApplicationLanguageChangedEventCallbackDelegate(IntPtr application);
456         private DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> _applicationLanguageChangedEventHandler;
457         private NUIApplicationLanguageChangedEventCallbackDelegate _applicationLanguageChangedEventCallbackDelegate;
458
459
460         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
461         private delegate void NUIApplicationRegionChangedEventCallbackDelegate(IntPtr application);
462         private DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> _applicationRegionChangedEventHandler;
463         private NUIApplicationRegionChangedEventCallbackDelegate _applicationRegionChangedEventCallbackDelegate;
464
465         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
466         private delegate void NUIApplicationBatteryLowEventCallbackDelegate(BatteryStatus status);
467         private DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> _applicationBatteryLowEventHandler;
468         private NUIApplicationBatteryLowEventCallbackDelegate _applicationBatteryLowEventCallbackDelegate;
469
470         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
471         private delegate void NUIApplicationMemoryLowEventCallbackDelegate(MemoryStatus status);
472         private DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> _applicationMemoryLowEventHandler;
473         private NUIApplicationMemoryLowEventCallbackDelegate _applicationMemoryLowEventCallbackDelegate;
474
475         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
476         private delegate void NUIApplicationAppControlEventCallbackDelegate(IntPtr application, IntPtr voidp);
477         private DaliEventHandler<object, NUIApplicationAppControlEventArgs> _applicationAppControlEventHandler;
478         private NUIApplicationAppControlEventCallbackDelegate _applicationAppControlEventCallbackDelegate;
479
480         /**
481           * @brief Event for Initialized signal which can be used to subscribe/unsubscribe the event handler
482           *  provided by the user. Initialized signal is emitted when application is initialised
483           */
484         public event DaliEventHandler<object, NUIApplicationInitEventArgs> Initialized
485         {
486             add
487             {
488                 lock (this)
489                 {
490                     // Restricted to only one listener
491                     if (_applicationInitEventHandler == null)
492                     {
493                         _applicationInitEventHandler += value;
494
495                         _applicationInitEventCallbackDelegate = new NUIApplicationInitEventCallbackDelegate(OnApplicationInit);
496                         this.InitSignal().Connect(_applicationInitEventCallbackDelegate);
497                     }
498                 }
499             }
500
501             remove
502             {
503                 lock (this)
504                 {
505                     if (_applicationInitEventHandler != null)
506                     {
507                         this.InitSignal().Disconnect(_applicationInitEventCallbackDelegate);
508                     }
509
510                     _applicationInitEventHandler -= value;
511                 }
512             }
513         }
514
515         // Callback for Application InitSignal
516         private void OnApplicationInit(IntPtr data)
517         {
518             if (Version.DaliVersionMatchWithNUI() == false)
519             {
520                 Tizen.Log.Fatal("NUI", "Dali and NUI are version mismatched!");
521             }
522
523             // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread.
524             DisposeQueue.Instance.Initialize();
525             NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs();
526
527             // Populate all members of "e" (NUIApplicationInitEventArgs) with real data
528             e.Application = Application.GetApplicationFromPtr(data);
529
530             if (_applicationInitEventHandler != null)
531             {
532                 //here we send all data to user event handlers
533                 _applicationInitEventHandler(this, e);
534             }
535         }
536
537         /**
538           * @brief Event for Terminated signal which can be used to subscribe/unsubscribe the event handler
539           *  provided by the user. Terminated signal is emitted when application is terminating
540           */
541         public event DaliEventHandler<object, NUIApplicationTerminatingEventArgs> Terminating
542         {
543             add
544             {
545                 lock (this)
546                 {
547                     // Restricted to only one listener
548                     if (_applicationTerminateEventHandler == null)
549                     {
550                         _applicationTerminateEventHandler += value;
551
552                         _applicationTerminateEventCallbackDelegate = new NUIApplicationTerminateEventCallbackDelegate(OnNUIApplicationTerminate);
553                         this.TerminateSignal().Connect(_applicationTerminateEventCallbackDelegate);
554                     }
555                 }
556             }
557
558             remove
559             {
560                 lock (this)
561                 {
562                     if (_applicationTerminateEventHandler != null)
563                     {
564                         this.TerminateSignal().Disconnect(_applicationTerminateEventCallbackDelegate);
565                     }
566
567                     _applicationTerminateEventHandler -= value;
568                 }
569             }
570         }
571
572         // Callback for Application TerminateSignal
573         private void OnNUIApplicationTerminate(IntPtr data)
574         {
575             NUIApplicationTerminatingEventArgs e = new NUIApplicationTerminatingEventArgs();
576
577             // Populate all members of "e" (NUIApplicationTerminateEventArgs) with real data
578             e.Application = Application.GetApplicationFromPtr(data);
579
580             if (_applicationTerminateEventHandler != null)
581             {
582                 //here we send all data to user event handlers
583                 _applicationTerminateEventHandler(this, e);
584             }
585         }
586
587         /**
588           * @brief Event for Paused signal which can be used to subscribe/unsubscribe the event handler
589           * provided by the user. Paused signal is emitted when application is paused
590           */
591         public event DaliEventHandler<object, NUIApplicationPausedEventArgs> Paused
592         {
593             add
594             {
595                 lock (this)
596                 {
597                     // Restricted to only one listener
598                     if (_applicationPauseEventHandler == null)
599                     {
600                         _applicationPauseEventHandler += value;
601
602                         _applicationPauseEventCallbackDelegate = new NUIApplicationPauseEventCallbackDelegate(OnNUIApplicationPause);
603                         this.PauseSignal().Connect(_applicationPauseEventCallbackDelegate);
604                     }
605                 }
606             }
607
608             remove
609             {
610                 lock (this)
611                 {
612                     if (_applicationPauseEventHandler != null)
613                     {
614                         this.PauseSignal().Disconnect(_applicationPauseEventCallbackDelegate);
615                     }
616
617                     _applicationPauseEventHandler -= value;
618                 }
619             }
620         }
621
622         // Callback for Application PauseSignal
623         private void OnNUIApplicationPause(IntPtr data)
624         {
625             NUIApplicationPausedEventArgs e = new NUIApplicationPausedEventArgs();
626
627             // Populate all members of "e" (NUIApplicationPauseEventArgs) with real data
628             e.Application = Application.GetApplicationFromPtr(data);
629
630             if (_applicationPauseEventHandler != null)
631             {
632                 //here we send all data to user event handlers
633                 _applicationPauseEventHandler(this, e);
634             }
635         }
636
637         /**
638           * @brief Event for Resumed signal which can be used to subscribe/unsubscribe the event handler
639           *  provided by the user. Resumed signal is emitted when application is resumed
640           */
641         public event DaliEventHandler<object, NUIApplicationResumedEventArgs> Resumed
642         {
643             add
644             {
645                 lock (this)
646                 {
647                     // Restricted to only one listener
648                     if (_applicationResumeEventHandler == null)
649                     {
650                         _applicationResumeEventHandler += value;
651
652                         _applicationResumeEventCallbackDelegate = new NUIApplicationResumeEventCallbackDelegate(OnNUIApplicationResume);
653                         this.ResumeSignal().Connect(_applicationResumeEventCallbackDelegate);
654                     }
655                 }
656             }
657
658             remove
659             {
660                 lock (this)
661                 {
662                     if (_applicationResumeEventHandler != null)
663                     {
664                         this.ResumeSignal().Disconnect(_applicationResumeEventCallbackDelegate);
665                     }
666
667                     _applicationResumeEventHandler -= value;
668                 }
669             }
670         }
671
672         // Callback for Application ResumeSignal
673         private void OnNUIApplicationResume(IntPtr data)
674         {
675             NUIApplicationResumedEventArgs e = new NUIApplicationResumedEventArgs();
676
677             // Populate all members of "e" (NUIApplicationResumeEventArgs) with real data
678             e.Application = Application.GetApplicationFromPtr(data);
679
680             if (_applicationResumeEventHandler != null)
681             {
682                 //here we send all data to user event handlers
683                 _applicationResumeEventHandler(this, e);
684             }
685         }
686
687         /**
688           * @brief Event for Reset signal which can be used to subscribe/unsubscribe the event handler
689           *  provided by the user. Reset signal is emitted when application is reset
690           */
691         public new event DaliEventHandler<object, NUIApplicationResetEventArgs> Reset
692         {
693             add
694             {
695                 lock (this)
696                 {
697                     // Restricted to only one listener
698                     if (_applicationResetEventHandler == null)
699                     {
700                         _applicationResetEventHandler += value;
701
702                         _applicationResetEventCallbackDelegate = new NUIApplicationResetEventCallbackDelegate(OnNUIApplicationReset);
703                         this.ResetSignal().Connect(_applicationResetEventCallbackDelegate);
704                     }
705                 }
706             }
707
708             remove
709             {
710                 lock (this)
711                 {
712                     if (_applicationResetEventHandler != null)
713                     {
714                         this.ResetSignal().Disconnect(_applicationResetEventCallbackDelegate);
715                     }
716
717                     _applicationResetEventHandler -= value;
718                 }
719             }
720         }
721
722         // Callback for Application ResetSignal
723         private void OnNUIApplicationReset(IntPtr data)
724         {
725             NUIApplicationResetEventArgs e = new NUIApplicationResetEventArgs();
726
727             // Populate all members of "e" (NUIApplicationResetEventArgs) with real data
728             e.Application = Application.GetApplicationFromPtr(data);
729
730             if (_applicationResetEventHandler != null)
731             {
732                 //here we send all data to user event handlers
733                 _applicationResetEventHandler(this, e);
734             }
735         }
736
737         /**
738           * @brief Event for Resized signal which can be used to subscribe/unsubscribe the event handler
739           *  provided by the user. Resized signal is emitted when application is resized
740           */
741         public event DaliEventHandler<object, NUIApplicationResizedEventArgs> Resized
742         {
743             add
744             {
745                 lock (this)
746                 {
747                     // Restricted to only one listener
748                     if (_applicationResizeEventHandler == null)
749                     {
750                         _applicationResizeEventHandler += value;
751
752                         _applicationResizeEventCallbackDelegate = new NUIApplicationResizeEventCallbackDelegate(OnNUIApplicationResize);
753                         this.ResizeSignal().Connect(_applicationResizeEventCallbackDelegate);
754                     }
755                 }
756             }
757
758             remove
759             {
760                 lock (this)
761                 {
762                     if (_applicationResizeEventHandler != null)
763                     {
764                         this.ResizeSignal().Disconnect(_applicationResizeEventCallbackDelegate);
765                     }
766
767                     _applicationResizeEventHandler -= value;
768                 }
769             }
770         }
771
772         // Callback for Application ResizeSignal
773         private void OnNUIApplicationResize(IntPtr data)
774         {
775             NUIApplicationResizedEventArgs e = new NUIApplicationResizedEventArgs();
776
777             // Populate all members of "e" (NUIApplicationResizeEventArgs) with real data
778             e.Application = Application.GetApplicationFromPtr(data);
779
780             if (_applicationResizeEventHandler != null)
781             {
782                 //here we send all data to user event handlers
783                 _applicationResizeEventHandler(this, e);
784             }
785         }
786
787         /**
788           * @brief Event for LanguageChanged signal which can be used to subscribe/unsubscribe the event handler
789           *  provided by the user. LanguageChanged signal is emitted when the region of the device is changed.
790           */
791         public event DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> LanguageChanged
792         {
793             add
794             {
795                 lock (this)
796                 {
797                     // Restricted to only one listener
798                     if (_applicationLanguageChangedEventHandler == null)
799                     {
800                         _applicationLanguageChangedEventHandler += value;
801
802                         _applicationLanguageChangedEventCallbackDelegate = new NUIApplicationLanguageChangedEventCallbackDelegate(OnNUIApplicationLanguageChanged);
803                         this.LanguageChangedSignal().Connect(_applicationLanguageChangedEventCallbackDelegate);
804                     }
805                 }
806             }
807
808             remove
809             {
810                 lock (this)
811                 {
812                     if (_applicationLanguageChangedEventHandler != null)
813                     {
814                         this.LanguageChangedSignal().Disconnect(_applicationLanguageChangedEventCallbackDelegate);
815                     }
816
817                     _applicationLanguageChangedEventHandler -= value;
818                 }
819             }
820         }
821
822         // Callback for Application LanguageChangedSignal
823         private void OnNUIApplicationLanguageChanged(IntPtr data)
824         {
825             NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs();
826
827             // Populate all members of "e" (NUIApplicationLanguageChangedEventArgs) with real data
828             e.Application = Application.GetApplicationFromPtr(data);
829
830             if (_applicationLanguageChangedEventHandler != null)
831             {
832                 //here we send all data to user event handlers
833                 _applicationLanguageChangedEventHandler(this, e);
834             }
835         }
836
837         /**
838           * @brief Event for RegionChanged signal which can be used to subscribe/unsubscribe the event handler
839           *  provided by the user. RegionChanged signal is emitted when the region of the device is changed.
840           */
841         public event DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> RegionChanged
842         {
843             add
844             {
845                 lock (this)
846                 {
847                     // Restricted to only one listener
848                     if (_applicationRegionChangedEventHandler == null)
849                     {
850                         _applicationRegionChangedEventHandler += value;
851
852                         _applicationRegionChangedEventCallbackDelegate = new NUIApplicationRegionChangedEventCallbackDelegate(OnNUIApplicationRegionChanged);
853                         this.RegionChangedSignal().Connect(_applicationRegionChangedEventCallbackDelegate);
854                     }
855                 }
856             }
857
858             remove
859             {
860                 lock (this)
861                 {
862                     if (_applicationRegionChangedEventHandler != null)
863                     {
864                         this.RegionChangedSignal().Disconnect(_applicationRegionChangedEventCallbackDelegate);
865                     }
866
867                     _applicationRegionChangedEventHandler -= value;
868                 }
869             }
870         }
871
872         // Callback for Application RegionChangedSignal
873         private void OnNUIApplicationRegionChanged(IntPtr data)
874         {
875             NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs();
876
877             // Populate all members of "e" (NUIApplicationRegionChangedEventArgs) with real data
878             e.Application = Application.GetApplicationFromPtr(data);
879
880             if (_applicationRegionChangedEventHandler != null)
881             {
882                 //here we send all data to user event handlers
883                 _applicationRegionChangedEventHandler(this, e);
884             }
885         }
886
887         /**
888           * @brief Event for BatteryLow signal which can be used to subscribe/unsubscribe the event handler
889           * provided by the user. BatteryLow signal is emitted when the battery level of the device is low.
890           */
891         public event DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> BatteryLow
892         {
893             add
894             {
895                 lock (this)
896                 {
897                     // Restricted to only one listener
898                     if (_applicationBatteryLowEventHandler == null)
899                     {
900                         _applicationBatteryLowEventHandler += value;
901
902                         _applicationBatteryLowEventCallbackDelegate = new NUIApplicationBatteryLowEventCallbackDelegate(OnNUIApplicationBatteryLow);
903                         this.BatteryLowSignal().Connect(_applicationBatteryLowEventCallbackDelegate);
904                     }
905                 }
906             }
907
908             remove
909             {
910                 lock (this)
911                 {
912                     if (_applicationBatteryLowEventHandler != null)
913                     {
914                         this.BatteryLowSignal().Disconnect(_applicationBatteryLowEventCallbackDelegate);
915                     }
916
917                     _applicationBatteryLowEventHandler -= value;
918                 }
919             }
920         }
921
922         // Callback for Application BatteryLowSignal
923         private void OnNUIApplicationBatteryLow(BatteryStatus status)
924         {
925             NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
926
927             // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
928             e.BatteryStatus = status;
929
930             if (_applicationBatteryLowEventHandler != null)
931             {
932                 //here we send all data to user event handlers
933                 _applicationBatteryLowEventHandler(this, e);
934             }
935         }
936
937         /**
938           * @brief Event for MemoryLow signal which can be used to subscribe/unsubscribe the event handler
939           *  provided by the user. MemoryLow signal is emitted when the memory level of the device is low.
940           */
941         public event DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> MemoryLow
942         {
943             add
944             {
945                 lock (this)
946                 {
947                     // Restricted to only one listener
948                     if (_applicationMemoryLowEventHandler == null)
949                     {
950                         _applicationMemoryLowEventHandler += value;
951
952                         _applicationMemoryLowEventCallbackDelegate = new NUIApplicationMemoryLowEventCallbackDelegate(OnNUIApplicationMemoryLow);
953                         this.MemoryLowSignal().Connect(_applicationMemoryLowEventCallbackDelegate);
954                     }
955                 }
956             }
957
958             remove
959             {
960                 lock (this)
961                 {
962                     if (_applicationMemoryLowEventHandler != null)
963                     {
964                         this.MemoryLowSignal().Disconnect(_applicationMemoryLowEventCallbackDelegate);
965                     }
966
967                     _applicationMemoryLowEventHandler -= value;
968                 }
969             }
970         }
971
972         // Callback for Application MemoryLowSignal
973         private void OnNUIApplicationMemoryLow(MemoryStatus status)
974         {
975             NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
976
977             // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
978             e.MemoryStatus = status;
979
980             if (_applicationMemoryLowEventHandler != null)
981             {
982                 //here we send all data to user event handlers
983                 _applicationMemoryLowEventHandler(this, e);
984             }
985         }
986
987         /**
988           * @brief Event for AppControl signal which can be used to subscribe/unsubscribe the event handler
989           *  provided by the user. AppControl signal is emitted when another application sends a launch request to the application.
990           */
991         public event DaliEventHandler<object, NUIApplicationAppControlEventArgs> AppControl
992         {
993             add
994             {
995                 lock (this)
996                 {
997                     // Restricted to only one listener
998                     if (_applicationAppControlEventHandler == null)
999                     {
1000                         _applicationAppControlEventHandler += value;
1001
1002                         _applicationAppControlEventCallbackDelegate = new NUIApplicationAppControlEventCallbackDelegate(OnNUIApplicationAppControl);
1003                         this.AppControlSignal().Connect(_applicationAppControlEventCallbackDelegate);
1004                     }
1005                 }
1006             }
1007
1008             remove
1009             {
1010                 lock (this)
1011                 {
1012                     if (_applicationAppControlEventHandler != null)
1013                     {
1014                         this.AppControlSignal().Disconnect(_applicationAppControlEventCallbackDelegate);
1015                     }
1016
1017                     _applicationAppControlEventHandler -= value;
1018                 }
1019             }
1020         }
1021
1022         // Callback for Application AppControlSignal
1023         private void OnNUIApplicationAppControl(IntPtr application, IntPtr voidp)
1024         {
1025             NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs();
1026
1027             // Populate all members of "e" (NUIApplicationAppControlEventArgs) with real data
1028             e.Application = Application.GetApplicationFromPtr(application);
1029             e.VoidP = voidp;
1030
1031             if (_applicationAppControlEventHandler != null)
1032             {
1033                 //here we send all data to user event handlers
1034                 _applicationAppControlEventHandler(this, e);
1035             }
1036         }
1037
1038         private static Application _instance; // singleton
1039
1040         public static Application Instance
1041         {
1042             get
1043             {
1044                 return _instance;
1045             }
1046         }
1047
1048         public static Application GetApplicationFromPtr(global::System.IntPtr cPtr)
1049         {
1050             Application ret = new Application(cPtr, false);
1051             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1052             return ret;
1053         }
1054
1055         public static Application NewApplication()
1056         {
1057             return NewApplication("", Application.WindowMode.Opaque);
1058         }
1059
1060         public static Application NewApplication(string stylesheet)
1061         {
1062             return NewApplication(stylesheet, Application.WindowMode.Opaque);
1063         }
1064
1065         public static Application NewApplication(string stylesheet, Application.WindowMode windowMode)
1066         {
1067             // register all Views with the type registry, so that can be created / styled via JSON
1068             //ViewRegistryHelper.Initialize(); //moved to Application side.
1069
1070             Application ret = New(1, stylesheet, windowMode);
1071             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1072
1073             // set the singleton
1074             _instance = ret;
1075             return ret;
1076         }
1077
1078
1079         public static Application NewApplication(string[] args, string stylesheet, Application.WindowMode windowMode)
1080         {
1081             Application ret = New(args, stylesheet, (Application.WindowMode)windowMode);
1082             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1083
1084             // set the singleton
1085             _instance = ret;
1086             return _instance;
1087         }
1088
1089         /// <summary>
1090         /// Ensures that the function passed in is called from the main loop when it is idle.
1091         /// </summary>
1092         /// <param name="func">The function to call</param>
1093         /// <returns>true if added successfully, false otherwise</returns>
1094         public bool AddIdle(System.Delegate func)
1095         {
1096             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
1097             System.IntPtr ip2 = NDalicManualPINVOKE.MakeCallback(new System.Runtime.InteropServices.HandleRef(this, ip));
1098
1099             bool ret = NDalicPINVOKE.Application_AddIdle(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip2));
1100
1101             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1102             return ret;
1103         }
1104
1105         /**
1106         * Outer::outer_method(int)
1107         */
1108         public static Application New()
1109         {
1110             Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_0(), true);
1111             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1112             return ret;
1113         }
1114
1115         public static Application New(int argc)
1116         {
1117             Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_1(argc), true);
1118             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1119             return ret;
1120         }
1121
1122         public static Application New(int argc, string stylesheet)
1123         {
1124             Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_2(argc, stylesheet), true);
1125             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1126             return ret;
1127         }
1128
1129         public static Application New(int argc, string stylesheet, Application.WindowMode windowMode)
1130         {
1131             Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_3(argc, stylesheet, (int)windowMode), true);
1132             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1133             return ret;
1134         }
1135
1136         public static Application New(string[] args, string stylesheet, Application.WindowMode windowMode)
1137         {
1138             int argc = args.Length;
1139             string argvStr = string.Join(" ", args);
1140
1141             Application ret = new Application(NDalicPINVOKE.Application_New__MANUAL_4(argc, argvStr, stylesheet, (int)windowMode), true);
1142             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1143             return ret;
1144         }
1145
1146         public static Application New(int argc, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1147         {
1148             Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_4(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1149             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1150             return ret;
1151         }
1152
1153         public Application() : this(NDalicPINVOKE.new_Application__SWIG_0(), true)
1154         {
1155             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1156         }
1157
1158         public Application(Application application) : this(NDalicPINVOKE.new_Application__SWIG_1(Application.getCPtr(application)), true)
1159         {
1160             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1161         }
1162
1163         public Application Assign(Application application)
1164         {
1165             Application ret = new Application(NDalicPINVOKE.Application_Assign(swigCPtr, Application.getCPtr(application)), false);
1166             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1167             return ret;
1168         }
1169
1170         public void MainLoop()
1171         {
1172             NDalicPINVOKE.Application_MainLoop__SWIG_0(swigCPtr);
1173             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1174         }
1175
1176         internal void MainLoop(SWIGTYPE_p_Configuration__ContextLoss configuration)
1177         {
1178             NDalicPINVOKE.Application_MainLoop__SWIG_1(swigCPtr, SWIGTYPE_p_Configuration__ContextLoss.getCPtr(configuration));
1179             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1180         }
1181
1182         public void Lower()
1183         {
1184             NDalicPINVOKE.Application_Lower(swigCPtr);
1185             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1186         }
1187
1188         public void Quit()
1189         {
1190             NDalicPINVOKE.Application_Quit(swigCPtr);
1191             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1192         }
1193
1194         internal bool AddIdle(SWIGTYPE_p_Dali__CallbackBase callback)
1195         {
1196             bool ret = NDalicPINVOKE.Application_AddIdle(swigCPtr, SWIGTYPE_p_Dali__CallbackBase.getCPtr(callback));
1197             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1198             return ret;
1199         }
1200
1201         public Window GetWindow()
1202         {
1203             Window ret = new Window(NDalicPINVOKE.Application_GetWindow(swigCPtr), true);
1204             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1205             return ret;
1206         }
1207
1208         public void ReplaceWindow(Rectangle windowPosition, string name)
1209         {
1210             NDalicPINVOKE.Application_ReplaceWindow(swigCPtr, Rectangle.getCPtr(windowPosition), name);
1211             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1212         }
1213
1214         public static string GetResourcePath()
1215         {
1216             string ret = NDalicPINVOKE.Application_GetResourcePath();
1217             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1218             return ret;
1219         }
1220
1221         internal void SetViewMode(ViewMode viewMode)
1222         {
1223             NDalicPINVOKE.Application_SetViewMode(swigCPtr, (int)viewMode);
1224             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1225         }
1226
1227         internal ViewMode GetViewMode()
1228         {
1229             ViewMode ret = (ViewMode)NDalicPINVOKE.Application_GetViewMode(swigCPtr);
1230             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1231             return ret;
1232         }
1233
1234         public void SetStereoBase(float stereoBase)
1235         {
1236             NDalicPINVOKE.Application_SetStereoBase(swigCPtr, stereoBase);
1237             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1238         }
1239
1240         public float GetStereoBase()
1241         {
1242             float ret = NDalicPINVOKE.Application_GetStereoBase(swigCPtr);
1243             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1244             return ret;
1245         }
1246
1247         public string GetLanguage()
1248         {
1249             string ret = NDalicPINVOKE.Application_GetLanguage(swigCPtr);
1250             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1251             return ret;
1252         }
1253
1254         public string GetRegion()
1255         {
1256             string ret = NDalicPINVOKE.Application_GetRegion(swigCPtr);
1257             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1258             return ret;
1259         }
1260
1261
1262         internal ApplicationSignal InitSignal()
1263         {
1264             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_InitSignal(swigCPtr), false);
1265             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1266             return ret;
1267         }
1268
1269         internal ApplicationSignal TerminateSignal()
1270         {
1271             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_TerminateSignal(swigCPtr), false);
1272             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1273             return ret;
1274         }
1275
1276         internal ApplicationSignal PauseSignal()
1277         {
1278             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_PauseSignal(swigCPtr), false);
1279             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1280             return ret;
1281         }
1282
1283         internal ApplicationSignal ResumeSignal()
1284         {
1285             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_ResumeSignal(swigCPtr), false);
1286             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1287             return ret;
1288         }
1289
1290         internal ApplicationSignal ResetSignal()
1291         {
1292             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_ResetSignal(swigCPtr), false);
1293             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1294             return ret;
1295         }
1296
1297         internal ApplicationSignal ResizeSignal()
1298         {
1299             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_ResizeSignal(swigCPtr), false);
1300             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1301             return ret;
1302         }
1303
1304         internal ApplicationControlSignal AppControlSignal()
1305         {
1306             ApplicationControlSignal ret = new ApplicationControlSignal(NDalicPINVOKE.Application_AppControlSignal(swigCPtr), false);
1307             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1308             return ret;
1309         }
1310
1311         internal ApplicationSignal LanguageChangedSignal()
1312         {
1313             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_LanguageChangedSignal(swigCPtr), false);
1314             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1315             return ret;
1316         }
1317
1318         internal ApplicationSignal RegionChangedSignal()
1319         {
1320             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_RegionChangedSignal(swigCPtr), false);
1321             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1322             return ret;
1323         }
1324
1325         internal LowBatterySignalType BatteryLowSignal()
1326         {
1327             LowBatterySignalType ret = new LowBatterySignalType(NDalicPINVOKE.Application_LowBatterySignal(swigCPtr), false);
1328             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1329             return ret;
1330         }
1331
1332         internal LowMemorySignalType MemoryLowSignal()
1333         {
1334             LowMemorySignalType ret = new LowMemorySignalType(NDalicPINVOKE.Application_LowMemorySignal(swigCPtr), false);
1335             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1336             return ret;
1337         }
1338
1339         /// <since_tizen> 3 </since_tizen>
1340         public enum WindowMode
1341         {
1342             Opaque = 0,
1343             Transparent = 1
1344         }
1345
1346     }
1347
1348 }