[NUI] NUI Integration - nui_1.2.83 version (#98)
[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             // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread.
519             DisposeQueue.Instance.Initialize();
520
521             NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs();
522             // Populate all members of "e" (NUIApplicationInitEventArgs) with real data
523             e.Application = Application.GetApplicationFromPtr(data);
524             if (_applicationInitEventHandler != null)
525             {
526                 //here we send all data to user event handlers
527                 _applicationInitEventHandler(this, e);
528             }
529         }
530
531         /**
532           * @brief Event for Terminated signal which can be used to subscribe/unsubscribe the event handler
533           *  provided by the user. Terminated signal is emitted when application is terminating
534           */
535         public event DaliEventHandler<object, NUIApplicationTerminatingEventArgs> Terminating
536         {
537             add
538             {
539                 lock (this)
540                 {
541                     // Restricted to only one listener
542                     if (_applicationTerminateEventHandler == null)
543                     {
544                         _applicationTerminateEventHandler += value;
545
546                         _applicationTerminateEventCallbackDelegate = new NUIApplicationTerminateEventCallbackDelegate(OnNUIApplicationTerminate);
547                         this.TerminateSignal().Connect(_applicationTerminateEventCallbackDelegate);
548                     }
549                 }
550             }
551
552             remove
553             {
554                 lock (this)
555                 {
556                     if (_applicationTerminateEventHandler != null)
557                     {
558                         this.TerminateSignal().Disconnect(_applicationTerminateEventCallbackDelegate);
559                     }
560
561                     _applicationTerminateEventHandler -= value;
562                 }
563             }
564         }
565
566         // Callback for Application TerminateSignal
567         private void OnNUIApplicationTerminate(IntPtr data)
568         {
569             NUIApplicationTerminatingEventArgs e = new NUIApplicationTerminatingEventArgs();
570
571             // Populate all members of "e" (NUIApplicationTerminateEventArgs) with real data
572             e.Application = Application.GetApplicationFromPtr(data);
573
574             if (_applicationTerminateEventHandler != null)
575             {
576                 //here we send all data to user event handlers
577                 _applicationTerminateEventHandler(this, e);
578             }
579         }
580
581         /**
582           * @brief Event for Paused signal which can be used to subscribe/unsubscribe the event handler
583           * provided by the user. Paused signal is emitted when application is paused
584           */
585         public event DaliEventHandler<object, NUIApplicationPausedEventArgs> Paused
586         {
587             add
588             {
589                 lock (this)
590                 {
591                     // Restricted to only one listener
592                     if (_applicationPauseEventHandler == null)
593                     {
594                         _applicationPauseEventHandler += value;
595
596                         _applicationPauseEventCallbackDelegate = new NUIApplicationPauseEventCallbackDelegate(OnNUIApplicationPause);
597                         this.PauseSignal().Connect(_applicationPauseEventCallbackDelegate);
598                     }
599                 }
600             }
601
602             remove
603             {
604                 lock (this)
605                 {
606                     if (_applicationPauseEventHandler != null)
607                     {
608                         this.PauseSignal().Disconnect(_applicationPauseEventCallbackDelegate);
609                     }
610
611                     _applicationPauseEventHandler -= value;
612                 }
613             }
614         }
615
616         // Callback for Application PauseSignal
617         private void OnNUIApplicationPause(IntPtr data)
618         {
619             NUIApplicationPausedEventArgs e = new NUIApplicationPausedEventArgs();
620
621             // Populate all members of "e" (NUIApplicationPauseEventArgs) with real data
622             e.Application = Application.GetApplicationFromPtr(data);
623
624             if (_applicationPauseEventHandler != null)
625             {
626                 //here we send all data to user event handlers
627                 _applicationPauseEventHandler(this, e);
628             }
629         }
630
631         /**
632           * @brief Event for Resumed signal which can be used to subscribe/unsubscribe the event handler
633           *  provided by the user. Resumed signal is emitted when application is resumed
634           */
635         public event DaliEventHandler<object, NUIApplicationResumedEventArgs> Resumed
636         {
637             add
638             {
639                 lock (this)
640                 {
641                     // Restricted to only one listener
642                     if (_applicationResumeEventHandler == null)
643                     {
644                         _applicationResumeEventHandler += value;
645
646                         _applicationResumeEventCallbackDelegate = new NUIApplicationResumeEventCallbackDelegate(OnNUIApplicationResume);
647                         this.ResumeSignal().Connect(_applicationResumeEventCallbackDelegate);
648                     }
649                 }
650             }
651
652             remove
653             {
654                 lock (this)
655                 {
656                     if (_applicationResumeEventHandler != null)
657                     {
658                         this.ResumeSignal().Disconnect(_applicationResumeEventCallbackDelegate);
659                     }
660
661                     _applicationResumeEventHandler -= value;
662                 }
663             }
664         }
665
666         // Callback for Application ResumeSignal
667         private void OnNUIApplicationResume(IntPtr data)
668         {
669             NUIApplicationResumedEventArgs e = new NUIApplicationResumedEventArgs();
670
671             // Populate all members of "e" (NUIApplicationResumeEventArgs) with real data
672             e.Application = Application.GetApplicationFromPtr(data);
673
674             if (_applicationResumeEventHandler != null)
675             {
676                 //here we send all data to user event handlers
677                 _applicationResumeEventHandler(this, e);
678             }
679         }
680
681         /**
682           * @brief Event for Reset signal which can be used to subscribe/unsubscribe the event handler
683           *  provided by the user. Reset signal is emitted when application is reset
684           */
685         public new event DaliEventHandler<object, NUIApplicationResetEventArgs> Reset
686         {
687             add
688             {
689                 lock (this)
690                 {
691                     // Restricted to only one listener
692                     if (_applicationResetEventHandler == null)
693                     {
694                         _applicationResetEventHandler += value;
695
696                         _applicationResetEventCallbackDelegate = new NUIApplicationResetEventCallbackDelegate(OnNUIApplicationReset);
697                         this.ResetSignal().Connect(_applicationResetEventCallbackDelegate);
698                     }
699                 }
700             }
701
702             remove
703             {
704                 lock (this)
705                 {
706                     if (_applicationResetEventHandler != null)
707                     {
708                         this.ResetSignal().Disconnect(_applicationResetEventCallbackDelegate);
709                     }
710
711                     _applicationResetEventHandler -= value;
712                 }
713             }
714         }
715
716         // Callback for Application ResetSignal
717         private void OnNUIApplicationReset(IntPtr data)
718         {
719             NUIApplicationResetEventArgs e = new NUIApplicationResetEventArgs();
720
721             // Populate all members of "e" (NUIApplicationResetEventArgs) with real data
722             e.Application = Application.GetApplicationFromPtr(data);
723
724             if (_applicationResetEventHandler != null)
725             {
726                 //here we send all data to user event handlers
727                 _applicationResetEventHandler(this, e);
728             }
729         }
730
731         /**
732           * @brief Event for Resized signal which can be used to subscribe/unsubscribe the event handler
733           *  provided by the user. Resized signal is emitted when application is resized
734           */
735         public event DaliEventHandler<object, NUIApplicationResizedEventArgs> Resized
736         {
737             add
738             {
739                 lock (this)
740                 {
741                     // Restricted to only one listener
742                     if (_applicationResizeEventHandler == null)
743                     {
744                         _applicationResizeEventHandler += value;
745
746                         _applicationResizeEventCallbackDelegate = new NUIApplicationResizeEventCallbackDelegate(OnNUIApplicationResize);
747                         this.ResizeSignal().Connect(_applicationResizeEventCallbackDelegate);
748                     }
749                 }
750             }
751
752             remove
753             {
754                 lock (this)
755                 {
756                     if (_applicationResizeEventHandler != null)
757                     {
758                         this.ResizeSignal().Disconnect(_applicationResizeEventCallbackDelegate);
759                     }
760
761                     _applicationResizeEventHandler -= value;
762                 }
763             }
764         }
765
766         // Callback for Application ResizeSignal
767         private void OnNUIApplicationResize(IntPtr data)
768         {
769             NUIApplicationResizedEventArgs e = new NUIApplicationResizedEventArgs();
770
771             // Populate all members of "e" (NUIApplicationResizeEventArgs) with real data
772             e.Application = Application.GetApplicationFromPtr(data);
773
774             if (_applicationResizeEventHandler != null)
775             {
776                 //here we send all data to user event handlers
777                 _applicationResizeEventHandler(this, e);
778             }
779         }
780
781         /**
782           * @brief Event for LanguageChanged signal which can be used to subscribe/unsubscribe the event handler
783           *  provided by the user. LanguageChanged signal is emitted when the region of the device is changed.
784           */
785         public event DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> LanguageChanged
786         {
787             add
788             {
789                 lock (this)
790                 {
791                     // Restricted to only one listener
792                     if (_applicationLanguageChangedEventHandler == null)
793                     {
794                         _applicationLanguageChangedEventHandler += value;
795
796                         _applicationLanguageChangedEventCallbackDelegate = new NUIApplicationLanguageChangedEventCallbackDelegate(OnNUIApplicationLanguageChanged);
797                         this.LanguageChangedSignal().Connect(_applicationLanguageChangedEventCallbackDelegate);
798                     }
799                 }
800             }
801
802             remove
803             {
804                 lock (this)
805                 {
806                     if (_applicationLanguageChangedEventHandler != null)
807                     {
808                         this.LanguageChangedSignal().Disconnect(_applicationLanguageChangedEventCallbackDelegate);
809                     }
810
811                     _applicationLanguageChangedEventHandler -= value;
812                 }
813             }
814         }
815
816         // Callback for Application LanguageChangedSignal
817         private void OnNUIApplicationLanguageChanged(IntPtr data)
818         {
819             NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs();
820
821             // Populate all members of "e" (NUIApplicationLanguageChangedEventArgs) with real data
822             e.Application = Application.GetApplicationFromPtr(data);
823
824             if (_applicationLanguageChangedEventHandler != null)
825             {
826                 //here we send all data to user event handlers
827                 _applicationLanguageChangedEventHandler(this, e);
828             }
829         }
830
831         /**
832           * @brief Event for RegionChanged signal which can be used to subscribe/unsubscribe the event handler
833           *  provided by the user. RegionChanged signal is emitted when the region of the device is changed.
834           */
835         public event DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> RegionChanged
836         {
837             add
838             {
839                 lock (this)
840                 {
841                     // Restricted to only one listener
842                     if (_applicationRegionChangedEventHandler == null)
843                     {
844                         _applicationRegionChangedEventHandler += value;
845
846                         _applicationRegionChangedEventCallbackDelegate = new NUIApplicationRegionChangedEventCallbackDelegate(OnNUIApplicationRegionChanged);
847                         this.RegionChangedSignal().Connect(_applicationRegionChangedEventCallbackDelegate);
848                     }
849                 }
850             }
851
852             remove
853             {
854                 lock (this)
855                 {
856                     if (_applicationRegionChangedEventHandler != null)
857                     {
858                         this.RegionChangedSignal().Disconnect(_applicationRegionChangedEventCallbackDelegate);
859                     }
860
861                     _applicationRegionChangedEventHandler -= value;
862                 }
863             }
864         }
865
866         // Callback for Application RegionChangedSignal
867         private void OnNUIApplicationRegionChanged(IntPtr data)
868         {
869             NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs();
870
871             // Populate all members of "e" (NUIApplicationRegionChangedEventArgs) with real data
872             e.Application = Application.GetApplicationFromPtr(data);
873
874             if (_applicationRegionChangedEventHandler != null)
875             {
876                 //here we send all data to user event handlers
877                 _applicationRegionChangedEventHandler(this, e);
878             }
879         }
880
881         /**
882           * @brief Event for BatteryLow signal which can be used to subscribe/unsubscribe the event handler
883           * provided by the user. BatteryLow signal is emitted when the battery level of the device is low.
884           */
885         public event DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> BatteryLow
886         {
887             add
888             {
889                 lock (this)
890                 {
891                     // Restricted to only one listener
892                     if (_applicationBatteryLowEventHandler == null)
893                     {
894                         _applicationBatteryLowEventHandler += value;
895
896                         _applicationBatteryLowEventCallbackDelegate = new NUIApplicationBatteryLowEventCallbackDelegate(OnNUIApplicationBatteryLow);
897                         this.BatteryLowSignal().Connect(_applicationBatteryLowEventCallbackDelegate);
898                     }
899                 }
900             }
901
902             remove
903             {
904                 lock (this)
905                 {
906                     if (_applicationBatteryLowEventHandler != null)
907                     {
908                         this.BatteryLowSignal().Disconnect(_applicationBatteryLowEventCallbackDelegate);
909                     }
910
911                     _applicationBatteryLowEventHandler -= value;
912                 }
913             }
914         }
915
916         // Callback for Application BatteryLowSignal
917         private void OnNUIApplicationBatteryLow(BatteryStatus status)
918         {
919             NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
920
921             // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
922             e.BatteryStatus = status;
923
924             if (_applicationBatteryLowEventHandler != null)
925             {
926                 //here we send all data to user event handlers
927                 _applicationBatteryLowEventHandler(this, e);
928             }
929         }
930
931         /**
932           * @brief Event for MemoryLow signal which can be used to subscribe/unsubscribe the event handler
933           *  provided by the user. MemoryLow signal is emitted when the memory level of the device is low.
934           */
935         public event DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> MemoryLow
936         {
937             add
938             {
939                 lock (this)
940                 {
941                     // Restricted to only one listener
942                     if (_applicationMemoryLowEventHandler == null)
943                     {
944                         _applicationMemoryLowEventHandler += value;
945
946                         _applicationMemoryLowEventCallbackDelegate = new NUIApplicationMemoryLowEventCallbackDelegate(OnNUIApplicationMemoryLow);
947                         this.MemoryLowSignal().Connect(_applicationMemoryLowEventCallbackDelegate);
948                     }
949                 }
950             }
951
952             remove
953             {
954                 lock (this)
955                 {
956                     if (_applicationMemoryLowEventHandler != null)
957                     {
958                         this.MemoryLowSignal().Disconnect(_applicationMemoryLowEventCallbackDelegate);
959                     }
960
961                     _applicationMemoryLowEventHandler -= value;
962                 }
963             }
964         }
965
966         // Callback for Application MemoryLowSignal
967         private void OnNUIApplicationMemoryLow(MemoryStatus status)
968         {
969             NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
970
971             // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
972             e.MemoryStatus = status;
973
974             if (_applicationMemoryLowEventHandler != null)
975             {
976                 //here we send all data to user event handlers
977                 _applicationMemoryLowEventHandler(this, e);
978             }
979         }
980
981         /**
982           * @brief Event for AppControl signal which can be used to subscribe/unsubscribe the event handler
983           *  provided by the user. AppControl signal is emitted when another application sends a launch request to the application.
984           */
985         public event DaliEventHandler<object, NUIApplicationAppControlEventArgs> AppControl
986         {
987             add
988             {
989                 lock (this)
990                 {
991                     // Restricted to only one listener
992                     if (_applicationAppControlEventHandler == null)
993                     {
994                         _applicationAppControlEventHandler += value;
995
996                         _applicationAppControlEventCallbackDelegate = new NUIApplicationAppControlEventCallbackDelegate(OnNUIApplicationAppControl);
997                         this.AppControlSignal().Connect(_applicationAppControlEventCallbackDelegate);
998                     }
999                 }
1000             }
1001
1002             remove
1003             {
1004                 lock (this)
1005                 {
1006                     if (_applicationAppControlEventHandler != null)
1007                     {
1008                         this.AppControlSignal().Disconnect(_applicationAppControlEventCallbackDelegate);
1009                     }
1010
1011                     _applicationAppControlEventHandler -= value;
1012                 }
1013             }
1014         }
1015
1016         // Callback for Application AppControlSignal
1017         private void OnNUIApplicationAppControl(IntPtr application, IntPtr voidp)
1018         {
1019             NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs();
1020
1021             // Populate all members of "e" (NUIApplicationAppControlEventArgs) with real data
1022             e.Application = Application.GetApplicationFromPtr(application);
1023             e.VoidP = voidp;
1024
1025             if (_applicationAppControlEventHandler != null)
1026             {
1027                 //here we send all data to user event handlers
1028                 _applicationAppControlEventHandler(this, e);
1029             }
1030         }
1031
1032         private static Application _instance; // singleton
1033
1034         public static Application Instance
1035         {
1036             get
1037             {
1038                 return _instance;
1039             }
1040         }
1041
1042         public static Application GetApplicationFromPtr(global::System.IntPtr cPtr)
1043         {
1044             Application ret = new Application(cPtr, false);
1045             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1046             return ret;
1047         }
1048
1049         public static Application NewApplication()
1050         {
1051             return NewApplication("", Application.WindowMode.Opaque);
1052         }
1053
1054         public static Application NewApplication(string stylesheet)
1055         {
1056             return NewApplication(stylesheet, Application.WindowMode.Opaque);
1057         }
1058
1059         public static Application NewApplication(string stylesheet, Application.WindowMode windowMode)
1060         {
1061             // register all Views with the type registry, so that can be created / styled via JSON
1062             //ViewRegistryHelper.Initialize(); //moved to Application side.
1063
1064             Application ret = New(1, stylesheet, windowMode);
1065             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1066
1067             // set the singleton
1068             _instance = ret;
1069             return ret;
1070         }
1071
1072
1073         public static Application NewApplication(string[] args, string stylesheet, Application.WindowMode windowMode)
1074         {
1075             Application ret = New(args, stylesheet, (Application.WindowMode)windowMode);
1076             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1077
1078             // set the singleton
1079             _instance = ret;
1080             return _instance;
1081         }
1082
1083         /// <summary>
1084         /// Ensures that the function passed in is called from the main loop when it is idle.
1085         /// </summary>
1086         /// <param name="func">The function to call</param>
1087         /// <returns>true if added successfully, false otherwise</returns>
1088         public bool AddIdle(System.Delegate func)
1089         {
1090             System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
1091             System.IntPtr ip2 = NDalicManualPINVOKE.MakeCallback(new System.Runtime.InteropServices.HandleRef(this, ip));
1092
1093             bool ret = NDalicPINVOKE.Application_AddIdle(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip2));
1094
1095             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1096             return ret;
1097         }
1098
1099         /**
1100         * Outer::outer_method(int)
1101         */
1102         public static Application New()
1103         {
1104             Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_0(), true);
1105             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1106             return ret;
1107         }
1108
1109         public static Application New(int argc)
1110         {
1111             Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_1(argc), true);
1112             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1113             return ret;
1114         }
1115
1116         public static Application New(int argc, string stylesheet)
1117         {
1118             Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_2(argc, stylesheet), true);
1119             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1120             return ret;
1121         }
1122
1123         public static Application New(int argc, string stylesheet, Application.WindowMode windowMode)
1124         {
1125             Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_3(argc, stylesheet, (int)windowMode), true);
1126             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1127             return ret;
1128         }
1129
1130         public static Application New(string[] args, string stylesheet, Application.WindowMode windowMode)
1131         {
1132             int argc = args.Length;
1133             string argvStr = string.Join(" ", args);
1134
1135             Application ret = new Application(NDalicPINVOKE.Application_New__MANUAL_4(argc, argvStr, stylesheet, (int)windowMode), true);
1136             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1137             return ret;
1138         }
1139
1140         public static Application New(int argc, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1141         {
1142             Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_4(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1143             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1144             return ret;
1145         }
1146
1147         public Application() : this(NDalicPINVOKE.new_Application__SWIG_0(), true)
1148         {
1149             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1150         }
1151
1152         public Application(Application application) : this(NDalicPINVOKE.new_Application__SWIG_1(Application.getCPtr(application)), true)
1153         {
1154             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1155         }
1156
1157         public Application Assign(Application application)
1158         {
1159             Application ret = new Application(NDalicPINVOKE.Application_Assign(swigCPtr, Application.getCPtr(application)), false);
1160             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1161             return ret;
1162         }
1163
1164         public void MainLoop()
1165         {
1166             NDalicPINVOKE.Application_MainLoop__SWIG_0(swigCPtr);
1167             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1168         }
1169
1170         internal void MainLoop(SWIGTYPE_p_Configuration__ContextLoss configuration)
1171         {
1172             NDalicPINVOKE.Application_MainLoop__SWIG_1(swigCPtr, SWIGTYPE_p_Configuration__ContextLoss.getCPtr(configuration));
1173             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1174         }
1175
1176         public void Lower()
1177         {
1178             NDalicPINVOKE.Application_Lower(swigCPtr);
1179             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1180         }
1181
1182         public void Quit()
1183         {
1184             NDalicPINVOKE.Application_Quit(swigCPtr);
1185             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1186         }
1187
1188         internal bool AddIdle(SWIGTYPE_p_Dali__CallbackBase callback)
1189         {
1190             bool ret = NDalicPINVOKE.Application_AddIdle(swigCPtr, SWIGTYPE_p_Dali__CallbackBase.getCPtr(callback));
1191             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1192             return ret;
1193         }
1194
1195         public Window GetWindow()
1196         {
1197             Window ret = new Window(NDalicPINVOKE.Application_GetWindow(swigCPtr), true);
1198             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1199             return ret;
1200         }
1201
1202         public void ReplaceWindow(Rectangle windowPosition, string name)
1203         {
1204             NDalicPINVOKE.Application_ReplaceWindow(swigCPtr, Rectangle.getCPtr(windowPosition), name);
1205             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1206         }
1207
1208         public static string GetResourcePath()
1209         {
1210             string ret = NDalicPINVOKE.Application_GetResourcePath();
1211             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1212             return ret;
1213         }
1214
1215         internal void SetViewMode(ViewMode viewMode)
1216         {
1217             NDalicPINVOKE.Application_SetViewMode(swigCPtr, (int)viewMode);
1218             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1219         }
1220
1221         internal ViewMode GetViewMode()
1222         {
1223             ViewMode ret = (ViewMode)NDalicPINVOKE.Application_GetViewMode(swigCPtr);
1224             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1225             return ret;
1226         }
1227
1228         public void SetStereoBase(float stereoBase)
1229         {
1230             NDalicPINVOKE.Application_SetStereoBase(swigCPtr, stereoBase);
1231             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1232         }
1233
1234         public float GetStereoBase()
1235         {
1236             float ret = NDalicPINVOKE.Application_GetStereoBase(swigCPtr);
1237             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1238             return ret;
1239         }
1240
1241         public string GetLanguage()
1242         {
1243             string ret = NDalicPINVOKE.Application_GetLanguage(swigCPtr);
1244             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1245             return ret;
1246         }
1247
1248         public string GetRegion()
1249         {
1250             string ret = NDalicPINVOKE.Application_GetRegion(swigCPtr);
1251             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1252             return ret;
1253         }
1254
1255
1256         internal ApplicationSignal InitSignal()
1257         {
1258             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_InitSignal(swigCPtr), false);
1259             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1260             return ret;
1261         }
1262
1263         internal ApplicationSignal TerminateSignal()
1264         {
1265             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_TerminateSignal(swigCPtr), false);
1266             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1267             return ret;
1268         }
1269
1270         internal ApplicationSignal PauseSignal()
1271         {
1272             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_PauseSignal(swigCPtr), false);
1273             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1274             return ret;
1275         }
1276
1277         internal ApplicationSignal ResumeSignal()
1278         {
1279             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_ResumeSignal(swigCPtr), false);
1280             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1281             return ret;
1282         }
1283
1284         internal ApplicationSignal ResetSignal()
1285         {
1286             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_ResetSignal(swigCPtr), false);
1287             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1288             return ret;
1289         }
1290
1291         internal ApplicationSignal ResizeSignal()
1292         {
1293             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_ResizeSignal(swigCPtr), false);
1294             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1295             return ret;
1296         }
1297
1298         internal ApplicationControlSignal AppControlSignal()
1299         {
1300             ApplicationControlSignal ret = new ApplicationControlSignal(NDalicPINVOKE.Application_AppControlSignal(swigCPtr), false);
1301             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1302             return ret;
1303         }
1304
1305         internal ApplicationSignal LanguageChangedSignal()
1306         {
1307             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_LanguageChangedSignal(swigCPtr), false);
1308             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1309             return ret;
1310         }
1311
1312         internal ApplicationSignal RegionChangedSignal()
1313         {
1314             ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_RegionChangedSignal(swigCPtr), false);
1315             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1316             return ret;
1317         }
1318
1319         internal LowBatterySignalType BatteryLowSignal()
1320         {
1321             LowBatterySignalType ret = new LowBatterySignalType(NDalicPINVOKE.Application_LowBatterySignal(swigCPtr), false);
1322             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1323             return ret;
1324         }
1325
1326         internal LowMemorySignalType MemoryLowSignal()
1327         {
1328             LowMemorySignalType ret = new LowMemorySignalType(NDalicPINVOKE.Application_LowMemorySignal(swigCPtr), false);
1329             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1330             return ret;
1331         }
1332
1333         /// <since_tizen> 3 </since_tizen>
1334         public enum WindowMode
1335         {
1336             Opaque = 0,
1337             Transparent = 1
1338         }
1339
1340     }
1341
1342 }