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.Runtime.InteropServices;
22 using System.Threading;
23 using System.Threading.Tasks;
24 using Tizen.NUI.Binding;
25 using Tizen.NUI.Binding.Internals;
30 * @brief Event arguments that passed via NUIApplicationInit signal
33 internal class NUIApplicationInitEventArgs : EventArgs
35 private Application _application;
38 * @brief Application - is the application that is being initialized
41 public Application Application
55 * @brief Event arguments that passed via NUIApplicationTerminate signal
58 internal class NUIApplicationTerminatingEventArgs : EventArgs
60 private Application _application;
62 * @brief Application - is the application that is being Terminated
65 public Application Application
79 * @brief Event arguments that passed via NUIApplicationPause signal
82 internal class NUIApplicationPausedEventArgs : EventArgs
84 private Application _application;
86 * @brief Application - is the application that is being Paused
89 public Application Application
103 * @brief Event arguments that passed via NUIApplicationResume signal
106 internal class NUIApplicationResumedEventArgs : EventArgs
108 private Application _application;
110 * @brief Application - is the application that is being Resumed
113 public Application Application
121 _application = value;
127 * @brief Event arguments that passed via NUIApplicationReset signal
130 internal class NUIApplicationResetEventArgs : EventArgs
132 private Application _application;
134 * @brief Application - is the application that is being Reset
137 public Application Application
145 _application = value;
151 * @brief Event arguments that passed via NUIApplicationResize signal
154 internal class NUIApplicationResizedEventArgs : EventArgs
156 private Application _application;
158 * @brief Application - is the application that is being Resized
161 public Application Application
169 _application = value;
175 * @brief Event arguments that passed via NUIApplicationLanguageChanged signal
178 internal class NUIApplicationLanguageChangedEventArgs : EventArgs
180 private Application _application;
182 * @brief Application - is the application that is being affected with Device's language change
185 public Application Application
193 _application = value;
199 * @brief Event arguments that passed via NUIApplicationRegionChanged signal
202 internal class NUIApplicationRegionChangedEventArgs : EventArgs
204 private Application _application;
206 * @brief Application - is the application that is being affected with Device's region change
209 public Application Application
217 _application = value;
223 * @brief Event arguments that passed via NUIApplicationBatteryLow signal
226 internal class NUIApplicationBatteryLowEventArgs : EventArgs
228 private Application.BatteryStatus _status;
230 * @brief Application - is the application that is being affected when the battery level of the device is low
233 public Application.BatteryStatus BatteryStatus
247 * @brief Event arguments that passed via NUIApplicationMemoryLow signal
250 internal class NUIApplicationMemoryLowEventArgs : EventArgs
252 private Application.MemoryStatus _status;
254 * @brief Application - is the application that is being affected when the memory level of the device is low
257 public Application.MemoryStatus MemoryStatus
271 * @brief Event arguments that passed via NUIApplicationAppControl signal
274 internal class NUIApplicationAppControlEventArgs : EventArgs
276 private Application _application;
277 private IntPtr _voidp;
279 * @brief Application - is the application that is receiving the launch request from another application
282 public Application Application
290 _application = value;
294 * @brief VoidP - contains the information about why the application is launched
311 /// A class to get resources in current application.
313 public class GetResourcesProvider
316 /// Get resources in current application.
318 static public IResourcesProvider Get()
320 return Tizen.NUI.Application.Current;
324 internal class Application : BaseHandle, IResourcesProvider, IElementConfiguration<Application>
327 static Application s_current;
329 ReadOnlyCollection<Element> _logicalChildren;
331 static SemaphoreSlim SaveSemaphore = new SemaphoreSlim(1, 1);
333 [EditorBrowsable(EditorBrowsableState.Never)]
334 public static void SetCurrentApplication(Application value) => Current = value;
336 public static Application Current
338 get { return s_current; }
341 if (s_current == value)
344 s_current = null; //Allow to reset current for unittesting
349 internal override ReadOnlyCollection<Element> LogicalChildrenInternal
351 get { return _logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(InternalChildren)); }
354 internal IResourceDictionary SystemResources { get; }
356 ObservableCollection<Element> InternalChildren { get; } = new ObservableCollection<Element>();
358 ResourceDictionary _resources;
359 public bool IsResourcesCreated => _resources != null;
361 public delegate void resChangeCb(object sender, ResourcesChangedEventArgs e);
363 static private Dictionary<object, Dictionary<resChangeCb, int>> resourceChangeCallbackDict = new Dictionary<object, Dictionary<resChangeCb, int>>();
364 static public void AddResourceChangedCallback(object handle, resChangeCb cb)
366 Dictionary<resChangeCb, int> cbDict;
367 resourceChangeCallbackDict.TryGetValue(handle, out cbDict);
371 cbDict = new Dictionary<resChangeCb, int>();
372 resourceChangeCallbackDict.Add(handle, cbDict);
375 if (false == cbDict.ContainsKey(cb))
381 internal override void OnResourcesChanged(object sender, ResourcesChangedEventArgs e)
383 base.OnResourcesChanged(sender, e);
385 foreach (KeyValuePair<object, Dictionary<resChangeCb, int>> resourcePair in resourceChangeCallbackDict)
387 foreach (KeyValuePair<resChangeCb, int> cbPair in resourcePair.Value)
389 cbPair.Key(sender, e);
394 public ResourceDictionary XamlResources
398 if (_resources != null)
401 _resources = new ResourceDictionary();
402 int hashCode = _resources.GetHashCode();
403 ((IResourceDictionary)_resources).ValuesChanged += OnResourcesChanged;
408 if (_resources == value)
410 OnPropertyChanging();
412 if (_resources != null)
413 ((IResourceDictionary)_resources).ValuesChanged -= OnResourcesChanged;
415 OnResourcesChanged(value);
416 if (_resources != null)
417 ((IResourceDictionary)_resources).ValuesChanged += OnResourcesChanged;
423 protected override void OnParentSet()
425 throw new InvalidOperationException("Setting a Parent on Application is invalid.");
428 [EditorBrowsable(EditorBrowsableState.Never)]
429 public static bool IsApplicationOrNull(Element element)
431 return element == null || element is Application;
434 internal override void OnParentResourcesChanged(IEnumerable<KeyValuePair<string, object>> values)
436 if (!((IResourcesProvider)this).IsResourcesCreated || XamlResources.Count == 0)
438 base.OnParentResourcesChanged(values);
442 var innerKeys = new HashSet<string>();
443 var changedResources = new List<KeyValuePair<string, object>>();
444 foreach (KeyValuePair<string, object> c in XamlResources)
445 innerKeys.Add(c.Key);
446 foreach (KeyValuePair<string, object> value in values)
448 if (innerKeys.Add(value.Key))
449 changedResources.Add(value);
451 OnResourcesChanged(changedResources);
454 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
456 internal Application(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Application_SWIGUpcast(cPtr), cMemoryOwn)
458 SetCurrentApplication(this);
460 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
465 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Application obj)
467 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
470 protected override void Dispose(DisposeTypes type)
477 //Release your own unmanaged resources here.
478 //You should not access any managed member here except static instance.
479 //because the execution order of Finalizes is non-deterministic.
481 if (_applicationInitEventCallbackDelegate != null)
483 this.InitSignal().Disconnect(_applicationInitEventCallbackDelegate);
486 if (_applicationTerminateEventCallbackDelegate != null)
488 this.TerminateSignal().Disconnect(_applicationTerminateEventCallbackDelegate);
491 if (_applicationPauseEventCallbackDelegate != null)
493 this.PauseSignal().Disconnect(_applicationPauseEventCallbackDelegate);
496 if (_applicationResumeEventCallbackDelegate != null)
498 this.ResumeSignal().Disconnect(_applicationResumeEventCallbackDelegate);
501 if (_applicationResetEventCallbackDelegate != null)
503 this.ResetSignal().Disconnect(_applicationResetEventCallbackDelegate);
506 if (_applicationResizeEventCallbackDelegate != null)
508 this.ResizeSignal().Disconnect(_applicationResizeEventCallbackDelegate);
511 if (_applicationLanguageChangedEventCallbackDelegate != null)
513 this.LanguageChangedSignal().Disconnect(_applicationLanguageChangedEventCallbackDelegate);
516 if (_applicationRegionChangedEventCallbackDelegate != null)
518 this.RegionChangedSignal().Disconnect(_applicationRegionChangedEventCallbackDelegate);
521 if (_applicationBatteryLowEventCallbackDelegate != null)
523 this.BatteryLowSignal().Disconnect(_applicationBatteryLowEventCallbackDelegate);
526 if (_applicationMemoryLowEventCallbackDelegate != null)
528 this.MemoryLowSignal().Disconnect(_applicationMemoryLowEventCallbackDelegate);
531 if (_applicationAppControlEventCallbackDelegate != null)
533 this.AppControlSignal().Disconnect(_applicationAppControlEventCallbackDelegate);
536 if (swigCPtr.Handle != global::System.IntPtr.Zero)
541 Interop.Application.delete_Application(swigCPtr);
543 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
549 /// <since_tizen> 4 </since_tizen>
550 public enum BatteryStatus
557 /// <since_tizen> 4 </since_tizen>
558 public enum MemoryStatus
565 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
566 private delegate void NUIApplicationInitEventCallbackDelegate(IntPtr application);
567 private DaliEventHandler<object, NUIApplicationInitEventArgs> _applicationInitEventHandler;
568 private NUIApplicationInitEventCallbackDelegate _applicationInitEventCallbackDelegate;
571 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
572 private delegate void NUIApplicationTerminateEventCallbackDelegate(IntPtr application);
573 private DaliEventHandler<object, NUIApplicationTerminatingEventArgs> _applicationTerminateEventHandler;
574 private NUIApplicationTerminateEventCallbackDelegate _applicationTerminateEventCallbackDelegate;
577 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
578 private delegate void NUIApplicationPauseEventCallbackDelegate(IntPtr application);
579 private DaliEventHandler<object, NUIApplicationPausedEventArgs> _applicationPauseEventHandler;
580 private NUIApplicationPauseEventCallbackDelegate _applicationPauseEventCallbackDelegate;
582 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
583 private delegate void NUIApplicationResumeEventCallbackDelegate(IntPtr application);
584 private DaliEventHandler<object, NUIApplicationResumedEventArgs> _applicationResumeEventHandler;
585 private NUIApplicationResumeEventCallbackDelegate _applicationResumeEventCallbackDelegate;
587 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
588 private delegate void NUIApplicationResetEventCallbackDelegate(IntPtr application);
589 private DaliEventHandler<object, NUIApplicationResetEventArgs> _applicationResetEventHandler;
590 private NUIApplicationResetEventCallbackDelegate _applicationResetEventCallbackDelegate;
592 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
593 private delegate void NUIApplicationResizeEventCallbackDelegate(IntPtr application);
594 private DaliEventHandler<object, NUIApplicationResizedEventArgs> _applicationResizeEventHandler;
595 private NUIApplicationResizeEventCallbackDelegate _applicationResizeEventCallbackDelegate;
597 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
598 private delegate void NUIApplicationLanguageChangedEventCallbackDelegate(IntPtr application);
599 private DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> _applicationLanguageChangedEventHandler;
600 private NUIApplicationLanguageChangedEventCallbackDelegate _applicationLanguageChangedEventCallbackDelegate;
603 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
604 private delegate void NUIApplicationRegionChangedEventCallbackDelegate(IntPtr application);
605 private DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> _applicationRegionChangedEventHandler;
606 private NUIApplicationRegionChangedEventCallbackDelegate _applicationRegionChangedEventCallbackDelegate;
608 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
609 private delegate void NUIApplicationBatteryLowEventCallbackDelegate(BatteryStatus status);
610 private DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> _applicationBatteryLowEventHandler;
611 private NUIApplicationBatteryLowEventCallbackDelegate _applicationBatteryLowEventCallbackDelegate;
613 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
614 private delegate void NUIApplicationMemoryLowEventCallbackDelegate(MemoryStatus status);
615 private DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> _applicationMemoryLowEventHandler;
616 private NUIApplicationMemoryLowEventCallbackDelegate _applicationMemoryLowEventCallbackDelegate;
618 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
619 private delegate void NUIApplicationAppControlEventCallbackDelegate(IntPtr application, IntPtr voidp);
620 private DaliEventHandler<object, NUIApplicationAppControlEventArgs> _applicationAppControlEventHandler;
621 private NUIApplicationAppControlEventCallbackDelegate _applicationAppControlEventCallbackDelegate;
624 * @brief Event for Initialized signal which can be used to subscribe/unsubscribe the event handler
625 * provided by the user. Initialized signal is emitted when application is initialised
627 public event DaliEventHandler<object, NUIApplicationInitEventArgs> Initialized
633 // Restricted to only one listener
634 if (_applicationInitEventHandler == null)
636 _applicationInitEventHandler += value;
638 _applicationInitEventCallbackDelegate = new NUIApplicationInitEventCallbackDelegate(OnApplicationInit);
639 this.InitSignal().Connect(_applicationInitEventCallbackDelegate);
648 if (_applicationInitEventHandler != null)
650 this.InitSignal().Disconnect(_applicationInitEventCallbackDelegate);
653 _applicationInitEventHandler -= value;
658 // Callback for Application InitSignal
659 private void OnApplicationInit(IntPtr data)
661 // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread.
662 DisposeQueue.Instance.Initialize();
664 if (_applicationInitEventHandler != null)
666 NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs();
667 e.Application = this;
668 _applicationInitEventHandler.Invoke(this, e);
674 * @brief Event for Terminated signal which can be used to subscribe/unsubscribe the event handler
675 * provided by the user. Terminated signal is emitted when application is terminating
677 public event DaliEventHandler<object, NUIApplicationTerminatingEventArgs> Terminating
683 // Restricted to only one listener
684 if (_applicationTerminateEventHandler == null)
686 _applicationTerminateEventHandler += value;
688 _applicationTerminateEventCallbackDelegate = new NUIApplicationTerminateEventCallbackDelegate(OnNUIApplicationTerminate);
689 this.TerminateSignal().Connect(_applicationTerminateEventCallbackDelegate);
698 if (_applicationTerminateEventHandler != null)
700 this.TerminateSignal().Disconnect(_applicationTerminateEventCallbackDelegate);
703 _applicationTerminateEventHandler -= value;
708 // Callback for Application TerminateSignal
709 private void OnNUIApplicationTerminate(IntPtr data)
711 if (_applicationTerminateEventHandler != null)
713 NUIApplicationTerminatingEventArgs e = new NUIApplicationTerminatingEventArgs();
714 e.Application = this;
715 _applicationTerminateEventHandler.Invoke(this, e);
719 Window.Instance.DisconnectNativeSignals();
724 * @brief Event for Paused signal which can be used to subscribe/unsubscribe the event handler
725 * provided by the user. Paused signal is emitted when application is paused
727 public event DaliEventHandler<object, NUIApplicationPausedEventArgs> Paused
733 // Restricted to only one listener
734 if (_applicationPauseEventHandler == null)
736 _applicationPauseEventHandler += value;
738 _applicationPauseEventCallbackDelegate = new NUIApplicationPauseEventCallbackDelegate(OnNUIApplicationPause);
739 this.PauseSignal().Connect(_applicationPauseEventCallbackDelegate);
748 if (_applicationPauseEventHandler != null)
750 this.PauseSignal().Disconnect(_applicationPauseEventCallbackDelegate);
753 _applicationPauseEventHandler -= value;
758 // Callback for Application PauseSignal
759 private void OnNUIApplicationPause(IntPtr data)
761 if (_applicationPauseEventHandler != null)
763 NUIApplicationPausedEventArgs e = new NUIApplicationPausedEventArgs();
764 e.Application = this;
765 _applicationPauseEventHandler.Invoke(this, e);
770 * @brief Event for Resumed signal which can be used to subscribe/unsubscribe the event handler
771 * provided by the user. Resumed signal is emitted when application is resumed
773 public event DaliEventHandler<object, NUIApplicationResumedEventArgs> Resumed
779 // Restricted to only one listener
780 if (_applicationResumeEventHandler == null)
782 _applicationResumeEventHandler += value;
784 _applicationResumeEventCallbackDelegate = new NUIApplicationResumeEventCallbackDelegate(OnNUIApplicationResume);
785 this.ResumeSignal().Connect(_applicationResumeEventCallbackDelegate);
794 if (_applicationResumeEventHandler != null)
796 this.ResumeSignal().Disconnect(_applicationResumeEventCallbackDelegate);
799 _applicationResumeEventHandler -= value;
804 // Callback for Application ResumeSignal
805 private void OnNUIApplicationResume(IntPtr data)
807 if (_applicationResumeEventHandler != null)
809 NUIApplicationResumedEventArgs e = new NUIApplicationResumedEventArgs();
810 e.Application = this;
811 _applicationResumeEventHandler.Invoke(this, e);
816 * @brief Event for Reset signal which can be used to subscribe/unsubscribe the event handler
817 * provided by the user. Reset signal is emitted when application is reset
819 public new event DaliEventHandler<object, NUIApplicationResetEventArgs> Reset
825 // Restricted to only one listener
826 if (_applicationResetEventHandler == null)
828 _applicationResetEventHandler += value;
830 _applicationResetEventCallbackDelegate = new NUIApplicationResetEventCallbackDelegate(OnNUIApplicationReset);
831 this.ResetSignal().Connect(_applicationResetEventCallbackDelegate);
840 if (_applicationResetEventHandler != null)
842 this.ResetSignal().Disconnect(_applicationResetEventCallbackDelegate);
845 _applicationResetEventHandler -= value;
850 // Callback for Application ResetSignal
851 private void OnNUIApplicationReset(IntPtr data)
853 if (_applicationResetEventHandler != null)
855 NUIApplicationResetEventArgs e = new NUIApplicationResetEventArgs();
856 e.Application = this;
857 _applicationResetEventHandler.Invoke(this, e);
862 * @brief Event for Resized signal which can be used to subscribe/unsubscribe the event handler
863 * provided by the user. Resized signal is emitted when application is resized
865 public event DaliEventHandler<object, NUIApplicationResizedEventArgs> Resized
871 // Restricted to only one listener
872 if (_applicationResizeEventHandler == null)
874 _applicationResizeEventHandler += value;
876 _applicationResizeEventCallbackDelegate = new NUIApplicationResizeEventCallbackDelegate(OnNUIApplicationResize);
877 this.ResizeSignal().Connect(_applicationResizeEventCallbackDelegate);
886 if (_applicationResizeEventHandler != null)
888 this.ResizeSignal().Disconnect(_applicationResizeEventCallbackDelegate);
891 _applicationResizeEventHandler -= value;
896 // Callback for Application ResizeSignal
897 private void OnNUIApplicationResize(IntPtr data)
899 if (_applicationResizeEventHandler != null)
901 NUIApplicationResizedEventArgs e = new NUIApplicationResizedEventArgs();
902 e.Application = this;
903 _applicationResizeEventHandler.Invoke(this, e);
908 * @brief Event for LanguageChanged signal which can be used to subscribe/unsubscribe the event handler
909 * provided by the user. LanguageChanged signal is emitted when the region of the device is changed.
911 public event DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> LanguageChanged
917 // Restricted to only one listener
918 if (_applicationLanguageChangedEventHandler == null)
920 _applicationLanguageChangedEventHandler += value;
922 _applicationLanguageChangedEventCallbackDelegate = new NUIApplicationLanguageChangedEventCallbackDelegate(OnNUIApplicationLanguageChanged);
923 this.LanguageChangedSignal().Connect(_applicationLanguageChangedEventCallbackDelegate);
932 if (_applicationLanguageChangedEventHandler != null)
934 this.LanguageChangedSignal().Disconnect(_applicationLanguageChangedEventCallbackDelegate);
937 _applicationLanguageChangedEventHandler -= value;
942 // Callback for Application LanguageChangedSignal
943 private void OnNUIApplicationLanguageChanged(IntPtr data)
945 if (_applicationLanguageChangedEventHandler != null)
947 NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs();
948 e.Application = this;
949 _applicationLanguageChangedEventHandler.Invoke(this, e);
954 * @brief Event for RegionChanged signal which can be used to subscribe/unsubscribe the event handler
955 * provided by the user. RegionChanged signal is emitted when the region of the device is changed.
957 public event DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> RegionChanged
963 // Restricted to only one listener
964 if (_applicationRegionChangedEventHandler == null)
966 _applicationRegionChangedEventHandler += value;
968 _applicationRegionChangedEventCallbackDelegate = new NUIApplicationRegionChangedEventCallbackDelegate(OnNUIApplicationRegionChanged);
969 this.RegionChangedSignal().Connect(_applicationRegionChangedEventCallbackDelegate);
978 if (_applicationRegionChangedEventHandler != null)
980 this.RegionChangedSignal().Disconnect(_applicationRegionChangedEventCallbackDelegate);
983 _applicationRegionChangedEventHandler -= value;
988 // Callback for Application RegionChangedSignal
989 private void OnNUIApplicationRegionChanged(IntPtr data)
991 if (_applicationRegionChangedEventHandler != null)
993 NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs();
994 e.Application = this;
995 _applicationRegionChangedEventHandler.Invoke(this, e);
1000 * @brief Event for BatteryLow signal which can be used to subscribe/unsubscribe the event handler
1001 * provided by the user. BatteryLow signal is emitted when the battery level of the device is low.
1003 public event DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> BatteryLow
1009 // Restricted to only one listener
1010 if (_applicationBatteryLowEventHandler == null)
1012 _applicationBatteryLowEventHandler += value;
1014 _applicationBatteryLowEventCallbackDelegate = new NUIApplicationBatteryLowEventCallbackDelegate(OnNUIApplicationBatteryLow);
1015 this.BatteryLowSignal().Connect(_applicationBatteryLowEventCallbackDelegate);
1024 if (_applicationBatteryLowEventHandler != null)
1026 this.BatteryLowSignal().Disconnect(_applicationBatteryLowEventCallbackDelegate);
1029 _applicationBatteryLowEventHandler -= value;
1034 // Callback for Application BatteryLowSignal
1035 private void OnNUIApplicationBatteryLow(BatteryStatus status)
1039 NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
1041 // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
1042 e.BatteryStatus = status;
1043 _applicationBatteryLowEventHandler?.Invoke(this, e);
1048 * @brief Event for MemoryLow signal which can be used to subscribe/unsubscribe the event handler
1049 * provided by the user. MemoryLow signal is emitted when the memory level of the device is low.
1051 public event DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> MemoryLow
1057 // Restricted to only one listener
1058 if (_applicationMemoryLowEventHandler == null)
1060 _applicationMemoryLowEventHandler += value;
1062 _applicationMemoryLowEventCallbackDelegate = new NUIApplicationMemoryLowEventCallbackDelegate(OnNUIApplicationMemoryLow);
1063 this.MemoryLowSignal().Connect(_applicationMemoryLowEventCallbackDelegate);
1072 if (_applicationMemoryLowEventHandler != null)
1074 this.MemoryLowSignal().Disconnect(_applicationMemoryLowEventCallbackDelegate);
1077 _applicationMemoryLowEventHandler -= value;
1082 // Callback for Application MemoryLowSignal
1083 private void OnNUIApplicationMemoryLow(MemoryStatus status)
1087 NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
1089 // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
1090 e.MemoryStatus = status;
1091 _applicationMemoryLowEventHandler?.Invoke(this, e);
1096 * @brief Event for AppControl signal which can be used to subscribe/unsubscribe the event handler
1097 * provided by the user. AppControl signal is emitted when another application sends a launch request to the application.
1099 public event DaliEventHandler<object, NUIApplicationAppControlEventArgs> AppControl
1105 // Restricted to only one listener
1106 if (_applicationAppControlEventHandler == null)
1108 _applicationAppControlEventHandler += value;
1110 _applicationAppControlEventCallbackDelegate = new NUIApplicationAppControlEventCallbackDelegate(OnNUIApplicationAppControl);
1111 this.AppControlSignal().Connect(_applicationAppControlEventCallbackDelegate);
1120 if (_applicationAppControlEventHandler != null)
1122 this.AppControlSignal().Disconnect(_applicationAppControlEventCallbackDelegate);
1125 _applicationAppControlEventHandler -= value;
1130 // Callback for Application AppControlSignal
1131 private void OnNUIApplicationAppControl(IntPtr application, IntPtr voidp)
1133 if (_applicationAppControlEventHandler != null)
1135 NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs();
1137 e.Application = this;
1138 _applicationAppControlEventHandler.Invoke(this, e);
1142 private static Application _instance; // singleton
1144 public static Application Instance
1152 public static Application GetApplicationFromPtr(global::System.IntPtr cPtr)
1154 if (cPtr == global::System.IntPtr.Zero)
1159 Application ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Application;
1160 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1164 public static Application NewApplication()
1166 return NewApplication("", Application.WindowMode.Opaque);
1169 public static Application NewApplication(string stylesheet)
1171 return NewApplication(stylesheet, Application.WindowMode.Opaque);
1174 public static Application NewApplication(string stylesheet, Application.WindowMode windowMode)
1176 // register all Views with the type registry, so that can be created / styled via JSON
1177 //ViewRegistryHelper.Initialize(); //moved to Application side.
1179 Application ret = New(1, stylesheet, windowMode);
1180 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1182 // set the singleton
1187 public static Application NewApplication(string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1189 Application ret = New(1, stylesheet, windowMode, positionSize);
1190 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1192 // set the singleton
1197 public static Application NewApplication(string[] args, string stylesheet, Application.WindowMode windowMode)
1199 Application ret = New(args, stylesheet, (Application.WindowMode)windowMode);
1200 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1202 // set the singleton
1207 public static Application NewApplication(string[] args, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1209 Application ret = New(args, stylesheet, (Application.WindowMode)windowMode, positionSize);
1210 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1212 // set the singleton
1218 /// Ensures that the function passed in is called from the main loop when it is idle.
1220 /// <param name="func">The function to call</param>
1221 /// <returns>true if added successfully, false otherwise</returns>
1222 public bool AddIdle(System.Delegate func)
1224 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
1225 System.IntPtr ip2 = Interop.Application.MakeCallback(new System.Runtime.InteropServices.HandleRef(this, ip));
1227 bool ret = Interop.Application.Application_AddIdle(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip2));
1229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1234 * Outer::outer_method(int)
1236 public static Application New()
1238 Application ret = new Application(Interop.Application.Application_New__SWIG_0(), true);
1239 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1243 public static Application New(int argc)
1245 Application ret = new Application(Interop.Application.Application_New__SWIG_1(argc), true);
1246 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1250 public static Application New(int argc, string stylesheet)
1252 Application ret = new Application(Interop.Application.Application_New__SWIG_2(argc, stylesheet), true);
1253 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1257 public static Application New(int argc, string stylesheet, Application.WindowMode windowMode)
1259 Application ret = new Application(Interop.Application.Application_New__SWIG_3(argc, stylesheet, (int)windowMode), true);
1260 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1265 public static Application New(string[] args, string stylesheet, Application.WindowMode windowMode)
1267 int argc = args.Length;
1268 string argvStr = string.Join(" ", args);
1270 Application ret = new Application(NDalicPINVOKE.Application_New__MANUAL_4(argc, argvStr, stylesheet, (int)windowMode), true);
1272 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1277 public static Application New(int argc, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1279 Application ret = new Application(Interop.Application.Application_New__SWIG_4(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1280 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1284 public static Application New(string[] args, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1286 int argc = args.Length;
1287 string argvStr = string.Join(" ", args);
1289 Application ret = new Application(NDalicPINVOKE.Application_New_WithWindowSizePosition(argc, argvStr, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1290 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1294 public Application() : this(Interop.Application.new_Application__SWIG_0(), true)
1296 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1299 public Application(Application application) : this(Interop.Application.new_Application__SWIG_1(Application.getCPtr(application)), true)
1301 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1304 public Application Assign(Application application)
1306 Application ret = new Application(Interop.Application.Application_Assign(swigCPtr, Application.getCPtr(application)), false);
1307 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1311 public void MainLoop()
1313 NDalicPINVOKE.Application_MainLoop__SWIG_0(swigCPtr);
1314 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1317 internal void MainLoop(SWIGTYPE_p_Configuration__ContextLoss configuration)
1319 Interop.Application.Application_MainLoop__SWIG_1(swigCPtr, SWIGTYPE_p_Configuration__ContextLoss.getCPtr(configuration));
1320 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1325 Interop.Application.Application_Lower(swigCPtr);
1326 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1331 Interop.Application.Application_Quit(swigCPtr);
1332 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1335 internal bool AddIdle(SWIGTYPE_p_Dali__CallbackBase callback)
1337 bool ret = Interop.Application.Application_AddIdle(swigCPtr, SWIGTYPE_p_Dali__CallbackBase.getCPtr(callback));
1338 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1342 public Window GetWindow()
1344 Window ret = new Window(Interop.Application.Application_GetWindow(swigCPtr), true);
1345 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1349 public void ReplaceWindow(Rectangle windowPosition, string name)
1351 Interop.Application.Application_ReplaceWindow(swigCPtr, Rectangle.getCPtr(windowPosition), name);
1352 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1355 public static string GetResourcePath()
1357 string ret = Interop.Application.Application_GetResourcePath();
1358 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1362 public string GetLanguage()
1364 string ret = Interop.Application.Application_GetLanguage(swigCPtr);
1365 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1369 public string GetRegion()
1371 string ret = Interop.Application.Application_GetRegion(swigCPtr);
1372 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1376 internal static List<Window> GetWindowList()
1378 uint ListSize = Interop.Application.Application_GetWindowsListSize();
1379 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1381 List<Window> WindowList = new List<Window>();
1382 for( uint i = 0; i < ListSize; ++i )
1384 Window currWin = Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.Application_GetWindowsFromList(i)) as Window;
1385 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1388 WindowList.Add(currWin);
1394 internal ApplicationSignal InitSignal()
1396 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_InitSignal(swigCPtr), false);
1397 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1401 internal ApplicationSignal TerminateSignal()
1403 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_TerminateSignal(swigCPtr), false);
1404 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1408 internal ApplicationSignal PauseSignal()
1410 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_PauseSignal(swigCPtr), false);
1411 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1415 internal ApplicationSignal ResumeSignal()
1417 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_ResumeSignal(swigCPtr), false);
1418 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1422 internal ApplicationSignal ResetSignal()
1424 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_ResetSignal(swigCPtr), false);
1425 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1429 internal ApplicationSignal ResizeSignal()
1431 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_ResizeSignal(swigCPtr), false);
1432 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1436 internal ApplicationControlSignal AppControlSignal()
1438 ApplicationControlSignal ret = new ApplicationControlSignal(NDalicPINVOKE.Application_AppControlSignal(swigCPtr), false);
1439 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1443 internal ApplicationSignal LanguageChangedSignal()
1445 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_LanguageChangedSignal(swigCPtr), false);
1446 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1450 internal ApplicationSignal RegionChangedSignal()
1452 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_RegionChangedSignal(swigCPtr), false);
1453 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1457 internal LowBatterySignalType BatteryLowSignal()
1459 LowBatterySignalType ret = new LowBatterySignalType(NDalicPINVOKE.Application_LowBatterySignal(swigCPtr), false);
1460 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1464 internal LowMemorySignalType MemoryLowSignal()
1466 LowMemorySignalType ret = new LowMemorySignalType(NDalicPINVOKE.Application_LowMemorySignal(swigCPtr), false);
1467 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1471 /// <since_tizen> 3 </since_tizen>
1472 public enum WindowMode