2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Collections.Generic;
19 using System.Collections.ObjectModel;
20 using System.ComponentModel;
21 using System.Diagnostics;
22 using System.Runtime.InteropServices;
23 using Tizen.NUI.Binding;
28 * @brief Event arguments that passed via NUIApplicationInit signal
30 internal class NUIApplicationInitEventArgs : EventArgs
32 private Application application;
35 * @brief Application - is the application that is being initialized
37 public Application Application
51 * @brief Event arguments that passed via NUIApplicationTerminate signal
53 internal class NUIApplicationTerminatingEventArgs : EventArgs
55 private Application application;
57 * @brief Application - is the application that is being Terminated
59 public Application Application
73 * @brief Event arguments that passed via NUIApplicationPause signal
75 internal class NUIApplicationPausedEventArgs : EventArgs
77 private Application application;
79 * @brief Application - is the application that is being Paused
81 public Application Application
95 * @brief Event arguments that passed via NUIApplicationResume signal
97 internal class NUIApplicationResumedEventArgs : EventArgs
99 private Application application;
101 * @brief Application - is the application that is being Resumed
103 public Application Application
117 * @brief Event arguments that passed via NUIApplicationReset signal
119 internal class NUIApplicationResetEventArgs : EventArgs
121 private Application application;
123 * @brief Application - is the application that is being Reset
125 public Application Application
139 * @brief Event arguments that passed via NUIApplicationLanguageChanged signal
141 internal class NUIApplicationLanguageChangedEventArgs : EventArgs
143 private Application application;
145 * @brief Application - is the application that is being affected with Device's language change
147 public Application Application
161 * @brief Event arguments that passed via NUIApplicationRegionChanged signal
163 internal class NUIApplicationRegionChangedEventArgs : EventArgs
165 private Application application;
167 * @brief Application - is the application that is being affected with Device's region change
169 public Application Application
183 * @brief Event arguments that passed via NUIApplicationBatteryLow signal
185 internal class NUIApplicationBatteryLowEventArgs : EventArgs
187 private Application.BatteryStatus status;
189 * @brief Application - is the application that is being affected when the battery level of the device is low
191 public Application.BatteryStatus BatteryStatus
205 * @brief Event arguments that passed via NUIApplicationMemoryLow signal
207 internal class NUIApplicationMemoryLowEventArgs : EventArgs
209 private Application.MemoryStatus status;
211 * @brief Application - is the application that is being affected when the memory level of the device is low
213 public Application.MemoryStatus MemoryStatus
227 * @brief Event arguments that passed via NUIApplicationAppControl signal
229 internal class NUIApplicationAppControlEventArgs : EventArgs
231 private Application application;
232 private IntPtr voidp;
234 * @brief Application - is the application that is receiving the launch request from another application
236 public Application Application
248 * @brief VoidP - contains the information about why the application is launched
264 /// A class to get resources in current application.
266 public sealed class GetResourcesProvider
269 /// Get resources in current application.
271 static public IResourcesProvider Get()
273 return Tizen.NUI.Application.Current;
277 internal class Application : BaseHandle, IResourcesProvider, IElementConfiguration<Application>
279 static Application s_current;
281 ReadOnlyCollection<Element> logicalChildren;
283 [EditorBrowsable(EditorBrowsableState.Never)]
284 public static void SetCurrentApplication(Application value) => Current = value;
286 public static Application Current
288 get { return s_current; }
291 if (s_current == value)
297 internal override ReadOnlyCollection<Element> LogicalChildrenInternal
299 get { return logicalChildren ?? (logicalChildren = new ReadOnlyCollection<Element>(InternalChildren)); }
302 internal IResourceDictionary SystemResources { get; }
304 ObservableCollection<Element> InternalChildren { get; } = new ObservableCollection<Element>();
306 ResourceDictionary resources;
307 public bool IsResourcesCreated => resources != null;
309 public delegate void resChangeCb(object sender, ResourcesChangedEventArgs e);
311 internal event EventHandler<ResourcesChangedEventArgs> XamlResourceChanged;
313 internal override void OnResourcesChanged(object sender, ResourcesChangedEventArgs e)
315 base.OnResourcesChanged(sender, e);
316 XamlResourceChanged?.Invoke(sender, e);
319 public ResourceDictionary XamlResources
323 if (resources == null)
325 resources = new ResourceDictionary();
326 int hashCode = resources.GetHashCode();
327 ((IResourceDictionary)resources).ValuesChanged += OnResourcesChanged;
333 if (resources == value)
335 OnPropertyChanging();
337 if (resources != null)
338 ((IResourceDictionary)resources).ValuesChanged -= OnResourcesChanged;
340 OnResourcesChanged(value);
341 if (resources != null)
342 ((IResourceDictionary)resources).ValuesChanged += OnResourcesChanged;
348 protected override void OnParentSet()
350 throw new InvalidOperationException("Setting a Parent on Application is invalid.");
353 [EditorBrowsable(EditorBrowsableState.Never)]
354 public static bool IsApplicationOrNull(Element element)
356 return element == null || element is Application;
359 internal override void OnParentResourcesChanged(IEnumerable<KeyValuePair<string, object>> values)
361 if (!((IResourcesProvider)this).IsResourcesCreated || XamlResources.Count == 0)
363 base.OnParentResourcesChanged(values);
367 var innerKeys = new HashSet<string>();
368 var changedResources = new List<KeyValuePair<string, object>>();
369 foreach (KeyValuePair<string, object> c in XamlResources)
370 innerKeys.Add(c.Key);
371 foreach (KeyValuePair<string, object> value in values)
373 if (innerKeys.Add(value.Key))
374 changedResources.Add(value);
376 OnResourcesChanged(changedResources);
379 internal Application(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
381 SetCurrentApplication(this);
385 protected override void Dispose(DisposeTypes type)
392 //Release your own unmanaged resources here.
393 //You should not access any managed member here except static instance.
394 //because the execution order of Finalizes is non-deterministic.
395 if (applicationInitEventCallbackDelegate != null)
397 initSignal?.Disconnect(applicationInitEventCallbackDelegate);
398 initSignal?.Dispose();
402 if (applicationTerminateEventCallbackDelegate != null)
404 terminateSignal?.Disconnect(applicationTerminateEventCallbackDelegate);
405 terminateSignal?.Dispose();
406 terminateSignal = null;
409 if (applicationPauseEventCallbackDelegate != null)
411 pauseSignal?.Disconnect(applicationPauseEventCallbackDelegate);
412 pauseSignal?.Dispose();
416 if (applicationResumeEventCallbackDelegate != null)
418 resumeSignal?.Disconnect(applicationResumeEventCallbackDelegate);
419 resumeSignal?.Dispose();
423 if (applicationResetEventCallbackDelegate != null)
425 resetSignal?.Disconnect(applicationResetEventCallbackDelegate);
426 resetSignal?.Dispose();
430 if (applicationLanguageChangedEventCallbackDelegate != null)
432 languageChangedSignal?.Disconnect(applicationLanguageChangedEventCallbackDelegate);
433 languageChangedSignal?.Dispose();
434 languageChangedSignal = null;
437 if (applicationRegionChangedEventCallbackDelegate != null)
439 regionChangedSignal?.Disconnect(applicationRegionChangedEventCallbackDelegate);
440 regionChangedSignal?.Dispose();
441 regionChangedSignal = null;
444 if (applicationBatteryLowEventCallbackDelegate != null)
446 batteryLowSignal?.Disconnect(applicationBatteryLowEventCallbackDelegate);
447 batteryLowSignal?.Dispose();
448 batteryLowSignal = null;
451 if (applicationMemoryLowEventCallbackDelegate != null)
453 memoryLowSignal?.Disconnect(applicationMemoryLowEventCallbackDelegate);
454 memoryLowSignal?.Dispose();
455 memoryLowSignal = null;
458 if (applicationAppControlEventCallbackDelegate != null)
460 appControlSignal?.Disconnect(applicationAppControlEventCallbackDelegate);
461 appControlSignal?.Dispose();
462 appControlSignal = null;
470 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
472 Interop.Application.DeleteApplication(swigCPtr);
475 public enum BatteryStatus
482 public enum MemoryStatus
489 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
490 private delegate void NUIApplicationInitEventCallbackDelegate(IntPtr application);
491 private DaliEventHandler<object, NUIApplicationInitEventArgs> applicationInitEventHandler;
492 private NUIApplicationInitEventCallbackDelegate applicationInitEventCallbackDelegate;
493 private ApplicationSignal initSignal;
495 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
496 private delegate void NUIApplicationTerminateEventCallbackDelegate(IntPtr application);
497 private DaliEventHandler<object, NUIApplicationTerminatingEventArgs> applicationTerminateEventHandler;
498 private NUIApplicationTerminateEventCallbackDelegate applicationTerminateEventCallbackDelegate;
499 private ApplicationSignal terminateSignal;
501 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
502 private delegate void NUIApplicationPauseEventCallbackDelegate(IntPtr application);
503 private DaliEventHandler<object, NUIApplicationPausedEventArgs> applicationPauseEventHandler;
504 private NUIApplicationPauseEventCallbackDelegate applicationPauseEventCallbackDelegate;
505 private ApplicationSignal pauseSignal;
507 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
508 private delegate void NUIApplicationResumeEventCallbackDelegate(IntPtr application);
509 private DaliEventHandler<object, NUIApplicationResumedEventArgs> applicationResumeEventHandler;
510 private NUIApplicationResumeEventCallbackDelegate applicationResumeEventCallbackDelegate;
511 private ApplicationSignal resumeSignal;
513 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
514 private delegate void NUIApplicationResetEventCallbackDelegate(IntPtr application);
515 private DaliEventHandler<object, NUIApplicationResetEventArgs> applicationResetEventHandler;
516 private NUIApplicationResetEventCallbackDelegate applicationResetEventCallbackDelegate;
517 private ApplicationSignal resetSignal;
519 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
520 private delegate void NUIApplicationLanguageChangedEventCallbackDelegate(IntPtr application);
521 private DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> applicationLanguageChangedEventHandler;
522 private NUIApplicationLanguageChangedEventCallbackDelegate applicationLanguageChangedEventCallbackDelegate;
523 private ApplicationSignal languageChangedSignal;
526 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
527 private delegate void NUIApplicationRegionChangedEventCallbackDelegate(IntPtr application);
528 private DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> applicationRegionChangedEventHandler;
529 private NUIApplicationRegionChangedEventCallbackDelegate applicationRegionChangedEventCallbackDelegate;
530 private ApplicationSignal regionChangedSignal;
532 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
533 private delegate void NUIApplicationBatteryLowEventCallbackDelegate(BatteryStatus status);
534 private DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> applicationBatteryLowEventHandler;
535 private NUIApplicationBatteryLowEventCallbackDelegate applicationBatteryLowEventCallbackDelegate;
536 private LowBatterySignalType batteryLowSignal;
538 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
539 private delegate void NUIApplicationMemoryLowEventCallbackDelegate(MemoryStatus status);
540 private DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> applicationMemoryLowEventHandler;
541 private NUIApplicationMemoryLowEventCallbackDelegate applicationMemoryLowEventCallbackDelegate;
542 private LowMemorySignalType memoryLowSignal;
544 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
545 private delegate void NUIApplicationAppControlEventCallbackDelegate(IntPtr application, IntPtr voidp);
546 private DaliEventHandler<object, NUIApplicationAppControlEventArgs> applicationAppControlEventHandler;
547 private NUIApplicationAppControlEventCallbackDelegate applicationAppControlEventCallbackDelegate;
548 private ApplicationControlSignal appControlSignal;
550 private Window window;
553 * @brief Event for Initialized signal which can be used to subscribe/unsubscribe the event handler
554 * provided by the user. Initialized signal is emitted when application is initialized
556 public event DaliEventHandler<object, NUIApplicationInitEventArgs> Initialized
560 // Restricted to only one listener
561 if (applicationInitEventHandler == null)
563 applicationInitEventHandler += value;
564 applicationInitEventCallbackDelegate = new NUIApplicationInitEventCallbackDelegate(OnApplicationInit);
565 initSignal = this.InitSignal();
566 initSignal?.Connect(applicationInitEventCallbackDelegate);
572 if (applicationInitEventHandler != null)
574 initSignal?.Disconnect(applicationInitEventCallbackDelegate);
575 initSignal?.Dispose();
579 applicationInitEventHandler -= value;
583 // Callback for Application InitSignal
584 private void OnApplicationInit(IntPtr data)
586 // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread.
587 DisposeQueue.Instance.Initialize();
588 Window.Instance = GetWindow();
590 // Notify that the window is displayed to the app core.
591 if (NUIApplication.IsPreload)
593 Window.Instance.Show();
596 if (applicationInitEventHandler != null)
598 NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs();
599 e.Application = this;
600 applicationInitEventHandler.Invoke(this, e);
606 * @brief Event for Terminated signal which can be used to subscribe/unsubscribe the event handler
607 * provided by the user. Terminated signal is emitted when application is terminating
609 public event DaliEventHandler<object, NUIApplicationTerminatingEventArgs> Terminating
613 // Restricted to only one listener
614 if (applicationTerminateEventHandler == null)
616 applicationTerminateEventHandler += value;
618 applicationTerminateEventCallbackDelegate = new NUIApplicationTerminateEventCallbackDelegate(OnNUIApplicationTerminate);
619 terminateSignal = this.TerminateSignal();
620 terminateSignal?.Connect(applicationTerminateEventCallbackDelegate);
626 if (applicationTerminateEventHandler != null)
628 terminateSignal?.Disconnect(applicationTerminateEventCallbackDelegate);
629 terminateSignal?.Dispose();
630 terminateSignal = null;
633 applicationTerminateEventHandler -= value;
637 // Callback for Application TerminateSignal
638 private void OnNUIApplicationTerminate(IntPtr data)
640 if (applicationTerminateEventHandler != null)
642 NUIApplicationTerminatingEventArgs e = new NUIApplicationTerminatingEventArgs();
643 e.Application = this;
644 applicationTerminateEventHandler.Invoke(this, e);
647 List<Window> windows = GetWindowList();
648 foreach (Window window in windows)
650 window?.DisconnectNativeSignals();
655 * @brief Event for Paused signal which can be used to subscribe/unsubscribe the event handler
656 * provided by the user. Paused signal is emitted when application is paused
658 public event DaliEventHandler<object, NUIApplicationPausedEventArgs> Paused
662 // Restricted to only one listener
663 if (applicationPauseEventHandler == null)
665 applicationPauseEventHandler += value;
667 applicationPauseEventCallbackDelegate = new NUIApplicationPauseEventCallbackDelegate(OnNUIApplicationPause);
668 pauseSignal = this.PauseSignal();
669 pauseSignal?.Connect(applicationPauseEventCallbackDelegate);
675 if (applicationPauseEventHandler != null)
677 pauseSignal?.Disconnect(applicationPauseEventCallbackDelegate);
678 pauseSignal?.Dispose();
682 applicationPauseEventHandler -= value;
686 // Callback for Application PauseSignal
687 private void OnNUIApplicationPause(IntPtr data)
689 if (applicationPauseEventHandler != null)
691 NUIApplicationPausedEventArgs e = new NUIApplicationPausedEventArgs();
692 e.Application = this;
693 applicationPauseEventHandler.Invoke(this, e);
698 * @brief Event for Resumed signal which can be used to subscribe/unsubscribe the event handler
699 * provided by the user. Resumed signal is emitted when application is resumed
701 public event DaliEventHandler<object, NUIApplicationResumedEventArgs> Resumed
705 // Restricted to only one listener
706 if (applicationResumeEventHandler == null)
708 applicationResumeEventHandler += value;
710 applicationResumeEventCallbackDelegate = new NUIApplicationResumeEventCallbackDelegate(OnNUIApplicationResume);
711 resumeSignal = this.ResumeSignal();
712 resumeSignal?.Connect(applicationResumeEventCallbackDelegate);
718 if (applicationResumeEventHandler != null)
720 resumeSignal?.Disconnect(applicationResumeEventCallbackDelegate);
721 resumeSignal?.Dispose();
725 applicationResumeEventHandler -= value;
729 // Callback for Application ResumeSignal
730 private void OnNUIApplicationResume(IntPtr data)
732 if (applicationResumeEventHandler != null)
734 NUIApplicationResumedEventArgs e = new NUIApplicationResumedEventArgs();
735 e.Application = this;
736 applicationResumeEventHandler.Invoke(this, e);
741 * @brief Event for Reset signal which can be used to subscribe/unsubscribe the event handler
742 * provided by the user. Reset signal is emitted when application is reset
744 public new event DaliEventHandler<object, NUIApplicationResetEventArgs> Reset
748 // Restricted to only one listener
749 if (applicationResetEventHandler == null)
751 applicationResetEventHandler += value;
753 applicationResetEventCallbackDelegate = new NUIApplicationResetEventCallbackDelegate(OnNUIApplicationReset);
754 resetSignal = this.ResetSignal();
755 resetSignal?.Connect(applicationResetEventCallbackDelegate);
761 if (applicationResetEventHandler != null)
763 resetSignal?.Disconnect(applicationResetEventCallbackDelegate);
764 resetSignal?.Dispose();
768 applicationResetEventHandler -= value;
772 // Callback for Application ResetSignal
773 private void OnNUIApplicationReset(IntPtr data)
775 if (applicationResetEventHandler != null)
777 NUIApplicationResetEventArgs e = new NUIApplicationResetEventArgs();
778 e.Application = this;
779 applicationResetEventHandler.Invoke(this, e);
784 * @brief Event for LanguageChanged signal which can be used to subscribe/unsubscribe the event handler
785 * provided by the user. LanguageChanged signal is emitted when the region of the device is changed.
787 public event DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> LanguageChanged
791 // Restricted to only one listener
792 if (applicationLanguageChangedEventHandler == null)
794 applicationLanguageChangedEventHandler += value;
796 applicationLanguageChangedEventCallbackDelegate = new NUIApplicationLanguageChangedEventCallbackDelegate(OnNUIApplicationLanguageChanged);
797 languageChangedSignal = this.LanguageChangedSignal();
798 languageChangedSignal?.Connect(applicationLanguageChangedEventCallbackDelegate);
804 if (applicationLanguageChangedEventHandler != null)
806 languageChangedSignal?.Disconnect(applicationLanguageChangedEventCallbackDelegate);
807 languageChangedSignal?.Dispose();
808 languageChangedSignal = null;
811 applicationLanguageChangedEventHandler -= value;
815 // Callback for Application LanguageChangedSignal
816 private void OnNUIApplicationLanguageChanged(IntPtr data)
818 if (applicationLanguageChangedEventHandler != null)
820 NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs();
821 e.Application = this;
822 applicationLanguageChangedEventHandler.Invoke(this, e);
827 * @brief Event for RegionChanged signal which can be used to subscribe/unsubscribe the event handler
828 * provided by the user. RegionChanged signal is emitted when the region of the device is changed.
830 public event DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> RegionChanged
834 // Restricted to only one listener
835 if (applicationRegionChangedEventHandler == null)
837 applicationRegionChangedEventHandler += value;
839 applicationRegionChangedEventCallbackDelegate = new NUIApplicationRegionChangedEventCallbackDelegate(OnNUIApplicationRegionChanged);
840 regionChangedSignal = this.RegionChangedSignal();
841 regionChangedSignal?.Connect(applicationRegionChangedEventCallbackDelegate);
847 if (applicationRegionChangedEventHandler != null)
849 regionChangedSignal?.Disconnect(applicationRegionChangedEventCallbackDelegate);
850 regionChangedSignal?.Dispose();
851 regionChangedSignal = null;
854 applicationRegionChangedEventHandler -= value;
858 // Callback for Application RegionChangedSignal
859 private void OnNUIApplicationRegionChanged(IntPtr data)
861 if (applicationRegionChangedEventHandler != null)
863 NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs();
864 e.Application = this;
865 applicationRegionChangedEventHandler.Invoke(this, e);
870 * @brief Event for BatteryLow signal which can be used to subscribe/unsubscribe the event handler
871 * provided by the user. BatteryLow signal is emitted when the battery level of the device is low.
873 public event DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> BatteryLow
877 // Restricted to only one listener
878 if (applicationBatteryLowEventHandler == null)
880 applicationBatteryLowEventHandler += value;
882 applicationBatteryLowEventCallbackDelegate = new NUIApplicationBatteryLowEventCallbackDelegate(OnNUIApplicationBatteryLow);
883 batteryLowSignal = this.BatteryLowSignal();
884 batteryLowSignal?.Connect(applicationBatteryLowEventCallbackDelegate);
890 if (applicationBatteryLowEventHandler != null)
892 batteryLowSignal?.Disconnect(applicationBatteryLowEventCallbackDelegate);
893 batteryLowSignal?.Dispose();
894 batteryLowSignal = null;
897 applicationBatteryLowEventHandler -= value;
901 // Callback for Application BatteryLowSignal
902 private void OnNUIApplicationBatteryLow(BatteryStatus status)
904 NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
906 // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
907 e.BatteryStatus = status;
908 applicationBatteryLowEventHandler?.Invoke(this, e);
912 * @brief Event for MemoryLow signal which can be used to subscribe/unsubscribe the event handler
913 * provided by the user. MemoryLow signal is emitted when the memory level of the device is low.
915 public event DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> MemoryLow
919 // Restricted to only one listener
920 if (applicationMemoryLowEventHandler == null)
922 applicationMemoryLowEventHandler += value;
924 applicationMemoryLowEventCallbackDelegate = new NUIApplicationMemoryLowEventCallbackDelegate(OnNUIApplicationMemoryLow);
925 memoryLowSignal = this.MemoryLowSignal();
926 memoryLowSignal?.Connect(applicationMemoryLowEventCallbackDelegate);
932 if (applicationMemoryLowEventHandler != null)
934 memoryLowSignal?.Disconnect(applicationMemoryLowEventCallbackDelegate);
935 memoryLowSignal?.Dispose();
936 memoryLowSignal = null;
939 applicationMemoryLowEventHandler -= value;
943 // Callback for Application MemoryLowSignal
944 private void OnNUIApplicationMemoryLow(MemoryStatus status)
946 NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
948 // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
949 e.MemoryStatus = status;
950 applicationMemoryLowEventHandler?.Invoke(this, e);
954 * @brief Event for AppControl signal which can be used to subscribe/unsubscribe the event handler
955 * provided by the user. AppControl signal is emitted when another application sends a launch request to the application.
957 public event DaliEventHandler<object, NUIApplicationAppControlEventArgs> AppControl
961 // Restricted to only one listener
962 if (applicationAppControlEventHandler == null)
964 applicationAppControlEventHandler += value;
966 applicationAppControlEventCallbackDelegate = new NUIApplicationAppControlEventCallbackDelegate(OnNUIApplicationAppControl);
967 appControlSignal = this.AppControlSignal();
968 appControlSignal?.Connect(applicationAppControlEventCallbackDelegate);
974 if (applicationAppControlEventHandler != null)
976 appControlSignal?.Disconnect(applicationAppControlEventCallbackDelegate);
977 appControlSignal?.Dispose();
978 appControlSignal = null;
981 applicationAppControlEventHandler -= value;
985 // Callback for Application AppControlSignal
986 private void OnNUIApplicationAppControl(IntPtr application, IntPtr voidp)
988 if (applicationAppControlEventHandler != null)
990 NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs();
992 e.Application = this;
993 applicationAppControlEventHandler.Invoke(this, e);
997 protected static Application instance; // singleton
999 public static Application Instance
1007 public static Application GetApplicationFromPtr(global::System.IntPtr cPtr)
1009 if (cPtr == global::System.IntPtr.Zero)
1014 Application ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Application;
1015 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1019 public static Application NewApplication()
1021 return NewApplication("", NUIApplication.WindowMode.Opaque);
1024 public static Application NewApplication(string stylesheet)
1026 return NewApplication(stylesheet, NUIApplication.WindowMode.Opaque);
1029 public static Application NewApplication(string stylesheet, NUIApplication.WindowMode windowMode)
1031 // register all Views with the type registry, so that can be created / styled via JSON
1032 //ViewRegistryHelper.Initialize(); //moved to Application side.
1033 if (instance != null)
1038 Application ret = New(1, stylesheet, windowMode);
1039 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1041 // set the singleton
1046 public static Application NewApplication(string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize)
1048 if (instance != null)
1052 Application ret = New(1, stylesheet, windowMode, positionSize);
1053 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1055 // set the singleton
1060 public static Application NewApplication(string[] args, string stylesheet, NUIApplication.WindowMode windowMode)
1062 if (instance != null)
1066 Application ret = New(args, stylesheet, windowMode);
1067 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1069 // set the singleton
1074 public static Application NewApplication(string[] args, string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize)
1076 if (instance != null)
1080 Application ret = New(args, stylesheet, windowMode, positionSize);
1081 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1083 // set the singleton
1088 public static Application NewApplication(string stylesheet, NUIApplication.WindowMode windowMode, WindowType type)
1090 if (instance != null)
1094 Application ret = New(1, stylesheet, windowMode, type);
1095 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1102 /// Ensures that the function passed in is called from the main loop when it is idle.
1104 /// <param name="func">The function to call</param>
1105 /// <returns>true if added successfully, false otherwise</returns>
1107 /// It will return false when one of the following conditions is met.
1108 /// 1) the <see cref="Window"/> is hidden.
1109 /// 2) the <see cref="Window"/> is iconified.
1111 public bool AddIdle(System.Delegate func)
1113 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
1114 System.IntPtr ip2 = Interop.Application.MakeCallback(new System.Runtime.InteropServices.HandleRef(this, ip));
1116 bool ret = Interop.Application.AddIdle(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip2));
1118 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1123 * Outer::outer_method(int)
1125 public static Application New()
1127 Application ret = new Application(Interop.Application.New(), true);
1128 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1132 public static Application New(int argc)
1134 Application ret = new Application(Interop.Application.New(argc), true);
1135 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1139 public static Application New(int argc, string stylesheet)
1141 Application ret = new Application(Interop.Application.New(argc, stylesheet), true);
1142 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1146 public static Application New(int argc, string stylesheet, NUIApplication.WindowMode windowMode)
1148 Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode), true);
1149 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1154 public static Application New(string[] args, string stylesheet, NUIApplication.WindowMode windowMode)
1156 Application ret = null;
1158 string argvStr = "";
1162 argvStr = string.Join(" ", args);
1164 catch (Exception exception)
1166 Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, message : " + exception.Message);
1167 Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber());
1168 Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace);
1172 ret = new Application(NDalicPINVOKE.ApplicationNewManual4(argc, argvStr, stylesheet, (int)windowMode), true);
1173 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1178 public static Application New(int argc, string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize)
1180 Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1185 public static Application New(string[] args, string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize)
1187 Application ret = null;
1189 string argvStr = "";
1193 argvStr = string.Join(" ", args);
1195 catch (Exception exception)
1197 Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, message : " + exception.Message);
1198 Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber());
1199 Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace);
1203 ret = new Application(NDalicPINVOKE.ApplicationNewWithWindowSizePosition(argc, argvStr, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1204 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1209 public static Application New(int argc, string stylesheet, NUIApplication.WindowMode windowMode, WindowType type)
1211 // It will be removed until dali APIs are prepared.
1212 Rectangle initRectangle = new Rectangle(0, 0, 0, 0);
1214 Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(initRectangle), (int)type), true);
1215 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1219 public Application() : this(Interop.Application.NewApplication(), true)
1221 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1224 public Application(Application application) : this(Interop.Application.NewApplication(Application.getCPtr(application)), true)
1226 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1229 public Application Assign(Application application)
1231 Application ret = new Application(Interop.Application.Assign(SwigCPtr, Application.getCPtr(application)), false);
1232 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1236 public void MainLoop()
1238 NDalicPINVOKE.ApplicationMainLoop(SwigCPtr);
1239 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1244 Interop.Application.Lower(SwigCPtr);
1245 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1250 Interop.Application.Quit(SwigCPtr);
1251 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1254 internal bool AddIdle(SWIGTYPE_p_Dali__CallbackBase callback)
1256 bool ret = Interop.Application.AddIdle(SwigCPtr, SWIGTYPE_p_Dali__CallbackBase.getCPtr(callback));
1257 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1261 public Window GetWindow()
1268 window = (Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindow(SwigCPtr)) as Window) ?? new Window(Interop.Application.GetWindow(SwigCPtr), true);
1270 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1274 public static string GetResourcePath()
1276 string ret = Interop.Application.GetResourcePath();
1277 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1281 public string GetLanguage()
1283 string ret = Interop.Application.GetLanguage(SwigCPtr);
1284 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1288 public string GetRegion()
1290 string ret = Interop.Application.GetRegion(SwigCPtr);
1291 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1295 [EditorBrowsable(EditorBrowsableState.Never)]
1296 public static List<Window> GetWindowList()
1298 uint ListSize = Interop.Application.GetWindowsListSize();
1299 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1301 List<Window> WindowList = new List<Window>();
1302 for (uint i = 0; i < ListSize; ++i)
1304 Window currWin = Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindowsFromList(i)) as Window;
1305 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1306 if (currWin != null)
1308 WindowList.Add(currWin);
1314 internal ApplicationSignal InitSignal()
1316 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationInitSignal(SwigCPtr), false);
1317 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1321 internal ApplicationSignal TerminateSignal()
1323 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationTerminateSignal(SwigCPtr), false);
1324 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1328 internal ApplicationSignal PauseSignal()
1330 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationPauseSignal(SwigCPtr), false);
1331 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1335 internal ApplicationSignal ResumeSignal()
1337 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationResumeSignal(SwigCPtr), false);
1338 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1342 internal ApplicationSignal ResetSignal()
1344 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationResetSignal(SwigCPtr), false);
1345 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1349 internal ApplicationControlSignal AppControlSignal()
1351 ApplicationControlSignal ret = new ApplicationControlSignal(NDalicPINVOKE.ApplicationAppControlSignal(SwigCPtr), false);
1352 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1356 internal ApplicationSignal LanguageChangedSignal()
1358 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationLanguageChangedSignal(SwigCPtr), false);
1359 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1363 internal ApplicationSignal RegionChangedSignal()
1365 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationRegionChangedSignal(SwigCPtr), false);
1366 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1370 internal LowBatterySignalType BatteryLowSignal()
1372 LowBatterySignalType ret = new LowBatterySignalType(NDalicPINVOKE.ApplicationLowBatterySignal(SwigCPtr), false);
1373 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1377 internal LowMemorySignalType MemoryLowSignal()
1379 LowMemorySignalType ret = new LowMemorySignalType(NDalicPINVOKE.ApplicationLowMemorySignal(SwigCPtr), false);
1380 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();