2 * Copyright(c) 2018 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 System.Threading;
24 using System.Threading.Tasks;
25 using Tizen.NUI.Binding;
26 using Tizen.NUI.Binding.Internals;
31 * @brief Event arguments that passed via NUIApplicationInit signal
34 internal class NUIApplicationInitEventArgs : EventArgs
36 private Application _application;
39 * @brief Application - is the application that is being initialized
42 public Application Application
56 * @brief Event arguments that passed via NUIApplicationTerminate signal
59 internal class NUIApplicationTerminatingEventArgs : EventArgs
61 private Application _application;
63 * @brief Application - is the application that is being Terminated
66 public Application Application
80 * @brief Event arguments that passed via NUIApplicationPause signal
83 internal class NUIApplicationPausedEventArgs : EventArgs
85 private Application _application;
87 * @brief Application - is the application that is being Paused
90 public Application Application
104 * @brief Event arguments that passed via NUIApplicationResume signal
107 internal class NUIApplicationResumedEventArgs : EventArgs
109 private Application _application;
111 * @brief Application - is the application that is being Resumed
114 public Application Application
122 _application = value;
128 * @brief Event arguments that passed via NUIApplicationReset signal
131 internal class NUIApplicationResetEventArgs : EventArgs
133 private Application _application;
135 * @brief Application - is the application that is being Reset
138 public Application Application
146 _application = value;
152 * @brief Event arguments that passed via NUIApplicationLanguageChanged signal
155 internal class NUIApplicationLanguageChangedEventArgs : EventArgs
157 private Application _application;
159 * @brief Application - is the application that is being affected with Device's language change
162 public Application Application
170 _application = value;
176 * @brief Event arguments that passed via NUIApplicationRegionChanged signal
179 internal class NUIApplicationRegionChangedEventArgs : EventArgs
181 private Application _application;
183 * @brief Application - is the application that is being affected with Device's region change
186 public Application Application
194 _application = value;
200 * @brief Event arguments that passed via NUIApplicationBatteryLow signal
203 internal class NUIApplicationBatteryLowEventArgs : EventArgs
205 private Application.BatteryStatus _status;
207 * @brief Application - is the application that is being affected when the battery level of the device is low
210 public Application.BatteryStatus BatteryStatus
224 * @brief Event arguments that passed via NUIApplicationMemoryLow signal
227 internal class NUIApplicationMemoryLowEventArgs : EventArgs
229 private Application.MemoryStatus _status;
231 * @brief Application - is the application that is being affected when the memory level of the device is low
234 public Application.MemoryStatus MemoryStatus
248 * @brief Event arguments that passed via NUIApplicationAppControl signal
251 internal class NUIApplicationAppControlEventArgs : EventArgs
253 private Application _application;
254 private IntPtr _voidp;
256 * @brief Application - is the application that is receiving the launch request from another application
259 public Application Application
267 _application = value;
271 * @brief VoidP - contains the information about why the application is launched
288 /// A class to get resources in current application.
290 public sealed class GetResourcesProvider
293 /// Get resources in current application.
295 static public IResourcesProvider Get()
297 return Tizen.NUI.Application.Current;
301 internal class Application : BaseHandle, IResourcesProvider, IElementConfiguration<Application>
304 static Application s_current;
306 ReadOnlyCollection<Element> _logicalChildren;
308 [EditorBrowsable(EditorBrowsableState.Never)]
309 public static void SetCurrentApplication(Application value) => Current = value;
311 public static Application Current
313 get { return s_current; }
316 if (s_current == value)
319 s_current = null; //Allow to reset current for unittesting
324 internal override ReadOnlyCollection<Element> LogicalChildrenInternal
326 get { return _logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(InternalChildren)); }
329 internal IResourceDictionary SystemResources { get; }
331 ObservableCollection<Element> InternalChildren { get; } = new ObservableCollection<Element>();
333 ResourceDictionary _resources;
334 public bool IsResourcesCreated => _resources != null;
336 public delegate void resChangeCb(object sender, ResourcesChangedEventArgs e);
338 static private Dictionary<object, Dictionary<resChangeCb, int>> resourceChangeCallbackDict = new Dictionary<object, Dictionary<resChangeCb, int>>();
339 static public void AddResourceChangedCallback(object handle, resChangeCb cb)
341 Dictionary<resChangeCb, int> cbDict;
342 resourceChangeCallbackDict.TryGetValue(handle, out cbDict);
346 cbDict = new Dictionary<resChangeCb, int>();
347 resourceChangeCallbackDict.Add(handle, cbDict);
350 if (false == cbDict.ContainsKey(cb))
356 internal override void OnResourcesChanged(object sender, ResourcesChangedEventArgs e)
358 base.OnResourcesChanged(sender, e);
360 foreach (KeyValuePair<object, Dictionary<resChangeCb, int>> resourcePair in resourceChangeCallbackDict)
362 foreach (KeyValuePair<resChangeCb, int> cbPair in resourcePair.Value)
364 cbPair.Key(sender, e);
369 public ResourceDictionary XamlResources
373 if (_resources != null)
376 _resources = new ResourceDictionary();
377 int hashCode = _resources.GetHashCode();
378 ((IResourceDictionary)_resources).ValuesChanged += OnResourcesChanged;
383 if (_resources == value)
385 OnPropertyChanging();
387 if (_resources != null)
388 ((IResourceDictionary)_resources).ValuesChanged -= OnResourcesChanged;
390 OnResourcesChanged(value);
391 if (_resources != null)
392 ((IResourceDictionary)_resources).ValuesChanged += OnResourcesChanged;
398 protected override void OnParentSet()
400 throw new InvalidOperationException("Setting a Parent on Application is invalid.");
403 [EditorBrowsable(EditorBrowsableState.Never)]
404 public static bool IsApplicationOrNull(Element element)
406 return element == null || element is Application;
409 internal override void OnParentResourcesChanged(IEnumerable<KeyValuePair<string, object>> values)
411 if (!((IResourcesProvider)this).IsResourcesCreated || XamlResources.Count == 0)
413 base.OnParentResourcesChanged(values);
417 var innerKeys = new HashSet<string>();
418 var changedResources = new List<KeyValuePair<string, object>>();
419 foreach (KeyValuePair<string, object> c in XamlResources)
420 innerKeys.Add(c.Key);
421 foreach (KeyValuePair<string, object> value in values)
423 if (innerKeys.Add(value.Key))
424 changedResources.Add(value);
426 OnResourcesChanged(changedResources);
430 internal Application(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
432 SetCurrentApplication(this);
438 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Application obj)
440 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
443 protected override void Dispose(DisposeTypes type)
450 //Release your own unmanaged resources here.
451 //You should not access any managed member here except static instance.
452 //because the execution order of Finalizes is non-deterministic.
454 if (_applicationInitEventCallbackDelegate != null)
456 initSignal?.Disconnect(_applicationInitEventCallbackDelegate);
457 initSignal?.Dispose();
461 if (_applicationTerminateEventCallbackDelegate != null)
463 terminateSignal?.Disconnect(_applicationTerminateEventCallbackDelegate);
464 terminateSignal?.Dispose();
465 terminateSignal = null;
468 if (_applicationPauseEventCallbackDelegate != null)
470 pauseSignal?.Disconnect(_applicationPauseEventCallbackDelegate);
471 pauseSignal?.Dispose();
475 if (_applicationResumeEventCallbackDelegate != null)
477 resumeSignal?.Disconnect(_applicationResumeEventCallbackDelegate);
478 resumeSignal?.Dispose();
482 if (_applicationResetEventCallbackDelegate != null)
484 resetSignal?.Disconnect(_applicationResetEventCallbackDelegate);
485 resetSignal?.Dispose();
489 if (_applicationLanguageChangedEventCallbackDelegate != null)
491 languageChangedSignal?.Disconnect(_applicationLanguageChangedEventCallbackDelegate);
492 languageChangedSignal?.Dispose();
493 languageChangedSignal = null;
496 if (_applicationRegionChangedEventCallbackDelegate != null)
498 regionChangedSignal?.Disconnect(_applicationRegionChangedEventCallbackDelegate);
499 regionChangedSignal?.Dispose();
500 regionChangedSignal = null;
503 if (_applicationBatteryLowEventCallbackDelegate != null)
505 batteryLowSignal?.Disconnect(_applicationBatteryLowEventCallbackDelegate);
506 batteryLowSignal?.Dispose();
507 batteryLowSignal = null;
510 if (_applicationMemoryLowEventCallbackDelegate != null)
512 memoryLowSignal?.Disconnect(_applicationMemoryLowEventCallbackDelegate);
513 memoryLowSignal?.Dispose();
514 memoryLowSignal = null;
517 if (_applicationAppControlEventCallbackDelegate != null)
519 appControlSignal?.Disconnect(_applicationAppControlEventCallbackDelegate);
520 appControlSignal?.Dispose();
521 appControlSignal = null;
529 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
531 Interop.Application.DeleteApplication(swigCPtr);
534 public enum BatteryStatus
541 public enum MemoryStatus
548 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
549 private delegate void NUIApplicationInitEventCallbackDelegate(IntPtr application);
550 private DaliEventHandler<object, NUIApplicationInitEventArgs> _applicationInitEventHandler;
551 private NUIApplicationInitEventCallbackDelegate _applicationInitEventCallbackDelegate;
552 private ApplicationSignal initSignal;
555 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
556 private delegate void NUIApplicationTerminateEventCallbackDelegate(IntPtr application);
557 private DaliEventHandler<object, NUIApplicationTerminatingEventArgs> _applicationTerminateEventHandler;
558 private NUIApplicationTerminateEventCallbackDelegate _applicationTerminateEventCallbackDelegate;
559 private ApplicationSignal terminateSignal;
562 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
563 private delegate void NUIApplicationPauseEventCallbackDelegate(IntPtr application);
564 private DaliEventHandler<object, NUIApplicationPausedEventArgs> _applicationPauseEventHandler;
565 private NUIApplicationPauseEventCallbackDelegate _applicationPauseEventCallbackDelegate;
566 private ApplicationSignal pauseSignal;
568 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
569 private delegate void NUIApplicationResumeEventCallbackDelegate(IntPtr application);
570 private DaliEventHandler<object, NUIApplicationResumedEventArgs> _applicationResumeEventHandler;
571 private NUIApplicationResumeEventCallbackDelegate _applicationResumeEventCallbackDelegate;
572 private ApplicationSignal resumeSignal;
574 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
575 private delegate void NUIApplicationResetEventCallbackDelegate(IntPtr application);
576 private DaliEventHandler<object, NUIApplicationResetEventArgs> _applicationResetEventHandler;
577 private NUIApplicationResetEventCallbackDelegate _applicationResetEventCallbackDelegate;
578 private ApplicationSignal resetSignal;
580 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
581 private delegate void NUIApplicationLanguageChangedEventCallbackDelegate(IntPtr application);
582 private DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> _applicationLanguageChangedEventHandler;
583 private NUIApplicationLanguageChangedEventCallbackDelegate _applicationLanguageChangedEventCallbackDelegate;
584 private ApplicationSignal languageChangedSignal;
587 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
588 private delegate void NUIApplicationRegionChangedEventCallbackDelegate(IntPtr application);
589 private DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> _applicationRegionChangedEventHandler;
590 private NUIApplicationRegionChangedEventCallbackDelegate _applicationRegionChangedEventCallbackDelegate;
591 private ApplicationSignal regionChangedSignal;
593 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
594 private delegate void NUIApplicationBatteryLowEventCallbackDelegate(BatteryStatus status);
595 private DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> _applicationBatteryLowEventHandler;
596 private NUIApplicationBatteryLowEventCallbackDelegate _applicationBatteryLowEventCallbackDelegate;
597 private LowBatterySignalType batteryLowSignal;
599 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
600 private delegate void NUIApplicationMemoryLowEventCallbackDelegate(MemoryStatus status);
601 private DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> _applicationMemoryLowEventHandler;
602 private NUIApplicationMemoryLowEventCallbackDelegate _applicationMemoryLowEventCallbackDelegate;
603 private LowMemorySignalType memoryLowSignal;
605 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
606 private delegate void NUIApplicationAppControlEventCallbackDelegate(IntPtr application, IntPtr voidp);
607 private DaliEventHandler<object, NUIApplicationAppControlEventArgs> _applicationAppControlEventHandler;
608 private NUIApplicationAppControlEventCallbackDelegate _applicationAppControlEventCallbackDelegate;
609 private ApplicationControlSignal appControlSignal;
614 * @brief Event for Initialized signal which can be used to subscribe/unsubscribe the event handler
615 * provided by the user. Initialized signal is emitted when application is initialised
617 public event DaliEventHandler<object, NUIApplicationInitEventArgs> Initialized
621 // Restricted to only one listener
622 if (_applicationInitEventHandler == null)
624 _applicationInitEventHandler += value;
625 _applicationInitEventCallbackDelegate = new NUIApplicationInitEventCallbackDelegate(OnApplicationInit);
626 initSignal = this.InitSignal();
627 initSignal?.Connect(_applicationInitEventCallbackDelegate);
633 if (_applicationInitEventHandler != null)
635 initSignal?.Disconnect(_applicationInitEventCallbackDelegate);
636 initSignal?.Dispose();
640 _applicationInitEventHandler -= value;
644 // Callback for Application InitSignal
645 private void OnApplicationInit(IntPtr data)
647 // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread.
648 DisposeQueue.Instance.Initialize();
650 // Notify that the window is displayed to the app core.
651 if (NUIApplication.IsPreload)
653 Window.Instance.Show();
656 if (_applicationInitEventHandler != null)
658 NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs();
659 e.Application = this;
660 _applicationInitEventHandler.Invoke(this, e);
666 * @brief Event for Terminated signal which can be used to subscribe/unsubscribe the event handler
667 * provided by the user. Terminated signal is emitted when application is terminating
669 public event DaliEventHandler<object, NUIApplicationTerminatingEventArgs> Terminating
673 // Restricted to only one listener
674 if (_applicationTerminateEventHandler == null)
676 _applicationTerminateEventHandler += value;
678 _applicationTerminateEventCallbackDelegate = new NUIApplicationTerminateEventCallbackDelegate(OnNUIApplicationTerminate);
679 terminateSignal = this.TerminateSignal();
680 terminateSignal?.Connect(_applicationTerminateEventCallbackDelegate);
686 if (_applicationTerminateEventHandler != null)
688 terminateSignal?.Disconnect(_applicationTerminateEventCallbackDelegate);
689 terminateSignal?.Dispose();
690 terminateSignal = null;
693 _applicationTerminateEventHandler -= value;
697 // Callback for Application TerminateSignal
698 private void OnNUIApplicationTerminate(IntPtr data)
700 if (_applicationTerminateEventHandler != null)
702 NUIApplicationTerminatingEventArgs e = new NUIApplicationTerminatingEventArgs();
703 e.Application = this;
704 _applicationTerminateEventHandler.Invoke(this, e);
707 List<Window> windows = GetWindowList();
708 foreach (Window window in windows)
710 window?.DisconnectNativeSignals();
715 * @brief Event for Paused signal which can be used to subscribe/unsubscribe the event handler
716 * provided by the user. Paused signal is emitted when application is paused
718 public event DaliEventHandler<object, NUIApplicationPausedEventArgs> Paused
722 // Restricted to only one listener
723 if (_applicationPauseEventHandler == null)
725 _applicationPauseEventHandler += value;
727 _applicationPauseEventCallbackDelegate = new NUIApplicationPauseEventCallbackDelegate(OnNUIApplicationPause);
728 pauseSignal = this.PauseSignal();
729 pauseSignal?.Connect(_applicationPauseEventCallbackDelegate);
735 if (_applicationPauseEventHandler != null)
737 pauseSignal?.Disconnect(_applicationPauseEventCallbackDelegate);
738 pauseSignal?.Dispose();
742 _applicationPauseEventHandler -= value;
746 // Callback for Application PauseSignal
747 private void OnNUIApplicationPause(IntPtr data)
749 if (_applicationPauseEventHandler != null)
751 NUIApplicationPausedEventArgs e = new NUIApplicationPausedEventArgs();
752 e.Application = this;
753 _applicationPauseEventHandler.Invoke(this, e);
758 * @brief Event for Resumed signal which can be used to subscribe/unsubscribe the event handler
759 * provided by the user. Resumed signal is emitted when application is resumed
761 public event DaliEventHandler<object, NUIApplicationResumedEventArgs> Resumed
765 // Restricted to only one listener
766 if (_applicationResumeEventHandler == null)
768 _applicationResumeEventHandler += value;
770 _applicationResumeEventCallbackDelegate = new NUIApplicationResumeEventCallbackDelegate(OnNUIApplicationResume);
771 resumeSignal = this.ResumeSignal();
772 resumeSignal?.Connect(_applicationResumeEventCallbackDelegate);
778 if (_applicationResumeEventHandler != null)
780 resumeSignal?.Disconnect(_applicationResumeEventCallbackDelegate);
781 resumeSignal?.Dispose();
785 _applicationResumeEventHandler -= value;
789 // Callback for Application ResumeSignal
790 private void OnNUIApplicationResume(IntPtr data)
792 if (_applicationResumeEventHandler != null)
794 NUIApplicationResumedEventArgs e = new NUIApplicationResumedEventArgs();
795 e.Application = this;
796 _applicationResumeEventHandler.Invoke(this, e);
801 * @brief Event for Reset signal which can be used to subscribe/unsubscribe the event handler
802 * provided by the user. Reset signal is emitted when application is reset
804 public new event DaliEventHandler<object, NUIApplicationResetEventArgs> Reset
808 // Restricted to only one listener
809 if (_applicationResetEventHandler == null)
811 _applicationResetEventHandler += value;
813 _applicationResetEventCallbackDelegate = new NUIApplicationResetEventCallbackDelegate(OnNUIApplicationReset);
814 resetSignal = this.ResetSignal();
815 resetSignal?.Connect(_applicationResetEventCallbackDelegate);
821 if (_applicationResetEventHandler != null)
823 resetSignal?.Disconnect(_applicationResetEventCallbackDelegate);
824 resetSignal?.Dispose();
828 _applicationResetEventHandler -= value;
832 // Callback for Application ResetSignal
833 private void OnNUIApplicationReset(IntPtr data)
835 if (_applicationResetEventHandler != null)
837 NUIApplicationResetEventArgs e = new NUIApplicationResetEventArgs();
838 e.Application = this;
839 _applicationResetEventHandler.Invoke(this, e);
844 * @brief Event for LanguageChanged signal which can be used to subscribe/unsubscribe the event handler
845 * provided by the user. LanguageChanged signal is emitted when the region of the device is changed.
847 public event DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> LanguageChanged
851 // Restricted to only one listener
852 if (_applicationLanguageChangedEventHandler == null)
854 _applicationLanguageChangedEventHandler += value;
856 _applicationLanguageChangedEventCallbackDelegate = new NUIApplicationLanguageChangedEventCallbackDelegate(OnNUIApplicationLanguageChanged);
857 languageChangedSignal = this.LanguageChangedSignal();
858 languageChangedSignal?.Connect(_applicationLanguageChangedEventCallbackDelegate);
864 if (_applicationLanguageChangedEventHandler != null)
866 languageChangedSignal?.Disconnect(_applicationLanguageChangedEventCallbackDelegate);
867 languageChangedSignal?.Dispose();
868 languageChangedSignal = null;
871 _applicationLanguageChangedEventHandler -= value;
875 // Callback for Application LanguageChangedSignal
876 private void OnNUIApplicationLanguageChanged(IntPtr data)
878 if (_applicationLanguageChangedEventHandler != null)
880 NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs();
881 e.Application = this;
882 _applicationLanguageChangedEventHandler.Invoke(this, e);
887 * @brief Event for RegionChanged signal which can be used to subscribe/unsubscribe the event handler
888 * provided by the user. RegionChanged signal is emitted when the region of the device is changed.
890 public event DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> RegionChanged
894 // Restricted to only one listener
895 if (_applicationRegionChangedEventHandler == null)
897 _applicationRegionChangedEventHandler += value;
899 _applicationRegionChangedEventCallbackDelegate = new NUIApplicationRegionChangedEventCallbackDelegate(OnNUIApplicationRegionChanged);
900 regionChangedSignal = this.RegionChangedSignal();
901 regionChangedSignal?.Connect(_applicationRegionChangedEventCallbackDelegate);
907 if (_applicationRegionChangedEventHandler != null)
909 regionChangedSignal?.Disconnect(_applicationRegionChangedEventCallbackDelegate);
910 regionChangedSignal?.Dispose();
911 regionChangedSignal = null;
914 _applicationRegionChangedEventHandler -= value;
918 // Callback for Application RegionChangedSignal
919 private void OnNUIApplicationRegionChanged(IntPtr data)
921 if (_applicationRegionChangedEventHandler != null)
923 NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs();
924 e.Application = this;
925 _applicationRegionChangedEventHandler.Invoke(this, e);
930 * @brief Event for BatteryLow signal which can be used to subscribe/unsubscribe the event handler
931 * provided by the user. BatteryLow signal is emitted when the battery level of the device is low.
933 public event DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> BatteryLow
937 // Restricted to only one listener
938 if (_applicationBatteryLowEventHandler == null)
940 _applicationBatteryLowEventHandler += value;
942 _applicationBatteryLowEventCallbackDelegate = new NUIApplicationBatteryLowEventCallbackDelegate(OnNUIApplicationBatteryLow);
943 batteryLowSignal = this.BatteryLowSignal();
944 batteryLowSignal?.Connect(_applicationBatteryLowEventCallbackDelegate);
950 if (_applicationBatteryLowEventHandler != null)
952 batteryLowSignal?.Disconnect(_applicationBatteryLowEventCallbackDelegate);
953 batteryLowSignal?.Dispose();
954 batteryLowSignal = null;
957 _applicationBatteryLowEventHandler -= value;
961 // Callback for Application BatteryLowSignal
962 private void OnNUIApplicationBatteryLow(BatteryStatus status)
964 NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
966 // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
967 e.BatteryStatus = status;
968 _applicationBatteryLowEventHandler?.Invoke(this, e);
972 * @brief Event for MemoryLow signal which can be used to subscribe/unsubscribe the event handler
973 * provided by the user. MemoryLow signal is emitted when the memory level of the device is low.
975 public event DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> MemoryLow
979 // Restricted to only one listener
980 if (_applicationMemoryLowEventHandler == null)
982 _applicationMemoryLowEventHandler += value;
984 _applicationMemoryLowEventCallbackDelegate = new NUIApplicationMemoryLowEventCallbackDelegate(OnNUIApplicationMemoryLow);
985 memoryLowSignal = this.MemoryLowSignal();
986 memoryLowSignal?.Connect(_applicationMemoryLowEventCallbackDelegate);
992 if (_applicationMemoryLowEventHandler != null)
994 memoryLowSignal?.Disconnect(_applicationMemoryLowEventCallbackDelegate);
995 memoryLowSignal?.Dispose();
996 memoryLowSignal = null;
999 _applicationMemoryLowEventHandler -= value;
1003 // Callback for Application MemoryLowSignal
1004 private void OnNUIApplicationMemoryLow(MemoryStatus status)
1006 NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
1008 // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
1009 e.MemoryStatus = status;
1010 _applicationMemoryLowEventHandler?.Invoke(this, e);
1014 * @brief Event for AppControl signal which can be used to subscribe/unsubscribe the event handler
1015 * provided by the user. AppControl signal is emitted when another application sends a launch request to the application.
1017 public event DaliEventHandler<object, NUIApplicationAppControlEventArgs> AppControl
1021 // Restricted to only one listener
1022 if (_applicationAppControlEventHandler == null)
1024 _applicationAppControlEventHandler += value;
1026 _applicationAppControlEventCallbackDelegate = new NUIApplicationAppControlEventCallbackDelegate(OnNUIApplicationAppControl);
1027 appControlSignal = this.AppControlSignal();
1028 appControlSignal?.Connect(_applicationAppControlEventCallbackDelegate);
1034 if (_applicationAppControlEventHandler != null)
1036 appControlSignal?.Disconnect(_applicationAppControlEventCallbackDelegate);
1037 appControlSignal?.Dispose();
1038 appControlSignal = null;
1041 _applicationAppControlEventHandler -= value;
1045 // Callback for Application AppControlSignal
1046 private void OnNUIApplicationAppControl(IntPtr application, IntPtr voidp)
1048 if (_applicationAppControlEventHandler != null)
1050 NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs();
1052 e.Application = this;
1053 _applicationAppControlEventHandler.Invoke(this, e);
1057 protected static Application _instance; // singleton
1059 public static Application Instance
1067 public static Application GetApplicationFromPtr(global::System.IntPtr cPtr)
1069 if (cPtr == global::System.IntPtr.Zero)
1074 Application ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Application;
1075 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1079 public static Application NewApplication()
1081 return NewApplication("", Application.WindowMode.Opaque);
1084 public static Application NewApplication(string stylesheet)
1086 return NewApplication(stylesheet, Application.WindowMode.Opaque);
1089 public static Application NewApplication(string stylesheet, Application.WindowMode windowMode)
1091 // register all Views with the type registry, so that can be created / styled via JSON
1092 //ViewRegistryHelper.Initialize(); //moved to Application side.
1098 Application ret = New(1, stylesheet, windowMode);
1099 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1101 // set the singleton
1106 public static Application NewApplication(string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1112 Application ret = New(1, stylesheet, windowMode, positionSize);
1113 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1115 // set the singleton
1120 public static Application NewApplication(string[] args, string stylesheet, Application.WindowMode windowMode)
1126 Application ret = New(args, stylesheet, (Application.WindowMode)windowMode);
1127 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1129 // set the singleton
1134 public static Application NewApplication(string[] args, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1140 Application ret = New(args, stylesheet, (Application.WindowMode)windowMode, positionSize);
1141 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1143 // set the singleton
1149 /// Ensures that the function passed in is called from the main loop when it is idle.
1151 /// <param name="func">The function to call</param>
1152 /// <returns>true if added successfully, false otherwise</returns>
1153 public bool AddIdle(System.Delegate func)
1155 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
1156 System.IntPtr ip2 = Interop.Application.MakeCallback(new System.Runtime.InteropServices.HandleRef(this, ip));
1158 bool ret = Interop.Application.AddIdle(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip2));
1160 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1165 * Outer::outer_method(int)
1167 public static Application New()
1169 Application ret = new Application(Interop.Application.New(), true);
1170 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1174 public static Application New(int argc)
1176 Application ret = new Application(Interop.Application.New(argc), true);
1177 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1181 public static Application New(int argc, string stylesheet)
1183 Application ret = new Application(Interop.Application.New(argc, stylesheet), true);
1184 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1188 public static Application New(int argc, string stylesheet, Application.WindowMode windowMode)
1190 Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode), true);
1191 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1196 public static Application New(string[] args, string stylesheet, Application.WindowMode windowMode)
1198 Application ret = null;
1200 string argvStr = "";
1204 argvStr = string.Join(" ", args);
1206 catch (Exception exception)
1208 Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, msg : " + exception.Message);
1209 Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber());
1210 Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace);
1214 ret = new Application(NDalicPINVOKE.ApplicationNewManual4(argc, argvStr, stylesheet, (int)windowMode), true);
1215 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1220 public static Application New(int argc, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1222 Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1223 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1227 public static Application New(string[] args, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1229 Application ret = null;
1231 string argvStr = "";
1235 argvStr = string.Join(" ", args);
1237 catch (Exception exception)
1239 Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, msg : " + exception.Message);
1240 Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber());
1241 Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace);
1245 ret = new Application(NDalicPINVOKE.ApplicationNewWithWindowSizePosition(argc, argvStr, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1246 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1251 public Application() : this(Interop.Application.NewApplication(), true)
1253 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1256 public Application(Application application) : this(Interop.Application.NewApplication(Application.getCPtr(application)), true)
1258 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1261 public Application Assign(Application application)
1263 Application ret = new Application(Interop.Application.Assign(SwigCPtr, Application.getCPtr(application)), false);
1264 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1268 public void MainLoop()
1270 NDalicPINVOKE.ApplicationMainLoop(SwigCPtr);
1271 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1276 Interop.Application.Lower(SwigCPtr);
1277 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1282 Interop.Application.Quit(SwigCPtr);
1283 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1286 internal bool AddIdle(SWIGTYPE_p_Dali__CallbackBase callback)
1288 bool ret = Interop.Application.AddIdle(SwigCPtr, SWIGTYPE_p_Dali__CallbackBase.getCPtr(callback));
1289 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1293 public Window GetWindow()
1295 win = Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindow(SwigCPtr)) as Window;
1298 win = new Window(Interop.Application.GetWindow(SwigCPtr), true);
1301 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1305 public static string GetResourcePath()
1307 string ret = Interop.Application.GetResourcePath();
1308 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1312 public string GetLanguage()
1314 string ret = Interop.Application.GetLanguage(SwigCPtr);
1315 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1319 public string GetRegion()
1321 string ret = Interop.Application.GetRegion(SwigCPtr);
1322 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1326 [EditorBrowsable(EditorBrowsableState.Never)]
1327 public static List<Window> GetWindowList()
1329 uint ListSize = Interop.Application.GetWindowsListSize();
1330 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1332 List<Window> WindowList = new List<Window>();
1333 for (uint i = 0; i < ListSize; ++i)
1335 Window currWin = Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindowsFromList(i)) as Window;
1336 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1339 WindowList.Add(currWin);
1345 internal ApplicationSignal InitSignal()
1347 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationInitSignal(SwigCPtr), false);
1348 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1352 internal ApplicationSignal TerminateSignal()
1354 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationTerminateSignal(SwigCPtr), false);
1355 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1359 internal ApplicationSignal PauseSignal()
1361 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationPauseSignal(SwigCPtr), false);
1362 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1366 internal ApplicationSignal ResumeSignal()
1368 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationResumeSignal(SwigCPtr), false);
1369 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1373 internal ApplicationSignal ResetSignal()
1375 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationResetSignal(SwigCPtr), false);
1376 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1380 internal ApplicationControlSignal AppControlSignal()
1382 ApplicationControlSignal ret = new ApplicationControlSignal(NDalicPINVOKE.ApplicationAppControlSignal(SwigCPtr), false);
1383 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1387 internal ApplicationSignal LanguageChangedSignal()
1389 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationLanguageChangedSignal(SwigCPtr), false);
1390 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1394 internal ApplicationSignal RegionChangedSignal()
1396 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationRegionChangedSignal(SwigCPtr), false);
1397 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1401 internal LowBatterySignalType BatteryLowSignal()
1403 LowBatterySignalType ret = new LowBatterySignalType(NDalicPINVOKE.ApplicationLowBatterySignal(SwigCPtr), false);
1404 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1408 internal LowMemorySignalType MemoryLowSignal()
1410 LowMemorySignalType ret = new LowMemorySignalType(NDalicPINVOKE.ApplicationLowMemorySignal(SwigCPtr), false);
1411 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1415 public enum WindowMode