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 initSignal?.Disconnect(_applicationInitEventCallbackDelegate);
457 initSignal?.Dispose();
461 if (_applicationTerminateEventCallbackDelegate != null)
463 terminateSignal?.Disconnect(_applicationTerminateEventCallbackDelegate);
464 terminateSignal?.Dispose();
465 terminateSignal = null;
468 if (_applicationPauseEventCallbackDelegate != null)
470 pauseSignal?.Disconnect(_applicationPauseEventCallbackDelegate);
471 pauseSignal?.Dispose();
475 if (_applicationResumeEventCallbackDelegate != null)
477 resumeSignal?.Disconnect(_applicationResumeEventCallbackDelegate);
478 resumeSignal?.Dispose();
482 if (_applicationResetEventCallbackDelegate != null)
484 resetSignal?.Disconnect(_applicationResetEventCallbackDelegate);
485 resetSignal?.Dispose();
489 if (_applicationLanguageChangedEventCallbackDelegate != null)
491 languageChangedSignal?.Disconnect(_applicationLanguageChangedEventCallbackDelegate);
492 languageChangedSignal?.Dispose();
493 languageChangedSignal = null;
496 if (_applicationRegionChangedEventCallbackDelegate != null)
498 regionChangedSignal?.Disconnect(_applicationRegionChangedEventCallbackDelegate);
499 regionChangedSignal?.Dispose();
500 regionChangedSignal = null;
503 if (_applicationBatteryLowEventCallbackDelegate != null)
505 batteryLowSignal?.Disconnect(_applicationBatteryLowEventCallbackDelegate);
506 batteryLowSignal?.Dispose();
507 batteryLowSignal = null;
510 if (_applicationMemoryLowEventCallbackDelegate != null)
512 memoryLowSignal?.Disconnect(_applicationMemoryLowEventCallbackDelegate);
513 memoryLowSignal?.Dispose();
514 memoryLowSignal = null;
517 if (_applicationAppControlEventCallbackDelegate != null)
519 appControlSignal?.Disconnect(_applicationAppControlEventCallbackDelegate);
520 appControlSignal?.Dispose();
521 appControlSignal = null;
529 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
531 Interop.Application.DeleteApplication(swigCPtr);
534 /// <since_tizen> 4 </since_tizen>
535 public enum BatteryStatus
542 /// <since_tizen> 4 </since_tizen>
543 public enum MemoryStatus
550 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
551 private delegate void NUIApplicationInitEventCallbackDelegate(IntPtr application);
552 private DaliEventHandler<object, NUIApplicationInitEventArgs> _applicationInitEventHandler;
553 private NUIApplicationInitEventCallbackDelegate _applicationInitEventCallbackDelegate;
554 private ApplicationSignal initSignal;
557 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
558 private delegate void NUIApplicationTerminateEventCallbackDelegate(IntPtr application);
559 private DaliEventHandler<object, NUIApplicationTerminatingEventArgs> _applicationTerminateEventHandler;
560 private NUIApplicationTerminateEventCallbackDelegate _applicationTerminateEventCallbackDelegate;
561 private ApplicationSignal terminateSignal;
564 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
565 private delegate void NUIApplicationPauseEventCallbackDelegate(IntPtr application);
566 private DaliEventHandler<object, NUIApplicationPausedEventArgs> _applicationPauseEventHandler;
567 private NUIApplicationPauseEventCallbackDelegate _applicationPauseEventCallbackDelegate;
568 private ApplicationSignal pauseSignal;
570 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
571 private delegate void NUIApplicationResumeEventCallbackDelegate(IntPtr application);
572 private DaliEventHandler<object, NUIApplicationResumedEventArgs> _applicationResumeEventHandler;
573 private NUIApplicationResumeEventCallbackDelegate _applicationResumeEventCallbackDelegate;
574 private ApplicationSignal resumeSignal;
576 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
577 private delegate void NUIApplicationResetEventCallbackDelegate(IntPtr application);
578 private DaliEventHandler<object, NUIApplicationResetEventArgs> _applicationResetEventHandler;
579 private NUIApplicationResetEventCallbackDelegate _applicationResetEventCallbackDelegate;
580 private ApplicationSignal resetSignal;
582 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
583 private delegate void NUIApplicationLanguageChangedEventCallbackDelegate(IntPtr application);
584 private DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> _applicationLanguageChangedEventHandler;
585 private NUIApplicationLanguageChangedEventCallbackDelegate _applicationLanguageChangedEventCallbackDelegate;
586 private ApplicationSignal languageChangedSignal;
589 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
590 private delegate void NUIApplicationRegionChangedEventCallbackDelegate(IntPtr application);
591 private DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> _applicationRegionChangedEventHandler;
592 private NUIApplicationRegionChangedEventCallbackDelegate _applicationRegionChangedEventCallbackDelegate;
593 private ApplicationSignal regionChangedSignal;
595 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
596 private delegate void NUIApplicationBatteryLowEventCallbackDelegate(BatteryStatus status);
597 private DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> _applicationBatteryLowEventHandler;
598 private NUIApplicationBatteryLowEventCallbackDelegate _applicationBatteryLowEventCallbackDelegate;
599 private LowBatterySignalType batteryLowSignal;
601 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
602 private delegate void NUIApplicationMemoryLowEventCallbackDelegate(MemoryStatus status);
603 private DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> _applicationMemoryLowEventHandler;
604 private NUIApplicationMemoryLowEventCallbackDelegate _applicationMemoryLowEventCallbackDelegate;
605 private LowMemorySignalType memoryLowSignal;
607 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
608 private delegate void NUIApplicationAppControlEventCallbackDelegate(IntPtr application, IntPtr voidp);
609 private DaliEventHandler<object, NUIApplicationAppControlEventArgs> _applicationAppControlEventHandler;
610 private NUIApplicationAppControlEventCallbackDelegate _applicationAppControlEventCallbackDelegate;
611 private ApplicationControlSignal appControlSignal;
616 * @brief Event for Initialized signal which can be used to subscribe/unsubscribe the event handler
617 * provided by the user. Initialized signal is emitted when application is initialised
619 public event DaliEventHandler<object, NUIApplicationInitEventArgs> Initialized
625 // Restricted to only one listener
626 if (_applicationInitEventHandler == null)
628 _applicationInitEventHandler += value;
629 _applicationInitEventCallbackDelegate = new NUIApplicationInitEventCallbackDelegate(OnApplicationInit);
630 initSignal = this.InitSignal();
631 initSignal?.Connect(_applicationInitEventCallbackDelegate);
640 if (_applicationInitEventHandler != null)
642 initSignal?.Disconnect(_applicationInitEventCallbackDelegate);
643 initSignal?.Dispose();
647 _applicationInitEventHandler -= value;
652 // Callback for Application InitSignal
653 private void OnApplicationInit(IntPtr data)
655 // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread.
656 DisposeQueue.Instance.Initialize();
658 // Notify that the window is displayed to the app core.
659 if (NUIApplication.IsPreLoad)
661 Window.Instance.Show();
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 terminateSignal = this.TerminateSignal();
690 terminateSignal?.Connect(_applicationTerminateEventCallbackDelegate);
699 if (_applicationTerminateEventHandler != null)
701 terminateSignal?.Disconnect(_applicationTerminateEventCallbackDelegate);
702 terminateSignal?.Dispose();
703 terminateSignal = null;
706 _applicationTerminateEventHandler -= value;
711 // Callback for Application TerminateSignal
712 private void OnNUIApplicationTerminate(IntPtr data)
714 if (_applicationTerminateEventHandler != null)
716 NUIApplicationTerminatingEventArgs e = new NUIApplicationTerminatingEventArgs();
717 e.Application = this;
718 _applicationTerminateEventHandler.Invoke(this, e);
721 List<Window> windows = GetWindowList();
722 foreach (Window window in windows)
724 window?.DisconnectNativeSignals();
729 * @brief Event for Paused signal which can be used to subscribe/unsubscribe the event handler
730 * provided by the user. Paused signal is emitted when application is paused
732 public event DaliEventHandler<object, NUIApplicationPausedEventArgs> Paused
738 // Restricted to only one listener
739 if (_applicationPauseEventHandler == null)
741 _applicationPauseEventHandler += value;
743 _applicationPauseEventCallbackDelegate = new NUIApplicationPauseEventCallbackDelegate(OnNUIApplicationPause);
744 pauseSignal = this.PauseSignal();
745 pauseSignal?.Connect(_applicationPauseEventCallbackDelegate);
754 if (_applicationPauseEventHandler != null)
756 pauseSignal?.Disconnect(_applicationPauseEventCallbackDelegate);
757 pauseSignal?.Dispose();
761 _applicationPauseEventHandler -= value;
766 // Callback for Application PauseSignal
767 private void OnNUIApplicationPause(IntPtr data)
769 if (_applicationPauseEventHandler != null)
771 NUIApplicationPausedEventArgs e = new NUIApplicationPausedEventArgs();
772 e.Application = this;
773 _applicationPauseEventHandler.Invoke(this, e);
778 * @brief Event for Resumed signal which can be used to subscribe/unsubscribe the event handler
779 * provided by the user. Resumed signal is emitted when application is resumed
781 public event DaliEventHandler<object, NUIApplicationResumedEventArgs> Resumed
787 // Restricted to only one listener
788 if (_applicationResumeEventHandler == null)
790 _applicationResumeEventHandler += value;
792 _applicationResumeEventCallbackDelegate = new NUIApplicationResumeEventCallbackDelegate(OnNUIApplicationResume);
793 resumeSignal = this.ResumeSignal();
794 resumeSignal?.Connect(_applicationResumeEventCallbackDelegate);
803 if (_applicationResumeEventHandler != null)
805 resumeSignal?.Disconnect(_applicationResumeEventCallbackDelegate);
806 resumeSignal?.Dispose();
810 _applicationResumeEventHandler -= value;
815 // Callback for Application ResumeSignal
816 private void OnNUIApplicationResume(IntPtr data)
818 if (_applicationResumeEventHandler != null)
820 NUIApplicationResumedEventArgs e = new NUIApplicationResumedEventArgs();
821 e.Application = this;
822 _applicationResumeEventHandler.Invoke(this, e);
827 * @brief Event for Reset signal which can be used to subscribe/unsubscribe the event handler
828 * provided by the user. Reset signal is emitted when application is reset
830 public new event DaliEventHandler<object, NUIApplicationResetEventArgs> Reset
836 // Restricted to only one listener
837 if (_applicationResetEventHandler == null)
839 _applicationResetEventHandler += value;
841 _applicationResetEventCallbackDelegate = new NUIApplicationResetEventCallbackDelegate(OnNUIApplicationReset);
842 resetSignal = this.ResetSignal();
843 resetSignal?.Connect(_applicationResetEventCallbackDelegate);
852 if (_applicationResetEventHandler != null)
854 resetSignal?.Disconnect(_applicationResetEventCallbackDelegate);
855 resetSignal?.Dispose();
859 _applicationResetEventHandler -= value;
864 // Callback for Application ResetSignal
865 private void OnNUIApplicationReset(IntPtr data)
867 if (_applicationResetEventHandler != null)
869 NUIApplicationResetEventArgs e = new NUIApplicationResetEventArgs();
870 e.Application = this;
871 _applicationResetEventHandler.Invoke(this, e);
876 * @brief Event for LanguageChanged signal which can be used to subscribe/unsubscribe the event handler
877 * provided by the user. LanguageChanged signal is emitted when the region of the device is changed.
879 public event DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> LanguageChanged
885 // Restricted to only one listener
886 if (_applicationLanguageChangedEventHandler == null)
888 _applicationLanguageChangedEventHandler += value;
890 _applicationLanguageChangedEventCallbackDelegate = new NUIApplicationLanguageChangedEventCallbackDelegate(OnNUIApplicationLanguageChanged);
891 languageChangedSignal = this.LanguageChangedSignal();
892 languageChangedSignal?.Connect(_applicationLanguageChangedEventCallbackDelegate);
901 if (_applicationLanguageChangedEventHandler != null)
903 languageChangedSignal?.Disconnect(_applicationLanguageChangedEventCallbackDelegate);
904 languageChangedSignal?.Dispose();
905 languageChangedSignal = null;
908 _applicationLanguageChangedEventHandler -= value;
913 // Callback for Application LanguageChangedSignal
914 private void OnNUIApplicationLanguageChanged(IntPtr data)
916 if (_applicationLanguageChangedEventHandler != null)
918 NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs();
919 e.Application = this;
920 _applicationLanguageChangedEventHandler.Invoke(this, e);
925 * @brief Event for RegionChanged signal which can be used to subscribe/unsubscribe the event handler
926 * provided by the user. RegionChanged signal is emitted when the region of the device is changed.
928 public event DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> RegionChanged
934 // Restricted to only one listener
935 if (_applicationRegionChangedEventHandler == null)
937 _applicationRegionChangedEventHandler += value;
939 _applicationRegionChangedEventCallbackDelegate = new NUIApplicationRegionChangedEventCallbackDelegate(OnNUIApplicationRegionChanged);
940 regionChangedSignal = this.RegionChangedSignal();
941 regionChangedSignal?.Connect(_applicationRegionChangedEventCallbackDelegate);
950 if (_applicationRegionChangedEventHandler != null)
952 regionChangedSignal?.Disconnect(_applicationRegionChangedEventCallbackDelegate);
953 regionChangedSignal?.Dispose();
954 regionChangedSignal = null;
957 _applicationRegionChangedEventHandler -= value;
962 // Callback for Application RegionChangedSignal
963 private void OnNUIApplicationRegionChanged(IntPtr data)
965 if (_applicationRegionChangedEventHandler != null)
967 NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs();
968 e.Application = this;
969 _applicationRegionChangedEventHandler.Invoke(this, e);
974 * @brief Event for BatteryLow signal which can be used to subscribe/unsubscribe the event handler
975 * provided by the user. BatteryLow signal is emitted when the battery level of the device is low.
977 public event DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> BatteryLow
983 // Restricted to only one listener
984 if (_applicationBatteryLowEventHandler == null)
986 _applicationBatteryLowEventHandler += value;
988 _applicationBatteryLowEventCallbackDelegate = new NUIApplicationBatteryLowEventCallbackDelegate(OnNUIApplicationBatteryLow);
989 batteryLowSignal = this.BatteryLowSignal();
990 batteryLowSignal?.Connect(_applicationBatteryLowEventCallbackDelegate);
999 if (_applicationBatteryLowEventHandler != null)
1001 batteryLowSignal?.Disconnect(_applicationBatteryLowEventCallbackDelegate);
1002 batteryLowSignal?.Dispose();
1003 batteryLowSignal = null;
1006 _applicationBatteryLowEventHandler -= value;
1011 // Callback for Application BatteryLowSignal
1012 private void OnNUIApplicationBatteryLow(BatteryStatus status)
1016 NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
1018 // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
1019 e.BatteryStatus = status;
1020 _applicationBatteryLowEventHandler?.Invoke(this, e);
1025 * @brief Event for MemoryLow signal which can be used to subscribe/unsubscribe the event handler
1026 * provided by the user. MemoryLow signal is emitted when the memory level of the device is low.
1028 public event DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> MemoryLow
1034 // Restricted to only one listener
1035 if (_applicationMemoryLowEventHandler == null)
1037 _applicationMemoryLowEventHandler += value;
1039 _applicationMemoryLowEventCallbackDelegate = new NUIApplicationMemoryLowEventCallbackDelegate(OnNUIApplicationMemoryLow);
1040 memoryLowSignal = this.MemoryLowSignal();
1041 memoryLowSignal?.Connect(_applicationMemoryLowEventCallbackDelegate);
1050 if (_applicationMemoryLowEventHandler != null)
1052 memoryLowSignal?.Disconnect(_applicationMemoryLowEventCallbackDelegate);
1053 memoryLowSignal?.Dispose();
1054 memoryLowSignal = null;
1057 _applicationMemoryLowEventHandler -= value;
1062 // Callback for Application MemoryLowSignal
1063 private void OnNUIApplicationMemoryLow(MemoryStatus status)
1067 NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
1069 // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
1070 e.MemoryStatus = status;
1071 _applicationMemoryLowEventHandler?.Invoke(this, e);
1076 * @brief Event for AppControl signal which can be used to subscribe/unsubscribe the event handler
1077 * provided by the user. AppControl signal is emitted when another application sends a launch request to the application.
1079 public event DaliEventHandler<object, NUIApplicationAppControlEventArgs> AppControl
1085 // Restricted to only one listener
1086 if (_applicationAppControlEventHandler == null)
1088 _applicationAppControlEventHandler += value;
1090 _applicationAppControlEventCallbackDelegate = new NUIApplicationAppControlEventCallbackDelegate(OnNUIApplicationAppControl);
1091 appControlSignal = this.AppControlSignal();
1092 appControlSignal?.Connect(_applicationAppControlEventCallbackDelegate);
1101 if (_applicationAppControlEventHandler != null)
1103 appControlSignal?.Disconnect(_applicationAppControlEventCallbackDelegate);
1104 appControlSignal?.Dispose();
1105 appControlSignal = null;
1108 _applicationAppControlEventHandler -= value;
1113 // Callback for Application AppControlSignal
1114 private void OnNUIApplicationAppControl(IntPtr application, IntPtr voidp)
1116 if (_applicationAppControlEventHandler != null)
1118 NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs();
1120 e.Application = this;
1121 _applicationAppControlEventHandler.Invoke(this, e);
1125 protected static Application _instance; // singleton
1127 public static Application Instance
1135 public static Application GetApplicationFromPtr(global::System.IntPtr cPtr)
1137 if (cPtr == global::System.IntPtr.Zero)
1142 Application ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Application;
1143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1147 public static Application NewApplication()
1149 return NewApplication("", Application.WindowMode.Opaque);
1152 public static Application NewApplication(string stylesheet)
1154 return NewApplication(stylesheet, Application.WindowMode.Opaque);
1157 public static Application NewApplication(string stylesheet, Application.WindowMode windowMode)
1159 // register all Views with the type registry, so that can be created / styled via JSON
1160 //ViewRegistryHelper.Initialize(); //moved to Application side.
1166 Application ret = New(1, stylesheet, windowMode);
1167 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1169 // set the singleton
1174 public static Application NewApplication(string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1180 Application ret = New(1, stylesheet, windowMode, positionSize);
1181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1183 // set the singleton
1188 public static Application NewApplication(string[] args, string stylesheet, Application.WindowMode windowMode)
1194 Application ret = New(args, stylesheet, (Application.WindowMode)windowMode);
1195 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1197 // set the singleton
1202 public static Application NewApplication(string[] args, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1208 Application ret = New(args, stylesheet, (Application.WindowMode)windowMode, positionSize);
1209 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1211 // set the singleton
1217 /// Ensures that the function passed in is called from the main loop when it is idle.
1219 /// <param name="func">The function to call</param>
1220 /// <returns>true if added successfully, false otherwise</returns>
1221 public bool AddIdle(System.Delegate func)
1223 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
1224 System.IntPtr ip2 = Interop.Application.MakeCallback(new System.Runtime.InteropServices.HandleRef(this, ip));
1226 bool ret = Interop.Application.AddIdle(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip2));
1228 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1233 * Outer::outer_method(int)
1235 public static Application New()
1237 Application ret = new Application(Interop.Application.New(), true);
1238 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1242 public static Application New(int argc)
1244 Application ret = new Application(Interop.Application.New(argc), true);
1245 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1249 public static Application New(int argc, string stylesheet)
1251 Application ret = new Application(Interop.Application.New(argc, stylesheet), true);
1252 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1256 public static Application New(int argc, string stylesheet, Application.WindowMode windowMode)
1258 Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode), true);
1259 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1264 public static Application New(string[] args, string stylesheet, Application.WindowMode windowMode)
1266 Application ret = null;
1268 string argvStr = "";
1272 argvStr = string.Join(" ", args);
1274 catch (Exception exception)
1276 Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, msg : " + exception.Message);
1277 Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber());
1278 Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace);
1282 ret = new Application(NDalicPINVOKE.ApplicationNewManual4(argc, argvStr, stylesheet, (int)windowMode), true);
1283 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1288 public static Application New(int argc, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1290 Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1291 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1295 public static Application New(string[] args, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
1297 Application ret = null;
1299 string argvStr = "";
1303 argvStr = string.Join(" ", args);
1305 catch (Exception exception)
1307 Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, msg : " + exception.Message);
1308 Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber());
1309 Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace);
1313 ret = new Application(NDalicPINVOKE.ApplicationNewWithWindowSizePosition(argc, argvStr, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1314 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1319 public Application() : this(Interop.Application.NewApplication(), true)
1321 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1324 public Application(Application application) : this(Interop.Application.NewApplication(Application.getCPtr(application)), true)
1326 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1329 public Application Assign(Application application)
1331 Application ret = new Application(Interop.Application.Assign(SwigCPtr, Application.getCPtr(application)), false);
1332 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1336 public void MainLoop()
1338 NDalicPINVOKE.ApplicationMainLoop(SwigCPtr);
1339 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1344 Interop.Application.Lower(SwigCPtr);
1345 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1350 Interop.Application.Quit(SwigCPtr);
1351 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1354 internal bool AddIdle(SWIGTYPE_p_Dali__CallbackBase callback)
1356 bool ret = Interop.Application.AddIdle(SwigCPtr, SWIGTYPE_p_Dali__CallbackBase.getCPtr(callback));
1357 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1361 public Window GetWindow()
1363 win = Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindow(SwigCPtr)) as Window;
1366 win = new Window(Interop.Application.GetWindow(SwigCPtr), true);
1369 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1373 public static string GetResourcePath()
1375 string ret = Interop.Application.GetResourcePath();
1376 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1380 public string GetLanguage()
1382 string ret = Interop.Application.GetLanguage(SwigCPtr);
1383 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1387 public string GetRegion()
1389 string ret = Interop.Application.GetRegion(SwigCPtr);
1390 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1394 [EditorBrowsable(EditorBrowsableState.Never)]
1395 public static List<Window> GetWindowList()
1397 uint ListSize = Interop.Application.GetWindowsListSize();
1398 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1400 List<Window> WindowList = new List<Window>();
1401 for (uint i = 0; i < ListSize; ++i)
1403 Window currWin = Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindowsFromList(i)) as Window;
1404 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1407 WindowList.Add(currWin);
1413 internal ApplicationSignal InitSignal()
1415 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationInitSignal(SwigCPtr), false);
1416 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1420 internal ApplicationSignal TerminateSignal()
1422 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationTerminateSignal(SwigCPtr), false);
1423 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1427 internal ApplicationSignal PauseSignal()
1429 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationPauseSignal(SwigCPtr), false);
1430 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1434 internal ApplicationSignal ResumeSignal()
1436 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationResumeSignal(SwigCPtr), false);
1437 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1441 internal ApplicationSignal ResetSignal()
1443 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationResetSignal(SwigCPtr), false);
1444 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1448 internal ApplicationControlSignal AppControlSignal()
1450 ApplicationControlSignal ret = new ApplicationControlSignal(NDalicPINVOKE.ApplicationAppControlSignal(SwigCPtr), false);
1451 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1455 internal ApplicationSignal LanguageChangedSignal()
1457 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationLanguageChangedSignal(SwigCPtr), false);
1458 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1462 internal ApplicationSignal RegionChangedSignal()
1464 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationRegionChangedSignal(SwigCPtr), false);
1465 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1469 internal LowBatterySignalType BatteryLowSignal()
1471 LowBatterySignalType ret = new LowBatterySignalType(NDalicPINVOKE.ApplicationLowBatterySignal(SwigCPtr), false);
1472 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1476 internal LowMemorySignalType MemoryLowSignal()
1478 LowMemorySignalType ret = new LowMemorySignalType(NDalicPINVOKE.ApplicationLowMemorySignal(SwigCPtr), false);
1479 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1483 /// <since_tizen> 3 </since_tizen>
1484 public enum WindowMode