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