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(NDalicPINVOKE.ApplicationUpcast(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 ApplicationSignal initSignal = this.InitSignal();
457 initSignal?.Disconnect(_applicationInitEventCallbackDelegate);
458 initSignal?.Dispose();
461 if (_applicationTerminateEventCallbackDelegate != null)
463 ApplicationSignal terminateSignal = this.TerminateSignal();
464 terminateSignal?.Disconnect(_applicationTerminateEventCallbackDelegate);
465 terminateSignal?.Dispose();
468 if (_applicationPauseEventCallbackDelegate != null)
470 ApplicationSignal pauseSignal = this.PauseSignal();
471 pauseSignal?.Disconnect(_applicationPauseEventCallbackDelegate);
472 pauseSignal?.Dispose();
475 if (_applicationResumeEventCallbackDelegate != null)
477 ApplicationSignal resumeSignal = this.ResumeSignal();
478 resumeSignal?.Disconnect(_applicationResumeEventCallbackDelegate);
479 resumeSignal?.Dispose();
482 if (_applicationResetEventCallbackDelegate != null)
484 ApplicationSignal resetSignal = this.ResetSignal();
485 resetSignal?.Disconnect(_applicationResetEventCallbackDelegate);
486 resetSignal?.Dispose();
489 if (_applicationLanguageChangedEventCallbackDelegate != null)
491 ApplicationSignal languageChangedSignal = this.LanguageChangedSignal();
492 languageChangedSignal?.Disconnect(_applicationLanguageChangedEventCallbackDelegate);
493 languageChangedSignal?.Dispose();
496 if (_applicationRegionChangedEventCallbackDelegate != null)
498 ApplicationSignal regionChangedSignal = this.RegionChangedSignal();
499 regionChangedSignal?.Disconnect(_applicationRegionChangedEventCallbackDelegate);
500 regionChangedSignal?.Dispose();
503 if (_applicationBatteryLowEventCallbackDelegate != null)
505 LowBatterySignalType batteryLowSignal = this.BatteryLowSignal();
506 batteryLowSignal?.Disconnect(_applicationBatteryLowEventCallbackDelegate);
507 batteryLowSignal?.Dispose();
510 if (_applicationMemoryLowEventCallbackDelegate != null)
512 LowMemorySignalType memoryLowSignal = this.MemoryLowSignal();
513 memoryLowSignal?.Disconnect(_applicationMemoryLowEventCallbackDelegate);
514 memoryLowSignal?.Dispose();
517 if (_applicationAppControlEventCallbackDelegate != null)
519 ApplicationControlSignal appControlSignal = this.AppControlSignal();
520 appControlSignal?.Disconnect(_applicationAppControlEventCallbackDelegate);
521 appControlSignal?.Dispose();
526 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
528 Interop.Application.DeleteApplication(swigCPtr);
531 /// <since_tizen> 4 </since_tizen>
532 public enum BatteryStatus
539 /// <since_tizen> 4 </since_tizen>
540 public enum MemoryStatus
547 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
548 private delegate void NUIApplicationInitEventCallbackDelegate(IntPtr application);
549 private DaliEventHandler<object, NUIApplicationInitEventArgs> _applicationInitEventHandler;
550 private NUIApplicationInitEventCallbackDelegate _applicationInitEventCallbackDelegate;
553 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
554 private delegate void NUIApplicationTerminateEventCallbackDelegate(IntPtr application);
555 private DaliEventHandler<object, NUIApplicationTerminatingEventArgs> _applicationTerminateEventHandler;
556 private NUIApplicationTerminateEventCallbackDelegate _applicationTerminateEventCallbackDelegate;
559 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
560 private delegate void NUIApplicationPauseEventCallbackDelegate(IntPtr application);
561 private DaliEventHandler<object, NUIApplicationPausedEventArgs> _applicationPauseEventHandler;
562 private NUIApplicationPauseEventCallbackDelegate _applicationPauseEventCallbackDelegate;
564 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
565 private delegate void NUIApplicationResumeEventCallbackDelegate(IntPtr application);
566 private DaliEventHandler<object, NUIApplicationResumedEventArgs> _applicationResumeEventHandler;
567 private NUIApplicationResumeEventCallbackDelegate _applicationResumeEventCallbackDelegate;
569 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
570 private delegate void NUIApplicationResetEventCallbackDelegate(IntPtr application);
571 private DaliEventHandler<object, NUIApplicationResetEventArgs> _applicationResetEventHandler;
572 private NUIApplicationResetEventCallbackDelegate _applicationResetEventCallbackDelegate;
574 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
575 private delegate void NUIApplicationLanguageChangedEventCallbackDelegate(IntPtr application);
576 private DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> _applicationLanguageChangedEventHandler;
577 private NUIApplicationLanguageChangedEventCallbackDelegate _applicationLanguageChangedEventCallbackDelegate;
580 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
581 private delegate void NUIApplicationRegionChangedEventCallbackDelegate(IntPtr application);
582 private DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> _applicationRegionChangedEventHandler;
583 private NUIApplicationRegionChangedEventCallbackDelegate _applicationRegionChangedEventCallbackDelegate;
585 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
586 private delegate void NUIApplicationBatteryLowEventCallbackDelegate(BatteryStatus status);
587 private DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> _applicationBatteryLowEventHandler;
588 private NUIApplicationBatteryLowEventCallbackDelegate _applicationBatteryLowEventCallbackDelegate;
590 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
591 private delegate void NUIApplicationMemoryLowEventCallbackDelegate(MemoryStatus status);
592 private DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> _applicationMemoryLowEventHandler;
593 private NUIApplicationMemoryLowEventCallbackDelegate _applicationMemoryLowEventCallbackDelegate;
595 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
596 private delegate void NUIApplicationAppControlEventCallbackDelegate(IntPtr application, IntPtr voidp);
597 private DaliEventHandler<object, NUIApplicationAppControlEventArgs> _applicationAppControlEventHandler;
598 private NUIApplicationAppControlEventCallbackDelegate _applicationAppControlEventCallbackDelegate;
601 * @brief Event for Initialized signal which can be used to subscribe/unsubscribe the event handler
602 * provided by the user. Initialized signal is emitted when application is initialised
604 public event DaliEventHandler<object, NUIApplicationInitEventArgs> Initialized
610 // Restricted to only one listener
611 if (_applicationInitEventHandler == null)
613 _applicationInitEventHandler += value;
615 _applicationInitEventCallbackDelegate = new NUIApplicationInitEventCallbackDelegate(OnApplicationInit);
616 this.InitSignal().Connect(_applicationInitEventCallbackDelegate);
625 if (_applicationInitEventHandler != null)
627 ApplicationSignal initSignal = this.InitSignal();
628 initSignal?.Disconnect(_applicationInitEventCallbackDelegate);
629 initSignal?.Dispose();
632 _applicationInitEventHandler -= value;
637 // Callback for Application InitSignal
638 private void OnApplicationInit(IntPtr data)
640 // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread.
641 DisposeQueue.Instance.Initialize();
643 // Notify that the window is displayed to the app core.
644 if (NUIApplication.IsPreLoad)
646 Window.Instance.Show();
649 if (_applicationInitEventHandler != null)
651 NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs();
652 e.Application = this;
653 _applicationInitEventHandler.Invoke(this, e);
659 * @brief Event for Terminated signal which can be used to subscribe/unsubscribe the event handler
660 * provided by the user. Terminated signal is emitted when application is terminating
662 public event DaliEventHandler<object, NUIApplicationTerminatingEventArgs> Terminating
668 // Restricted to only one listener
669 if (_applicationTerminateEventHandler == null)
671 _applicationTerminateEventHandler += value;
673 _applicationTerminateEventCallbackDelegate = new NUIApplicationTerminateEventCallbackDelegate(OnNUIApplicationTerminate);
674 this.TerminateSignal().Connect(_applicationTerminateEventCallbackDelegate);
683 if (_applicationTerminateEventHandler != null)
685 ApplicationSignal terminateSignal = this.TerminateSignal();
686 terminateSignal?.Disconnect(_applicationTerminateEventCallbackDelegate);
687 terminateSignal?.Dispose();
690 _applicationTerminateEventHandler -= value;
695 // Callback for Application TerminateSignal
696 private void OnNUIApplicationTerminate(IntPtr data)
698 if (_applicationTerminateEventHandler != null)
700 NUIApplicationTerminatingEventArgs e = new NUIApplicationTerminatingEventArgs();
701 e.Application = this;
702 _applicationTerminateEventHandler.Invoke(this, e);
705 List<Window> windows = GetWindowList();
706 foreach (Window window in windows)
708 window?.DisconnectNativeSignals();
713 * @brief Event for Paused signal which can be used to subscribe/unsubscribe the event handler
714 * provided by the user. Paused signal is emitted when application is paused
716 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 this.PauseSignal().Connect(_applicationPauseEventCallbackDelegate);
737 if (_applicationPauseEventHandler != null)
739 ApplicationSignal pauseSignal = this.PauseSignal();
740 pauseSignal?.Disconnect(_applicationPauseEventCallbackDelegate);
741 pauseSignal?.Dispose();
744 _applicationPauseEventHandler -= value;
749 // Callback for Application PauseSignal
750 private void OnNUIApplicationPause(IntPtr data)
752 if (_applicationPauseEventHandler != null)
754 NUIApplicationPausedEventArgs e = new NUIApplicationPausedEventArgs();
755 e.Application = this;
756 _applicationPauseEventHandler.Invoke(this, e);
761 * @brief Event for Resumed signal which can be used to subscribe/unsubscribe the event handler
762 * provided by the user. Resumed signal is emitted when application is resumed
764 public event DaliEventHandler<object, NUIApplicationResumedEventArgs> Resumed
770 // Restricted to only one listener
771 if (_applicationResumeEventHandler == null)
773 _applicationResumeEventHandler += value;
775 _applicationResumeEventCallbackDelegate = new NUIApplicationResumeEventCallbackDelegate(OnNUIApplicationResume);
776 this.ResumeSignal().Connect(_applicationResumeEventCallbackDelegate);
785 if (_applicationResumeEventHandler != null)
787 ApplicationSignal resumeSignal = this.ResumeSignal();
788 resumeSignal?.Disconnect(_applicationResumeEventCallbackDelegate);
789 resumeSignal?.Dispose();
792 _applicationResumeEventHandler -= value;
797 // Callback for Application ResumeSignal
798 private void OnNUIApplicationResume(IntPtr data)
800 if (_applicationResumeEventHandler != null)
802 NUIApplicationResumedEventArgs e = new NUIApplicationResumedEventArgs();
803 e.Application = this;
804 _applicationResumeEventHandler.Invoke(this, e);
809 * @brief Event for Reset signal which can be used to subscribe/unsubscribe the event handler
810 * provided by the user. Reset signal is emitted when application is reset
812 public new event DaliEventHandler<object, NUIApplicationResetEventArgs> Reset
818 // Restricted to only one listener
819 if (_applicationResetEventHandler == null)
821 _applicationResetEventHandler += value;
823 _applicationResetEventCallbackDelegate = new NUIApplicationResetEventCallbackDelegate(OnNUIApplicationReset);
824 this.ResetSignal().Connect(_applicationResetEventCallbackDelegate);
833 if (_applicationResetEventHandler != null)
835 ApplicationSignal resetSignal = this.ResetSignal();
836 resetSignal?.Disconnect(_applicationResetEventCallbackDelegate);
837 resetSignal?.Dispose();
840 _applicationResetEventHandler -= value;
845 // Callback for Application ResetSignal
846 private void OnNUIApplicationReset(IntPtr data)
848 if (_applicationResetEventHandler != null)
850 NUIApplicationResetEventArgs e = new NUIApplicationResetEventArgs();
851 e.Application = this;
852 _applicationResetEventHandler.Invoke(this, e);
857 * @brief Event for LanguageChanged signal which can be used to subscribe/unsubscribe the event handler
858 * provided by the user. LanguageChanged signal is emitted when the region of the device is changed.
860 public event DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> LanguageChanged
866 // Restricted to only one listener
867 if (_applicationLanguageChangedEventHandler == null)
869 _applicationLanguageChangedEventHandler += value;
871 _applicationLanguageChangedEventCallbackDelegate = new NUIApplicationLanguageChangedEventCallbackDelegate(OnNUIApplicationLanguageChanged);
872 this.LanguageChangedSignal().Connect(_applicationLanguageChangedEventCallbackDelegate);
881 if (_applicationLanguageChangedEventHandler != null)
883 ApplicationSignal languageChangedSignal = this.LanguageChangedSignal();
884 languageChangedSignal?.Disconnect(_applicationLanguageChangedEventCallbackDelegate);
885 languageChangedSignal?.Dispose();
888 _applicationLanguageChangedEventHandler -= value;
893 // Callback for Application LanguageChangedSignal
894 private void OnNUIApplicationLanguageChanged(IntPtr data)
896 if (_applicationLanguageChangedEventHandler != null)
898 NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs();
899 e.Application = this;
900 _applicationLanguageChangedEventHandler.Invoke(this, e);
905 * @brief Event for RegionChanged signal which can be used to subscribe/unsubscribe the event handler
906 * provided by the user. RegionChanged signal is emitted when the region of the device is changed.
908 public event DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> RegionChanged
914 // Restricted to only one listener
915 if (_applicationRegionChangedEventHandler == null)
917 _applicationRegionChangedEventHandler += value;
919 _applicationRegionChangedEventCallbackDelegate = new NUIApplicationRegionChangedEventCallbackDelegate(OnNUIApplicationRegionChanged);
920 this.RegionChangedSignal().Connect(_applicationRegionChangedEventCallbackDelegate);
929 if (_applicationRegionChangedEventHandler != null)
931 ApplicationSignal regionChangedSignal = this.RegionChangedSignal();
932 regionChangedSignal?.Disconnect(_applicationRegionChangedEventCallbackDelegate);
933 regionChangedSignal?.Dispose();
936 _applicationRegionChangedEventHandler -= value;
941 // Callback for Application RegionChangedSignal
942 private void OnNUIApplicationRegionChanged(IntPtr data)
944 if (_applicationRegionChangedEventHandler != null)
946 NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs();
947 e.Application = this;
948 _applicationRegionChangedEventHandler.Invoke(this, e);
953 * @brief Event for BatteryLow signal which can be used to subscribe/unsubscribe the event handler
954 * provided by the user. BatteryLow signal is emitted when the battery level of the device is low.
956 public event DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> BatteryLow
962 // Restricted to only one listener
963 if (_applicationBatteryLowEventHandler == null)
965 _applicationBatteryLowEventHandler += value;
967 _applicationBatteryLowEventCallbackDelegate = new NUIApplicationBatteryLowEventCallbackDelegate(OnNUIApplicationBatteryLow);
968 this.BatteryLowSignal().Connect(_applicationBatteryLowEventCallbackDelegate);
977 if (_applicationBatteryLowEventHandler != null)
979 LowBatterySignalType BatteryLowSignal = this.BatteryLowSignal();
980 BatteryLowSignal?.Disconnect(_applicationBatteryLowEventCallbackDelegate);
981 BatteryLowSignal?.Dispose();
984 _applicationBatteryLowEventHandler -= value;
989 // Callback for Application BatteryLowSignal
990 private void OnNUIApplicationBatteryLow(BatteryStatus status)
994 NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
996 // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
997 e.BatteryStatus = status;
998 _applicationBatteryLowEventHandler?.Invoke(this, e);
1003 * @brief Event for MemoryLow signal which can be used to subscribe/unsubscribe the event handler
1004 * provided by the user. MemoryLow signal is emitted when the memory level of the device is low.
1006 public event DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> MemoryLow
1012 // Restricted to only one listener
1013 if (_applicationMemoryLowEventHandler == null)
1015 _applicationMemoryLowEventHandler += value;
1017 _applicationMemoryLowEventCallbackDelegate = new NUIApplicationMemoryLowEventCallbackDelegate(OnNUIApplicationMemoryLow);
1018 this.MemoryLowSignal().Connect(_applicationMemoryLowEventCallbackDelegate);
1027 if (_applicationMemoryLowEventHandler != null)
1029 LowMemorySignalType memoryLowSignal = this.MemoryLowSignal();
1030 memoryLowSignal?.Disconnect(_applicationMemoryLowEventCallbackDelegate);
1031 memoryLowSignal?.Dispose();
1034 _applicationMemoryLowEventHandler -= value;
1039 // Callback for Application MemoryLowSignal
1040 private void OnNUIApplicationMemoryLow(MemoryStatus status)
1044 NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
1046 // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
1047 e.MemoryStatus = status;
1048 _applicationMemoryLowEventHandler?.Invoke(this, e);
1053 * @brief Event for AppControl signal which can be used to subscribe/unsubscribe the event handler
1054 * provided by the user. AppControl signal is emitted when another application sends a launch request to the application.
1056 public event DaliEventHandler<object, NUIApplicationAppControlEventArgs> AppControl
1062 // Restricted to only one listener
1063 if (_applicationAppControlEventHandler == null)
1065 _applicationAppControlEventHandler += value;
1067 _applicationAppControlEventCallbackDelegate = new NUIApplicationAppControlEventCallbackDelegate(OnNUIApplicationAppControl);
1068 this.AppControlSignal().Connect(_applicationAppControlEventCallbackDelegate);
1077 if (_applicationAppControlEventHandler != null)
1079 ApplicationControlSignal appControlSignal = this.AppControlSignal();
1080 appControlSignal?.Disconnect(_applicationAppControlEventCallbackDelegate);
1081 appControlSignal?.Dispose();
1084 _applicationAppControlEventHandler -= value;
1089 // Callback for Application AppControlSignal
1090 private void OnNUIApplicationAppControl(IntPtr application, IntPtr voidp)
1092 if (_applicationAppControlEventHandler != null)
1094 NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs();
1096 e.Application = this;
1097 _applicationAppControlEventHandler.Invoke(this, e);
1101 protected static Application _instance; // singleton
1103 public static Application Instance
1111 public static Application GetApplicationFromPtr(global::System.IntPtr cPtr)
1113 if (cPtr == global::System.IntPtr.Zero)
1118 Application ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Application;
1119 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1123 public static Application NewApplication()
1125 return NewApplication("", Application.WindowMode.Opaque);
1128 public static Application NewApplication(string stylesheet)
1130 return NewApplication(stylesheet, Application.WindowMode.Opaque);
1133 public static Application NewApplication(string stylesheet, Application.WindowMode windowMode)
1135 // register all Views with the type registry, so that can be created / styled via JSON
1136 //ViewRegistryHelper.Initialize(); //moved to Application side.
1142 Application ret = New(1, stylesheet, windowMode);
1143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1145 // set the singleton
1150 public static Application NewApplication(string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1156 Application ret = New(1, stylesheet, windowMode, positionSize);
1157 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1159 // set the singleton
1164 public static Application NewApplication(string[] args, string stylesheet, Application.WindowMode windowMode)
1170 Application ret = New(args, stylesheet, (Application.WindowMode)windowMode);
1171 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1173 // set the singleton
1178 public static Application NewApplication(string[] args, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1184 Application ret = New(args, stylesheet, (Application.WindowMode)windowMode, positionSize);
1185 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1187 // set the singleton
1193 /// Ensures that the function passed in is called from the main loop when it is idle.
1195 /// <param name="func">The function to call</param>
1196 /// <returns>true if added successfully, false otherwise</returns>
1197 public bool AddIdle(System.Delegate func)
1199 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
1200 System.IntPtr ip2 = Interop.Application.MakeCallback(new System.Runtime.InteropServices.HandleRef(this, ip));
1202 bool ret = Interop.Application.AddIdle(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip2));
1204 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1209 * Outer::outer_method(int)
1211 public static Application New()
1213 Application ret = new Application(Interop.Application.New(), true);
1214 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1218 public static Application New(int argc)
1220 Application ret = new Application(Interop.Application.New(argc), true);
1221 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1225 public static Application New(int argc, string stylesheet)
1227 Application ret = new Application(Interop.Application.New(argc, stylesheet), true);
1228 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1232 public static Application New(int argc, string stylesheet, Application.WindowMode windowMode)
1234 Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode), true);
1235 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1240 public static Application New(string[] args, string stylesheet, Application.WindowMode windowMode)
1242 Application ret = null;
1244 string argvStr = "";
1248 argvStr = string.Join(" ", args);
1250 catch (Exception exception)
1252 Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, msg : " + exception.Message);
1253 Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber());
1254 Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace);
1258 ret = new Application(NDalicPINVOKE.ApplicationNewManual4(argc, argvStr, stylesheet, (int)windowMode), true);
1259 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1264 public static Application New(int argc, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1266 Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1267 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1271 public static Application New(string[] args, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1273 Application ret = null;
1275 string argvStr = "";
1279 argvStr = string.Join(" ", args);
1281 catch (Exception exception)
1283 Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, msg : " + exception.Message);
1284 Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber());
1285 Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace);
1289 ret = new Application(NDalicPINVOKE.ApplicationNewWithWindowSizePosition(argc, argvStr, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1290 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1295 public Application() : this(Interop.Application.NewApplication(), true)
1297 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1300 public Application(Application application) : this(Interop.Application.NewApplication(Application.getCPtr(application)), true)
1302 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1305 public Application Assign(Application application)
1307 Application ret = new Application(Interop.Application.Assign(SwigCPtr, Application.getCPtr(application)), false);
1308 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1312 public void MainLoop()
1314 NDalicPINVOKE.ApplicationMainLoop(SwigCPtr);
1315 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1320 Interop.Application.Lower(SwigCPtr);
1321 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1326 Interop.Application.Quit(SwigCPtr);
1327 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1330 internal bool AddIdle(SWIGTYPE_p_Dali__CallbackBase callback)
1332 bool ret = Interop.Application.AddIdle(SwigCPtr, SWIGTYPE_p_Dali__CallbackBase.getCPtr(callback));
1333 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1337 public Window GetWindow()
1339 Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindow(SwigCPtr)) as Window;
1342 ret = new Window(Interop.Application.GetWindow(SwigCPtr), true);
1345 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1349 public static string GetResourcePath()
1351 string ret = Interop.Application.GetResourcePath();
1352 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1356 public string GetLanguage()
1358 string ret = Interop.Application.GetLanguage(SwigCPtr);
1359 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1363 public string GetRegion()
1365 string ret = Interop.Application.GetRegion(SwigCPtr);
1366 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1370 [EditorBrowsable(EditorBrowsableState.Never)]
1371 public static List<Window> GetWindowList()
1373 uint ListSize = Interop.Application.GetWindowsListSize();
1374 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1376 List<Window> WindowList = new List<Window>();
1377 for (uint i = 0; i < ListSize; ++i)
1379 Window currWin = Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindowsFromList(i)) as Window;
1380 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1383 WindowList.Add(currWin);
1389 internal ApplicationSignal InitSignal()
1391 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationInitSignal(SwigCPtr), false);
1392 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1396 internal ApplicationSignal TerminateSignal()
1398 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationTerminateSignal(SwigCPtr), false);
1399 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1403 internal ApplicationSignal PauseSignal()
1405 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationPauseSignal(SwigCPtr), false);
1406 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1410 internal ApplicationSignal ResumeSignal()
1412 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationResumeSignal(SwigCPtr), false);
1413 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1417 internal ApplicationSignal ResetSignal()
1419 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationResetSignal(SwigCPtr), false);
1420 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1424 internal ApplicationControlSignal AppControlSignal()
1426 ApplicationControlSignal ret = new ApplicationControlSignal(NDalicPINVOKE.ApplicationAppControlSignal(SwigCPtr), false);
1427 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1431 internal ApplicationSignal LanguageChangedSignal()
1433 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationLanguageChangedSignal(SwigCPtr), false);
1434 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1438 internal ApplicationSignal RegionChangedSignal()
1440 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationRegionChangedSignal(SwigCPtr), false);
1441 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1445 internal LowBatterySignalType BatteryLowSignal()
1447 LowBatterySignalType ret = new LowBatterySignalType(NDalicPINVOKE.ApplicationLowBatterySignal(SwigCPtr), false);
1448 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1452 internal LowMemorySignalType MemoryLowSignal()
1454 LowMemorySignalType ret = new LowMemorySignalType(NDalicPINVOKE.ApplicationLowMemorySignal(SwigCPtr), false);
1455 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1459 /// <since_tizen> 3 </since_tizen>
1460 public enum WindowMode