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