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