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.
22 using System.Collections.Generic;
23 using System.Collections.ObjectModel;
24 using System.ComponentModel;
25 using System.Runtime.InteropServices;
26 using System.Threading;
27 using System.Threading.Tasks;
28 using Tizen.NUI.Binding;
29 using Tizen.NUI.Binding.Internals;
32 * @brief Event arguments that passed via NUIApplicationInit signal
35 internal class NUIApplicationInitEventArgs : EventArgs
37 private Application _application;
40 * @brief Application - is the application that is being initialized
43 public Application Application
57 * @brief Event arguments that passed via NUIApplicationTerminate signal
60 internal class NUIApplicationTerminatingEventArgs : EventArgs
62 private Application _application;
64 * @brief Application - is the application that is being Terminated
67 public Application Application
81 * @brief Event arguments that passed via NUIApplicationPause signal
84 internal class NUIApplicationPausedEventArgs : EventArgs
86 private Application _application;
88 * @brief Application - is the application that is being Paused
91 public Application Application
105 * @brief Event arguments that passed via NUIApplicationResume signal
108 internal class NUIApplicationResumedEventArgs : EventArgs
110 private Application _application;
112 * @brief Application - is the application that is being Resumed
115 public Application Application
123 _application = value;
129 * @brief Event arguments that passed via NUIApplicationReset signal
132 internal class NUIApplicationResetEventArgs : EventArgs
134 private Application _application;
136 * @brief Application - is the application that is being Reset
139 public Application Application
147 _application = value;
153 * @brief Event arguments that passed via NUIApplicationResize signal
156 internal class NUIApplicationResizedEventArgs : EventArgs
158 private Application _application;
160 * @brief Application - is the application that is being Resized
163 public Application Application
171 _application = value;
177 * @brief Event arguments that passed via NUIApplicationLanguageChanged signal
180 internal class NUIApplicationLanguageChangedEventArgs : EventArgs
182 private Application _application;
184 * @brief Application - is the application that is being affected with Device's language change
187 public Application Application
195 _application = value;
201 * @brief Event arguments that passed via NUIApplicationRegionChanged signal
204 internal class NUIApplicationRegionChangedEventArgs : EventArgs
206 private Application _application;
208 * @brief Application - is the application that is being affected with Device's region change
211 public Application Application
219 _application = value;
225 * @brief Event arguments that passed via NUIApplicationBatteryLow signal
228 internal class NUIApplicationBatteryLowEventArgs : EventArgs
230 private Application.BatteryStatus _status;
232 * @brief Application - is the application that is being affected when the battery level of the device is low
235 public Application.BatteryStatus BatteryStatus
249 * @brief Event arguments that passed via NUIApplicationMemoryLow signal
252 internal class NUIApplicationMemoryLowEventArgs : EventArgs
254 private Application.MemoryStatus _status;
256 * @brief Application - is the application that is being affected when the memory level of the device is low
259 public Application.MemoryStatus MemoryStatus
273 * @brief Event arguments that passed via NUIApplicationAppControl signal
276 internal class NUIApplicationAppControlEventArgs : EventArgs
278 private Application _application;
279 private IntPtr _voidp;
281 * @brief Application - is the application that is receiving the launch request from another application
284 public Application Application
292 _application = value;
296 * @brief VoidP - contains the information about why the application is launched
313 /// A class to get resources in current application.
315 public class GetResourcesProvider
318 /// Get resources in current application.
320 static public IResourcesProvider Get()
322 return Tizen.NUI.Application.Current;
326 internal class Application : BaseHandle, IResourcesProvider, IElementConfiguration<Application>
329 static Application s_current;
331 ReadOnlyCollection<Element> _logicalChildren;
333 static SemaphoreSlim SaveSemaphore = new SemaphoreSlim(1, 1);
335 [EditorBrowsable(EditorBrowsableState.Never)]
336 public static void SetCurrentApplication(Application value) => Current = value;
338 public static Application Current
340 get { return s_current; }
343 if (s_current == value)
346 s_current = null; //Allow to reset current for unittesting
351 internal override ReadOnlyCollection<Element> LogicalChildrenInternal
353 get { return _logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(InternalChildren)); }
356 internal IResourceDictionary SystemResources { get; }
358 ObservableCollection<Element> InternalChildren { get; } = new ObservableCollection<Element>();
360 ResourceDictionary _resources;
361 public bool IsResourcesCreated => _resources != null;
363 public delegate void resChangeCb(object sender, ResourcesChangedEventArgs e);
365 static private Dictionary<object, Dictionary<resChangeCb, int>> resourceChangeCallbackDict = new Dictionary<object, Dictionary<resChangeCb, int>>();
366 static public void AddResourceChangedCallback(object handle, resChangeCb cb)
368 Dictionary<resChangeCb, int> cbDict;
369 resourceChangeCallbackDict.TryGetValue(handle, out cbDict);
373 cbDict = new Dictionary<resChangeCb, int>();
374 resourceChangeCallbackDict.Add(handle, cbDict);
377 if (false == cbDict.ContainsKey(cb))
383 internal override void OnResourcesChanged(object sender, ResourcesChangedEventArgs e)
385 base.OnResourcesChanged(sender, e);
387 foreach (KeyValuePair<object, Dictionary<resChangeCb, int>> resourcePair in resourceChangeCallbackDict)
389 foreach (KeyValuePair<resChangeCb, int> cbPair in resourcePair.Value)
391 cbPair.Key(sender, e);
396 public ResourceDictionary XamlResources
400 if (_resources != null)
403 _resources = new ResourceDictionary();
404 int hashCode = _resources.GetHashCode();
405 ((IResourceDictionary)_resources).ValuesChanged += OnResourcesChanged;
410 if (_resources == value)
412 OnPropertyChanging();
414 if (_resources != null)
415 ((IResourceDictionary)_resources).ValuesChanged -= OnResourcesChanged;
417 OnResourcesChanged(value);
418 if (_resources != null)
419 ((IResourceDictionary)_resources).ValuesChanged += OnResourcesChanged;
425 protected override void OnParentSet()
427 throw new InvalidOperationException("Setting a Parent on Application is invalid.");
430 [EditorBrowsable(EditorBrowsableState.Never)]
431 public static bool IsApplicationOrNull(Element element)
433 return element == null || element is Application;
436 internal override void OnParentResourcesChanged(IEnumerable<KeyValuePair<string, object>> values)
438 if (!((IResourcesProvider)this).IsResourcesCreated || XamlResources.Count == 0)
440 base.OnParentResourcesChanged(values);
444 var innerKeys = new HashSet<string>();
445 var changedResources = new List<KeyValuePair<string, object>>();
446 foreach (KeyValuePair<string, object> c in XamlResources)
447 innerKeys.Add(c.Key);
448 foreach (KeyValuePair<string, object> value in values)
450 if (innerKeys.Add(value.Key))
451 changedResources.Add(value);
453 OnResourcesChanged(changedResources);
456 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
458 internal Application(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Application_SWIGUpcast(cPtr), cMemoryOwn)
460 SetCurrentApplication(this);
462 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
467 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Application obj)
469 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
472 protected override void Dispose(DisposeTypes type)
479 if (type == DisposeTypes.Explicit)
482 //Release your own managed resources here.
483 //You should release all of your own disposable objects here.
487 //Release your own unmanaged resources here.
488 //You should not access any managed member here except static instance.
489 //because the execution order of Finalizes is non-deterministic.
491 if (_applicationInitEventCallbackDelegate != null)
493 this.InitSignal().Disconnect(_applicationInitEventCallbackDelegate);
496 if (_applicationTerminateEventCallbackDelegate != null)
498 this.TerminateSignal().Disconnect(_applicationTerminateEventCallbackDelegate);
501 if (_applicationPauseEventCallbackDelegate != null)
503 this.PauseSignal().Disconnect(_applicationPauseEventCallbackDelegate);
506 if (_applicationResumeEventCallbackDelegate != null)
508 this.ResumeSignal().Disconnect(_applicationResumeEventCallbackDelegate);
511 if (_applicationResetEventCallbackDelegate != null)
513 this.ResetSignal().Disconnect(_applicationResetEventCallbackDelegate);
516 if (_applicationResizeEventCallbackDelegate != null)
518 this.ResizeSignal().Disconnect(_applicationResizeEventCallbackDelegate);
521 if (_applicationLanguageChangedEventCallbackDelegate != null)
523 this.LanguageChangedSignal().Disconnect(_applicationLanguageChangedEventCallbackDelegate);
526 if (_applicationRegionChangedEventCallbackDelegate != null)
528 this.RegionChangedSignal().Disconnect(_applicationRegionChangedEventCallbackDelegate);
531 if (_applicationBatteryLowEventCallbackDelegate != null)
533 this.BatteryLowSignal().Disconnect(_applicationBatteryLowEventCallbackDelegate);
536 if (_applicationMemoryLowEventCallbackDelegate != null)
538 this.MemoryLowSignal().Disconnect(_applicationMemoryLowEventCallbackDelegate);
541 if (_applicationAppControlEventCallbackDelegate != null)
543 this.AppControlSignal().Disconnect(_applicationAppControlEventCallbackDelegate);
546 if (swigCPtr.Handle != global::System.IntPtr.Zero)
551 Interop.Application.delete_Application(swigCPtr);
553 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
559 /// <since_tizen> 4 </since_tizen>
560 public enum BatteryStatus
567 /// <since_tizen> 4 </since_tizen>
568 public enum MemoryStatus
575 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
576 private delegate void NUIApplicationInitEventCallbackDelegate(IntPtr application);
577 private DaliEventHandler<object, NUIApplicationInitEventArgs> _applicationInitEventHandler;
578 private NUIApplicationInitEventCallbackDelegate _applicationInitEventCallbackDelegate;
581 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
582 private delegate void NUIApplicationTerminateEventCallbackDelegate(IntPtr application);
583 private DaliEventHandler<object, NUIApplicationTerminatingEventArgs> _applicationTerminateEventHandler;
584 private NUIApplicationTerminateEventCallbackDelegate _applicationTerminateEventCallbackDelegate;
587 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
588 private delegate void NUIApplicationPauseEventCallbackDelegate(IntPtr application);
589 private DaliEventHandler<object, NUIApplicationPausedEventArgs> _applicationPauseEventHandler;
590 private NUIApplicationPauseEventCallbackDelegate _applicationPauseEventCallbackDelegate;
592 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
593 private delegate void NUIApplicationResumeEventCallbackDelegate(IntPtr application);
594 private DaliEventHandler<object, NUIApplicationResumedEventArgs> _applicationResumeEventHandler;
595 private NUIApplicationResumeEventCallbackDelegate _applicationResumeEventCallbackDelegate;
597 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
598 private delegate void NUIApplicationResetEventCallbackDelegate(IntPtr application);
599 private DaliEventHandler<object, NUIApplicationResetEventArgs> _applicationResetEventHandler;
600 private NUIApplicationResetEventCallbackDelegate _applicationResetEventCallbackDelegate;
602 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
603 private delegate void NUIApplicationResizeEventCallbackDelegate(IntPtr application);
604 private DaliEventHandler<object, NUIApplicationResizedEventArgs> _applicationResizeEventHandler;
605 private NUIApplicationResizeEventCallbackDelegate _applicationResizeEventCallbackDelegate;
607 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
608 private delegate void NUIApplicationLanguageChangedEventCallbackDelegate(IntPtr application);
609 private DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> _applicationLanguageChangedEventHandler;
610 private NUIApplicationLanguageChangedEventCallbackDelegate _applicationLanguageChangedEventCallbackDelegate;
613 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
614 private delegate void NUIApplicationRegionChangedEventCallbackDelegate(IntPtr application);
615 private DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> _applicationRegionChangedEventHandler;
616 private NUIApplicationRegionChangedEventCallbackDelegate _applicationRegionChangedEventCallbackDelegate;
618 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
619 private delegate void NUIApplicationBatteryLowEventCallbackDelegate(BatteryStatus status);
620 private DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> _applicationBatteryLowEventHandler;
621 private NUIApplicationBatteryLowEventCallbackDelegate _applicationBatteryLowEventCallbackDelegate;
623 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
624 private delegate void NUIApplicationMemoryLowEventCallbackDelegate(MemoryStatus status);
625 private DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> _applicationMemoryLowEventHandler;
626 private NUIApplicationMemoryLowEventCallbackDelegate _applicationMemoryLowEventCallbackDelegate;
628 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
629 private delegate void NUIApplicationAppControlEventCallbackDelegate(IntPtr application, IntPtr voidp);
630 private DaliEventHandler<object, NUIApplicationAppControlEventArgs> _applicationAppControlEventHandler;
631 private NUIApplicationAppControlEventCallbackDelegate _applicationAppControlEventCallbackDelegate;
634 * @brief Event for Initialized signal which can be used to subscribe/unsubscribe the event handler
635 * provided by the user. Initialized signal is emitted when application is initialised
637 public event DaliEventHandler<object, NUIApplicationInitEventArgs> Initialized
643 // Restricted to only one listener
644 if (_applicationInitEventHandler == null)
646 _applicationInitEventHandler += value;
648 _applicationInitEventCallbackDelegate = new NUIApplicationInitEventCallbackDelegate(OnApplicationInit);
649 this.InitSignal().Connect(_applicationInitEventCallbackDelegate);
658 if (_applicationInitEventHandler != null)
660 this.InitSignal().Disconnect(_applicationInitEventCallbackDelegate);
663 _applicationInitEventHandler -= value;
668 // Callback for Application InitSignal
669 private void OnApplicationInit(IntPtr data)
671 // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread.
672 DisposeQueue.Instance.Initialize();
674 if (_applicationInitEventHandler != null)
676 NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs();
677 e.Application = this;
678 _applicationInitEventHandler.Invoke(this, e);
684 * @brief Event for Terminated signal which can be used to subscribe/unsubscribe the event handler
685 * provided by the user. Terminated signal is emitted when application is terminating
687 public event DaliEventHandler<object, NUIApplicationTerminatingEventArgs> Terminating
693 // Restricted to only one listener
694 if (_applicationTerminateEventHandler == null)
696 _applicationTerminateEventHandler += value;
698 _applicationTerminateEventCallbackDelegate = new NUIApplicationTerminateEventCallbackDelegate(OnNUIApplicationTerminate);
699 this.TerminateSignal().Connect(_applicationTerminateEventCallbackDelegate);
708 if (_applicationTerminateEventHandler != null)
710 this.TerminateSignal().Disconnect(_applicationTerminateEventCallbackDelegate);
713 _applicationTerminateEventHandler -= value;
718 // Callback for Application TerminateSignal
719 private void OnNUIApplicationTerminate(IntPtr data)
721 if (_applicationTerminateEventHandler != null)
723 NUIApplicationTerminatingEventArgs e = new NUIApplicationTerminatingEventArgs();
724 e.Application = this;
725 _applicationTerminateEventHandler.Invoke(this, e);
729 Window.Instance.DisconnectNativeSignals();
734 * @brief Event for Paused signal which can be used to subscribe/unsubscribe the event handler
735 * provided by the user. Paused signal is emitted when application is paused
737 public event DaliEventHandler<object, NUIApplicationPausedEventArgs> Paused
743 // Restricted to only one listener
744 if (_applicationPauseEventHandler == null)
746 _applicationPauseEventHandler += value;
748 _applicationPauseEventCallbackDelegate = new NUIApplicationPauseEventCallbackDelegate(OnNUIApplicationPause);
749 this.PauseSignal().Connect(_applicationPauseEventCallbackDelegate);
758 if (_applicationPauseEventHandler != null)
760 this.PauseSignal().Disconnect(_applicationPauseEventCallbackDelegate);
763 _applicationPauseEventHandler -= value;
768 // Callback for Application PauseSignal
769 private void OnNUIApplicationPause(IntPtr data)
771 if (_applicationPauseEventHandler != null)
773 NUIApplicationPausedEventArgs e = new NUIApplicationPausedEventArgs();
774 e.Application = this;
775 _applicationPauseEventHandler.Invoke(this, e);
780 * @brief Event for Resumed signal which can be used to subscribe/unsubscribe the event handler
781 * provided by the user. Resumed signal is emitted when application is resumed
783 public event DaliEventHandler<object, NUIApplicationResumedEventArgs> Resumed
789 // Restricted to only one listener
790 if (_applicationResumeEventHandler == null)
792 _applicationResumeEventHandler += value;
794 _applicationResumeEventCallbackDelegate = new NUIApplicationResumeEventCallbackDelegate(OnNUIApplicationResume);
795 this.ResumeSignal().Connect(_applicationResumeEventCallbackDelegate);
804 if (_applicationResumeEventHandler != null)
806 this.ResumeSignal().Disconnect(_applicationResumeEventCallbackDelegate);
809 _applicationResumeEventHandler -= value;
814 // Callback for Application ResumeSignal
815 private void OnNUIApplicationResume(IntPtr data)
817 if (_applicationResumeEventHandler != null)
819 NUIApplicationResumedEventArgs e = new NUIApplicationResumedEventArgs();
820 e.Application = this;
821 _applicationResumeEventHandler.Invoke(this, e);
826 * @brief Event for Reset signal which can be used to subscribe/unsubscribe the event handler
827 * provided by the user. Reset signal is emitted when application is reset
829 public new event DaliEventHandler<object, NUIApplicationResetEventArgs> Reset
835 // Restricted to only one listener
836 if (_applicationResetEventHandler == null)
838 _applicationResetEventHandler += value;
840 _applicationResetEventCallbackDelegate = new NUIApplicationResetEventCallbackDelegate(OnNUIApplicationReset);
841 this.ResetSignal().Connect(_applicationResetEventCallbackDelegate);
850 if (_applicationResetEventHandler != null)
852 this.ResetSignal().Disconnect(_applicationResetEventCallbackDelegate);
855 _applicationResetEventHandler -= value;
860 // Callback for Application ResetSignal
861 private void OnNUIApplicationReset(IntPtr data)
863 if (_applicationResetEventHandler != null)
865 NUIApplicationResetEventArgs e = new NUIApplicationResetEventArgs();
866 e.Application = this;
867 _applicationResetEventHandler.Invoke(this, e);
872 * @brief Event for Resized signal which can be used to subscribe/unsubscribe the event handler
873 * provided by the user. Resized signal is emitted when application is resized
875 public event DaliEventHandler<object, NUIApplicationResizedEventArgs> Resized
881 // Restricted to only one listener
882 if (_applicationResizeEventHandler == null)
884 _applicationResizeEventHandler += value;
886 _applicationResizeEventCallbackDelegate = new NUIApplicationResizeEventCallbackDelegate(OnNUIApplicationResize);
887 this.ResizeSignal().Connect(_applicationResizeEventCallbackDelegate);
896 if (_applicationResizeEventHandler != null)
898 this.ResizeSignal().Disconnect(_applicationResizeEventCallbackDelegate);
901 _applicationResizeEventHandler -= value;
906 // Callback for Application ResizeSignal
907 private void OnNUIApplicationResize(IntPtr data)
909 if (_applicationResizeEventHandler != null)
911 NUIApplicationResizedEventArgs e = new NUIApplicationResizedEventArgs();
912 e.Application = this;
913 _applicationResizeEventHandler.Invoke(this, e);
918 * @brief Event for LanguageChanged signal which can be used to subscribe/unsubscribe the event handler
919 * provided by the user. LanguageChanged signal is emitted when the region of the device is changed.
921 public event DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> LanguageChanged
927 // Restricted to only one listener
928 if (_applicationLanguageChangedEventHandler == null)
930 _applicationLanguageChangedEventHandler += value;
932 _applicationLanguageChangedEventCallbackDelegate = new NUIApplicationLanguageChangedEventCallbackDelegate(OnNUIApplicationLanguageChanged);
933 this.LanguageChangedSignal().Connect(_applicationLanguageChangedEventCallbackDelegate);
942 if (_applicationLanguageChangedEventHandler != null)
944 this.LanguageChangedSignal().Disconnect(_applicationLanguageChangedEventCallbackDelegate);
947 _applicationLanguageChangedEventHandler -= value;
952 // Callback for Application LanguageChangedSignal
953 private void OnNUIApplicationLanguageChanged(IntPtr data)
955 if (_applicationLanguageChangedEventHandler != null)
957 NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs();
958 e.Application = this;
959 _applicationLanguageChangedEventHandler.Invoke(this, e);
964 * @brief Event for RegionChanged signal which can be used to subscribe/unsubscribe the event handler
965 * provided by the user. RegionChanged signal is emitted when the region of the device is changed.
967 public event DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> RegionChanged
973 // Restricted to only one listener
974 if (_applicationRegionChangedEventHandler == null)
976 _applicationRegionChangedEventHandler += value;
978 _applicationRegionChangedEventCallbackDelegate = new NUIApplicationRegionChangedEventCallbackDelegate(OnNUIApplicationRegionChanged);
979 this.RegionChangedSignal().Connect(_applicationRegionChangedEventCallbackDelegate);
988 if (_applicationRegionChangedEventHandler != null)
990 this.RegionChangedSignal().Disconnect(_applicationRegionChangedEventCallbackDelegate);
993 _applicationRegionChangedEventHandler -= value;
998 // Callback for Application RegionChangedSignal
999 private void OnNUIApplicationRegionChanged(IntPtr data)
1001 if (_applicationRegionChangedEventHandler != null)
1003 NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs();
1004 e.Application = this;
1005 _applicationRegionChangedEventHandler.Invoke(this, e);
1010 * @brief Event for BatteryLow signal which can be used to subscribe/unsubscribe the event handler
1011 * provided by the user. BatteryLow signal is emitted when the battery level of the device is low.
1013 public event DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> BatteryLow
1019 // Restricted to only one listener
1020 if (_applicationBatteryLowEventHandler == null)
1022 _applicationBatteryLowEventHandler += value;
1024 _applicationBatteryLowEventCallbackDelegate = new NUIApplicationBatteryLowEventCallbackDelegate(OnNUIApplicationBatteryLow);
1025 this.BatteryLowSignal().Connect(_applicationBatteryLowEventCallbackDelegate);
1034 if (_applicationBatteryLowEventHandler != null)
1036 this.BatteryLowSignal().Disconnect(_applicationBatteryLowEventCallbackDelegate);
1039 _applicationBatteryLowEventHandler -= value;
1044 // Callback for Application BatteryLowSignal
1045 private void OnNUIApplicationBatteryLow(BatteryStatus status)
1049 NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
1051 // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
1052 e.BatteryStatus = status;
1053 _applicationBatteryLowEventHandler?.Invoke(this, e);
1058 * @brief Event for MemoryLow signal which can be used to subscribe/unsubscribe the event handler
1059 * provided by the user. MemoryLow signal is emitted when the memory level of the device is low.
1061 public event DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> MemoryLow
1067 // Restricted to only one listener
1068 if (_applicationMemoryLowEventHandler == null)
1070 _applicationMemoryLowEventHandler += value;
1072 _applicationMemoryLowEventCallbackDelegate = new NUIApplicationMemoryLowEventCallbackDelegate(OnNUIApplicationMemoryLow);
1073 this.MemoryLowSignal().Connect(_applicationMemoryLowEventCallbackDelegate);
1082 if (_applicationMemoryLowEventHandler != null)
1084 this.MemoryLowSignal().Disconnect(_applicationMemoryLowEventCallbackDelegate);
1087 _applicationMemoryLowEventHandler -= value;
1092 // Callback for Application MemoryLowSignal
1093 private void OnNUIApplicationMemoryLow(MemoryStatus status)
1097 NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
1099 // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
1100 e.MemoryStatus = status;
1101 _applicationMemoryLowEventHandler?.Invoke(this, e);
1106 * @brief Event for AppControl signal which can be used to subscribe/unsubscribe the event handler
1107 * provided by the user. AppControl signal is emitted when another application sends a launch request to the application.
1109 public event DaliEventHandler<object, NUIApplicationAppControlEventArgs> AppControl
1115 // Restricted to only one listener
1116 if (_applicationAppControlEventHandler == null)
1118 _applicationAppControlEventHandler += value;
1120 _applicationAppControlEventCallbackDelegate = new NUIApplicationAppControlEventCallbackDelegate(OnNUIApplicationAppControl);
1121 this.AppControlSignal().Connect(_applicationAppControlEventCallbackDelegate);
1130 if (_applicationAppControlEventHandler != null)
1132 this.AppControlSignal().Disconnect(_applicationAppControlEventCallbackDelegate);
1135 _applicationAppControlEventHandler -= value;
1140 // Callback for Application AppControlSignal
1141 private void OnNUIApplicationAppControl(IntPtr application, IntPtr voidp)
1143 if (_applicationAppControlEventHandler != null)
1145 NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs();
1147 e.Application = this;
1148 _applicationAppControlEventHandler.Invoke(this, e);
1152 private static Application _instance; // singleton
1154 public static Application Instance
1162 public static Application GetApplicationFromPtr(global::System.IntPtr cPtr)
1164 if (cPtr == global::System.IntPtr.Zero)
1169 Application ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Application;
1170 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1174 public static Application NewApplication()
1176 return NewApplication("", Application.WindowMode.Opaque);
1179 public static Application NewApplication(string stylesheet)
1181 return NewApplication(stylesheet, Application.WindowMode.Opaque);
1184 public static Application NewApplication(string stylesheet, Application.WindowMode windowMode)
1186 // register all Views with the type registry, so that can be created / styled via JSON
1187 //ViewRegistryHelper.Initialize(); //moved to Application side.
1189 Application ret = New(1, stylesheet, windowMode);
1190 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1192 // set the singleton
1197 public static Application NewApplication(string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1199 Application ret = New(1, stylesheet, windowMode, positionSize);
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)
1209 Application ret = New(args, stylesheet, (Application.WindowMode)windowMode);
1210 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1212 // set the singleton
1217 public static Application NewApplication(string[] args, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1219 Application ret = New(args, stylesheet, (Application.WindowMode)windowMode, positionSize);
1220 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1222 // set the singleton
1228 /// Ensures that the function passed in is called from the main loop when it is idle.
1230 /// <param name="func">The function to call</param>
1231 /// <returns>true if added successfully, false otherwise</returns>
1232 public bool AddIdle(System.Delegate func)
1234 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
1235 System.IntPtr ip2 = Interop.Application.MakeCallback(new System.Runtime.InteropServices.HandleRef(this, ip));
1237 bool ret = Interop.Application.Application_AddIdle(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip2));
1239 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1244 * Outer::outer_method(int)
1246 public static Application New()
1248 Application ret = new Application(Interop.Application.Application_New__SWIG_0(), true);
1249 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1253 public static Application New(int argc)
1255 Application ret = new Application(Interop.Application.Application_New__SWIG_1(argc), true);
1256 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1260 public static Application New(int argc, string stylesheet)
1262 Application ret = new Application(Interop.Application.Application_New__SWIG_2(argc, stylesheet), true);
1263 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1267 public static Application New(int argc, string stylesheet, Application.WindowMode windowMode)
1269 Application ret = new Application(Interop.Application.Application_New__SWIG_3(argc, stylesheet, (int)windowMode), true);
1270 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1275 public static Application New(string[] args, string stylesheet, Application.WindowMode windowMode)
1277 int argc = args.Length;
1278 string argvStr = string.Join(" ", args);
1280 Application ret = new Application(NDalicPINVOKE.Application_New__MANUAL_4(argc, argvStr, stylesheet, (int)windowMode), true);
1282 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1287 public static Application New(int argc, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1289 Application ret = new Application(Interop.Application.Application_New__SWIG_4(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1290 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1294 public static Application New(string[] args, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1296 int argc = args.Length;
1297 string argvStr = string.Join(" ", args);
1299 Application ret = new Application(NDalicPINVOKE.Application_New_WithWindowSizePosition(argc, argvStr, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1300 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1304 public Application() : this(Interop.Application.new_Application__SWIG_0(), true)
1306 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1309 public Application(Application application) : this(Interop.Application.new_Application__SWIG_1(Application.getCPtr(application)), true)
1311 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1314 public Application Assign(Application application)
1316 Application ret = new Application(Interop.Application.Application_Assign(swigCPtr, Application.getCPtr(application)), false);
1317 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1321 public void MainLoop()
1323 NDalicPINVOKE.Application_MainLoop__SWIG_0(swigCPtr);
1324 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1327 internal void MainLoop(SWIGTYPE_p_Configuration__ContextLoss configuration)
1329 Interop.Application.Application_MainLoop__SWIG_1(swigCPtr, SWIGTYPE_p_Configuration__ContextLoss.getCPtr(configuration));
1330 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1335 Interop.Application.Application_Lower(swigCPtr);
1336 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1341 Interop.Application.Application_Quit(swigCPtr);
1342 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1345 internal bool AddIdle(SWIGTYPE_p_Dali__CallbackBase callback)
1347 bool ret = Interop.Application.Application_AddIdle(swigCPtr, SWIGTYPE_p_Dali__CallbackBase.getCPtr(callback));
1348 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1352 public Window GetWindow()
1354 Window ret = new Window(Interop.Application.Application_GetWindow(swigCPtr), true);
1355 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1359 public void ReplaceWindow(Rectangle windowPosition, string name)
1361 Interop.Application.Application_ReplaceWindow(swigCPtr, Rectangle.getCPtr(windowPosition), name);
1362 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1365 public static string GetResourcePath()
1367 string ret = Interop.Application.Application_GetResourcePath();
1368 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1372 public string GetLanguage()
1374 string ret = Interop.Application.Application_GetLanguage(swigCPtr);
1375 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1379 public string GetRegion()
1381 string ret = Interop.Application.Application_GetRegion(swigCPtr);
1382 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1386 internal static List<Window> GetWindowList()
1388 uint ListSize = Interop.Application.Application_GetWindowsListSize();
1389 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1391 List<Window> WindowList = new List<Window>();
1392 for( uint i = 0; i < ListSize; ++i )
1394 Window currWin = new Window(Interop.Application.Application_GetWindowsFromList(i), true);
1395 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1396 WindowList.Add(currWin);
1401 internal ApplicationSignal InitSignal()
1403 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_InitSignal(swigCPtr), false);
1404 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1408 internal ApplicationSignal TerminateSignal()
1410 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_TerminateSignal(swigCPtr), false);
1411 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1415 internal ApplicationSignal PauseSignal()
1417 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_PauseSignal(swigCPtr), false);
1418 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1422 internal ApplicationSignal ResumeSignal()
1424 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_ResumeSignal(swigCPtr), false);
1425 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1429 internal ApplicationSignal ResetSignal()
1431 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_ResetSignal(swigCPtr), false);
1432 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1436 internal ApplicationSignal ResizeSignal()
1438 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_ResizeSignal(swigCPtr), false);
1439 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1443 internal ApplicationControlSignal AppControlSignal()
1445 ApplicationControlSignal ret = new ApplicationControlSignal(NDalicPINVOKE.Application_AppControlSignal(swigCPtr), false);
1446 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1450 internal ApplicationSignal LanguageChangedSignal()
1452 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_LanguageChangedSignal(swigCPtr), false);
1453 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1457 internal ApplicationSignal RegionChangedSignal()
1459 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.Application_RegionChangedSignal(swigCPtr), false);
1460 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1464 internal LowBatterySignalType BatteryLowSignal()
1466 LowBatterySignalType ret = new LowBatterySignalType(NDalicPINVOKE.Application_LowBatterySignal(swigCPtr), false);
1467 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1471 internal LowMemorySignalType MemoryLowSignal()
1473 LowMemorySignalType ret = new LowMemorySignalType(NDalicPINVOKE.Application_LowMemorySignal(swigCPtr), false);
1474 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1478 /// <since_tizen> 3 </since_tizen>
1479 public enum WindowMode