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