2 * Copyright(c) 2021 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 Tizen.NUI.Binding;
28 * @brief Event arguments that passed via NUIApplicationInit signal
30 internal class NUIApplicationInitEventArgs : EventArgs
32 private Application application;
35 * @brief Application - is the application that is being initialized
37 public Application Application
51 * @brief Event arguments that passed via NUIApplicationTerminate signal
53 internal class NUIApplicationTerminatingEventArgs : EventArgs
55 private Application application;
57 * @brief Application - is the application that is being Terminated
59 public Application Application
73 * @brief Event arguments that passed via NUIApplicationPause signal
75 internal class NUIApplicationPausedEventArgs : EventArgs
77 private Application application;
79 * @brief Application - is the application that is being Paused
81 public Application Application
95 * @brief Event arguments that passed via NUIApplicationResume signal
97 internal class NUIApplicationResumedEventArgs : EventArgs
99 private Application application;
101 * @brief Application - is the application that is being Resumed
103 public Application Application
117 * @brief Event arguments that passed via NUIApplicationReset signal
119 internal class NUIApplicationResetEventArgs : EventArgs
121 private Application application;
123 * @brief Application - is the application that is being Reset
125 public Application Application
139 * @brief Event arguments that passed via NUIApplicationLanguageChanged signal
141 internal class NUIApplicationLanguageChangedEventArgs : EventArgs
143 private Application application;
145 * @brief Application - is the application that is being affected with Device's language change
147 public Application Application
161 * @brief Event arguments that passed via NUIApplicationRegionChanged signal
163 internal class NUIApplicationRegionChangedEventArgs : EventArgs
165 private Application application;
167 * @brief Application - is the application that is being affected with Device's region change
169 public Application Application
183 * @brief Event arguments that passed via NUIApplicationBatteryLow signal
185 internal class NUIApplicationBatteryLowEventArgs : EventArgs
187 private Application.BatteryStatus status;
189 * @brief Application - is the application that is being affected when the battery level of the device is low
191 public Application.BatteryStatus BatteryStatus
205 * @brief Event arguments that passed via NUIApplicationMemoryLow signal
207 internal class NUIApplicationMemoryLowEventArgs : EventArgs
209 private Application.MemoryStatus status;
211 * @brief Application - is the application that is being affected when the memory level of the device is low
213 public Application.MemoryStatus MemoryStatus
227 * @brief Event arguments that passed via NUIApplicationAppControl signal
229 internal class NUIApplicationAppControlEventArgs : EventArgs
231 private Application application;
232 private IntPtr voidp;
234 * @brief Application - is the application that is receiving the launch request from another application
236 public Application Application
248 * @brief VoidP - contains the information about why the application is launched
264 /// A class to get resources in current application.
266 public sealed class GetResourcesProvider
269 /// Get resources in current application.
271 static public IResourcesProvider Get()
273 return Tizen.NUI.Application.Current;
277 internal class Application : BaseHandle, IResourcesProvider, IElementConfiguration<Application>
279 static Application s_current;
281 ReadOnlyCollection<Element> logicalChildren;
283 [EditorBrowsable(EditorBrowsableState.Never)]
284 public static void SetCurrentApplication(Application value) => Current = value;
286 public static Application Current
288 get { return s_current; }
291 if (s_current == value)
297 internal override ReadOnlyCollection<Element> LogicalChildrenInternal
299 get { return logicalChildren ?? (logicalChildren = new ReadOnlyCollection<Element>(InternalChildren)); }
302 internal IResourceDictionary SystemResources { get; }
304 ObservableCollection<Element> InternalChildren { get; } = new ObservableCollection<Element>();
306 ResourceDictionary resources;
307 public bool IsResourcesCreated => resources != null;
309 public delegate void resChangeCb(object sender, ResourcesChangedEventArgs e);
311 static private Dictionary<object, Dictionary<resChangeCb, int>> resourceChangeCallbackDict = new Dictionary<object, Dictionary<resChangeCb, int>>();
312 static public void AddResourceChangedCallback(object handle, resChangeCb cb)
314 Dictionary<resChangeCb, int> cbDict;
315 resourceChangeCallbackDict.TryGetValue(handle, out cbDict);
319 cbDict = new Dictionary<resChangeCb, int>();
320 resourceChangeCallbackDict.Add(handle, cbDict);
323 if (false == cbDict.ContainsKey(cb))
329 internal override void OnResourcesChanged(object sender, ResourcesChangedEventArgs e)
331 base.OnResourcesChanged(sender, e);
333 foreach (KeyValuePair<object, Dictionary<resChangeCb, int>> resourcePair in resourceChangeCallbackDict)
335 foreach (KeyValuePair<resChangeCb, int> cbPair in resourcePair.Value)
337 cbPair.Key(sender, e);
342 public ResourceDictionary XamlResources
346 if (resources == null)
348 resources = new ResourceDictionary();
349 int hashCode = resources.GetHashCode();
350 ((IResourceDictionary)resources).ValuesChanged += OnResourcesChanged;
356 if (resources == value)
358 OnPropertyChanging();
360 if (resources != null)
361 ((IResourceDictionary)resources).ValuesChanged -= OnResourcesChanged;
363 OnResourcesChanged(value);
364 if (resources != null)
365 ((IResourceDictionary)resources).ValuesChanged += OnResourcesChanged;
371 protected override void OnParentSet()
373 throw new InvalidOperationException("Setting a Parent on Application is invalid.");
376 [EditorBrowsable(EditorBrowsableState.Never)]
377 public static bool IsApplicationOrNull(Element element)
379 return element == null || element is Application;
382 internal override void OnParentResourcesChanged(IEnumerable<KeyValuePair<string, object>> values)
384 if (!((IResourcesProvider)this).IsResourcesCreated || XamlResources.Count == 0)
386 base.OnParentResourcesChanged(values);
390 var innerKeys = new HashSet<string>();
391 var changedResources = new List<KeyValuePair<string, object>>();
392 foreach (KeyValuePair<string, object> c in XamlResources)
393 innerKeys.Add(c.Key);
394 foreach (KeyValuePair<string, object> value in values)
396 if (innerKeys.Add(value.Key))
397 changedResources.Add(value);
399 OnResourcesChanged(changedResources);
402 internal Application(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
404 SetCurrentApplication(this);
408 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Application obj)
410 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
413 protected override void Dispose(DisposeTypes type)
420 //Release your own unmanaged resources here.
421 //You should not access any managed member here except static instance.
422 //because the execution order of Finalizes is non-deterministic.
423 if (applicationInitEventCallbackDelegate != null)
425 initSignal?.Disconnect(applicationInitEventCallbackDelegate);
426 initSignal?.Dispose();
430 if (applicationTerminateEventCallbackDelegate != null)
432 terminateSignal?.Disconnect(applicationTerminateEventCallbackDelegate);
433 terminateSignal?.Dispose();
434 terminateSignal = null;
437 if (applicationPauseEventCallbackDelegate != null)
439 pauseSignal?.Disconnect(applicationPauseEventCallbackDelegate);
440 pauseSignal?.Dispose();
444 if (applicationResumeEventCallbackDelegate != null)
446 resumeSignal?.Disconnect(applicationResumeEventCallbackDelegate);
447 resumeSignal?.Dispose();
451 if (applicationResetEventCallbackDelegate != null)
453 resetSignal?.Disconnect(applicationResetEventCallbackDelegate);
454 resetSignal?.Dispose();
458 if (applicationLanguageChangedEventCallbackDelegate != null)
460 languageChangedSignal?.Disconnect(applicationLanguageChangedEventCallbackDelegate);
461 languageChangedSignal?.Dispose();
462 languageChangedSignal = null;
465 if (applicationRegionChangedEventCallbackDelegate != null)
467 regionChangedSignal?.Disconnect(applicationRegionChangedEventCallbackDelegate);
468 regionChangedSignal?.Dispose();
469 regionChangedSignal = null;
472 if (applicationBatteryLowEventCallbackDelegate != null)
474 batteryLowSignal?.Disconnect(applicationBatteryLowEventCallbackDelegate);
475 batteryLowSignal?.Dispose();
476 batteryLowSignal = null;
479 if (applicationMemoryLowEventCallbackDelegate != null)
481 memoryLowSignal?.Disconnect(applicationMemoryLowEventCallbackDelegate);
482 memoryLowSignal?.Dispose();
483 memoryLowSignal = null;
486 if (applicationAppControlEventCallbackDelegate != null)
488 appControlSignal?.Disconnect(applicationAppControlEventCallbackDelegate);
489 appControlSignal?.Dispose();
490 appControlSignal = null;
498 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
500 Interop.Application.DeleteApplication(swigCPtr);
503 public enum BatteryStatus
510 public enum MemoryStatus
517 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
518 private delegate void NUIApplicationInitEventCallbackDelegate(IntPtr application);
519 private DaliEventHandler<object, NUIApplicationInitEventArgs> applicationInitEventHandler;
520 private NUIApplicationInitEventCallbackDelegate applicationInitEventCallbackDelegate;
521 private ApplicationSignal initSignal;
523 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
524 private delegate void NUIApplicationTerminateEventCallbackDelegate(IntPtr application);
525 private DaliEventHandler<object, NUIApplicationTerminatingEventArgs> applicationTerminateEventHandler;
526 private NUIApplicationTerminateEventCallbackDelegate applicationTerminateEventCallbackDelegate;
527 private ApplicationSignal terminateSignal;
529 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
530 private delegate void NUIApplicationPauseEventCallbackDelegate(IntPtr application);
531 private DaliEventHandler<object, NUIApplicationPausedEventArgs> applicationPauseEventHandler;
532 private NUIApplicationPauseEventCallbackDelegate applicationPauseEventCallbackDelegate;
533 private ApplicationSignal pauseSignal;
535 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
536 private delegate void NUIApplicationResumeEventCallbackDelegate(IntPtr application);
537 private DaliEventHandler<object, NUIApplicationResumedEventArgs> applicationResumeEventHandler;
538 private NUIApplicationResumeEventCallbackDelegate applicationResumeEventCallbackDelegate;
539 private ApplicationSignal resumeSignal;
541 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
542 private delegate void NUIApplicationResetEventCallbackDelegate(IntPtr application);
543 private DaliEventHandler<object, NUIApplicationResetEventArgs> applicationResetEventHandler;
544 private NUIApplicationResetEventCallbackDelegate applicationResetEventCallbackDelegate;
545 private ApplicationSignal resetSignal;
547 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
548 private delegate void NUIApplicationLanguageChangedEventCallbackDelegate(IntPtr application);
549 private DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> applicationLanguageChangedEventHandler;
550 private NUIApplicationLanguageChangedEventCallbackDelegate applicationLanguageChangedEventCallbackDelegate;
551 private ApplicationSignal languageChangedSignal;
554 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
555 private delegate void NUIApplicationRegionChangedEventCallbackDelegate(IntPtr application);
556 private DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> applicationRegionChangedEventHandler;
557 private NUIApplicationRegionChangedEventCallbackDelegate applicationRegionChangedEventCallbackDelegate;
558 private ApplicationSignal regionChangedSignal;
560 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
561 private delegate void NUIApplicationBatteryLowEventCallbackDelegate(BatteryStatus status);
562 private DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> applicationBatteryLowEventHandler;
563 private NUIApplicationBatteryLowEventCallbackDelegate applicationBatteryLowEventCallbackDelegate;
564 private LowBatterySignalType batteryLowSignal;
566 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
567 private delegate void NUIApplicationMemoryLowEventCallbackDelegate(MemoryStatus status);
568 private DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> applicationMemoryLowEventHandler;
569 private NUIApplicationMemoryLowEventCallbackDelegate applicationMemoryLowEventCallbackDelegate;
570 private LowMemorySignalType memoryLowSignal;
572 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
573 private delegate void NUIApplicationAppControlEventCallbackDelegate(IntPtr application, IntPtr voidp);
574 private DaliEventHandler<object, NUIApplicationAppControlEventArgs> applicationAppControlEventHandler;
575 private NUIApplicationAppControlEventCallbackDelegate applicationAppControlEventCallbackDelegate;
576 private ApplicationControlSignal appControlSignal;
581 * @brief Event for Initialized signal which can be used to subscribe/unsubscribe the event handler
582 * provided by the user. Initialized signal is emitted when application is initialised
584 public event DaliEventHandler<object, NUIApplicationInitEventArgs> Initialized
588 // Restricted to only one listener
589 if (applicationInitEventHandler == null)
591 applicationInitEventHandler += value;
592 applicationInitEventCallbackDelegate = new NUIApplicationInitEventCallbackDelegate(OnApplicationInit);
593 initSignal = this.InitSignal();
594 initSignal?.Connect(applicationInitEventCallbackDelegate);
600 if (applicationInitEventHandler != null)
602 initSignal?.Disconnect(applicationInitEventCallbackDelegate);
603 initSignal?.Dispose();
607 applicationInitEventHandler -= value;
611 // Callback for Application InitSignal
612 private void OnApplicationInit(IntPtr data)
614 // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread.
615 DisposeQueue.Instance.Initialize();
617 // Notify that the window is displayed to the app core.
618 if (NUIApplication.IsPreload)
620 Window.Instance.Show();
623 if (applicationInitEventHandler != null)
625 NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs();
626 e.Application = this;
627 applicationInitEventHandler.Invoke(this, e);
633 * @brief Event for Terminated signal which can be used to subscribe/unsubscribe the event handler
634 * provided by the user. Terminated signal is emitted when application is terminating
636 public event DaliEventHandler<object, NUIApplicationTerminatingEventArgs> Terminating
640 // Restricted to only one listener
641 if (applicationTerminateEventHandler == null)
643 applicationTerminateEventHandler += value;
645 applicationTerminateEventCallbackDelegate = new NUIApplicationTerminateEventCallbackDelegate(OnNUIApplicationTerminate);
646 terminateSignal = this.TerminateSignal();
647 terminateSignal?.Connect(applicationTerminateEventCallbackDelegate);
653 if (applicationTerminateEventHandler != null)
655 terminateSignal?.Disconnect(applicationTerminateEventCallbackDelegate);
656 terminateSignal?.Dispose();
657 terminateSignal = null;
660 applicationTerminateEventHandler -= value;
664 // Callback for Application TerminateSignal
665 private void OnNUIApplicationTerminate(IntPtr data)
667 if (applicationTerminateEventHandler != null)
669 NUIApplicationTerminatingEventArgs e = new NUIApplicationTerminatingEventArgs();
670 e.Application = this;
671 applicationTerminateEventHandler.Invoke(this, e);
674 List<Window> windows = GetWindowList();
675 foreach (Window window in windows)
677 window?.DisconnectNativeSignals();
682 * @brief Event for Paused signal which can be used to subscribe/unsubscribe the event handler
683 * provided by the user. Paused signal is emitted when application is paused
685 public event DaliEventHandler<object, NUIApplicationPausedEventArgs> Paused
689 // Restricted to only one listener
690 if (applicationPauseEventHandler == null)
692 applicationPauseEventHandler += value;
694 applicationPauseEventCallbackDelegate = new NUIApplicationPauseEventCallbackDelegate(OnNUIApplicationPause);
695 pauseSignal = this.PauseSignal();
696 pauseSignal?.Connect(applicationPauseEventCallbackDelegate);
702 if (applicationPauseEventHandler != null)
704 pauseSignal?.Disconnect(applicationPauseEventCallbackDelegate);
705 pauseSignal?.Dispose();
709 applicationPauseEventHandler -= value;
713 // Callback for Application PauseSignal
714 private void OnNUIApplicationPause(IntPtr data)
716 if (applicationPauseEventHandler != null)
718 NUIApplicationPausedEventArgs e = new NUIApplicationPausedEventArgs();
719 e.Application = this;
720 applicationPauseEventHandler.Invoke(this, e);
725 * @brief Event for Resumed signal which can be used to subscribe/unsubscribe the event handler
726 * provided by the user. Resumed signal is emitted when application is resumed
728 public event DaliEventHandler<object, NUIApplicationResumedEventArgs> Resumed
732 // Restricted to only one listener
733 if (applicationResumeEventHandler == null)
735 applicationResumeEventHandler += value;
737 applicationResumeEventCallbackDelegate = new NUIApplicationResumeEventCallbackDelegate(OnNUIApplicationResume);
738 resumeSignal = this.ResumeSignal();
739 resumeSignal?.Connect(applicationResumeEventCallbackDelegate);
745 if (applicationResumeEventHandler != null)
747 resumeSignal?.Disconnect(applicationResumeEventCallbackDelegate);
748 resumeSignal?.Dispose();
752 applicationResumeEventHandler -= value;
756 // Callback for Application ResumeSignal
757 private void OnNUIApplicationResume(IntPtr data)
759 if (applicationResumeEventHandler != null)
761 NUIApplicationResumedEventArgs e = new NUIApplicationResumedEventArgs();
762 e.Application = this;
763 applicationResumeEventHandler.Invoke(this, e);
768 * @brief Event for Reset signal which can be used to subscribe/unsubscribe the event handler
769 * provided by the user. Reset signal is emitted when application is reset
771 public new event DaliEventHandler<object, NUIApplicationResetEventArgs> Reset
775 // Restricted to only one listener
776 if (applicationResetEventHandler == null)
778 applicationResetEventHandler += value;
780 applicationResetEventCallbackDelegate = new NUIApplicationResetEventCallbackDelegate(OnNUIApplicationReset);
781 resetSignal = this.ResetSignal();
782 resetSignal?.Connect(applicationResetEventCallbackDelegate);
788 if (applicationResetEventHandler != null)
790 resetSignal?.Disconnect(applicationResetEventCallbackDelegate);
791 resetSignal?.Dispose();
795 applicationResetEventHandler -= value;
799 // Callback for Application ResetSignal
800 private void OnNUIApplicationReset(IntPtr data)
802 if (applicationResetEventHandler != null)
804 NUIApplicationResetEventArgs e = new NUIApplicationResetEventArgs();
805 e.Application = this;
806 applicationResetEventHandler.Invoke(this, e);
811 * @brief Event for LanguageChanged signal which can be used to subscribe/unsubscribe the event handler
812 * provided by the user. LanguageChanged signal is emitted when the region of the device is changed.
814 public event DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> LanguageChanged
818 // Restricted to only one listener
819 if (applicationLanguageChangedEventHandler == null)
821 applicationLanguageChangedEventHandler += value;
823 applicationLanguageChangedEventCallbackDelegate = new NUIApplicationLanguageChangedEventCallbackDelegate(OnNUIApplicationLanguageChanged);
824 languageChangedSignal = this.LanguageChangedSignal();
825 languageChangedSignal?.Connect(applicationLanguageChangedEventCallbackDelegate);
831 if (applicationLanguageChangedEventHandler != null)
833 languageChangedSignal?.Disconnect(applicationLanguageChangedEventCallbackDelegate);
834 languageChangedSignal?.Dispose();
835 languageChangedSignal = null;
838 applicationLanguageChangedEventHandler -= value;
842 // Callback for Application LanguageChangedSignal
843 private void OnNUIApplicationLanguageChanged(IntPtr data)
845 if (applicationLanguageChangedEventHandler != null)
847 NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs();
848 e.Application = this;
849 applicationLanguageChangedEventHandler.Invoke(this, e);
854 * @brief Event for RegionChanged signal which can be used to subscribe/unsubscribe the event handler
855 * provided by the user. RegionChanged signal is emitted when the region of the device is changed.
857 public event DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> RegionChanged
861 // Restricted to only one listener
862 if (applicationRegionChangedEventHandler == null)
864 applicationRegionChangedEventHandler += value;
866 applicationRegionChangedEventCallbackDelegate = new NUIApplicationRegionChangedEventCallbackDelegate(OnNUIApplicationRegionChanged);
867 regionChangedSignal = this.RegionChangedSignal();
868 regionChangedSignal?.Connect(applicationRegionChangedEventCallbackDelegate);
874 if (applicationRegionChangedEventHandler != null)
876 regionChangedSignal?.Disconnect(applicationRegionChangedEventCallbackDelegate);
877 regionChangedSignal?.Dispose();
878 regionChangedSignal = null;
881 applicationRegionChangedEventHandler -= value;
885 // Callback for Application RegionChangedSignal
886 private void OnNUIApplicationRegionChanged(IntPtr data)
888 if (applicationRegionChangedEventHandler != null)
890 NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs();
891 e.Application = this;
892 applicationRegionChangedEventHandler.Invoke(this, e);
897 * @brief Event for BatteryLow signal which can be used to subscribe/unsubscribe the event handler
898 * provided by the user. BatteryLow signal is emitted when the battery level of the device is low.
900 public event DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> BatteryLow
904 // Restricted to only one listener
905 if (applicationBatteryLowEventHandler == null)
907 applicationBatteryLowEventHandler += value;
909 applicationBatteryLowEventCallbackDelegate = new NUIApplicationBatteryLowEventCallbackDelegate(OnNUIApplicationBatteryLow);
910 batteryLowSignal = this.BatteryLowSignal();
911 batteryLowSignal?.Connect(applicationBatteryLowEventCallbackDelegate);
917 if (applicationBatteryLowEventHandler != null)
919 batteryLowSignal?.Disconnect(applicationBatteryLowEventCallbackDelegate);
920 batteryLowSignal?.Dispose();
921 batteryLowSignal = null;
924 applicationBatteryLowEventHandler -= value;
928 // Callback for Application BatteryLowSignal
929 private void OnNUIApplicationBatteryLow(BatteryStatus status)
931 NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
933 // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
934 e.BatteryStatus = status;
935 applicationBatteryLowEventHandler?.Invoke(this, e);
939 * @brief Event for MemoryLow signal which can be used to subscribe/unsubscribe the event handler
940 * provided by the user. MemoryLow signal is emitted when the memory level of the device is low.
942 public event DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> MemoryLow
946 // Restricted to only one listener
947 if (applicationMemoryLowEventHandler == null)
949 applicationMemoryLowEventHandler += value;
951 applicationMemoryLowEventCallbackDelegate = new NUIApplicationMemoryLowEventCallbackDelegate(OnNUIApplicationMemoryLow);
952 memoryLowSignal = this.MemoryLowSignal();
953 memoryLowSignal?.Connect(applicationMemoryLowEventCallbackDelegate);
959 if (applicationMemoryLowEventHandler != null)
961 memoryLowSignal?.Disconnect(applicationMemoryLowEventCallbackDelegate);
962 memoryLowSignal?.Dispose();
963 memoryLowSignal = null;
966 applicationMemoryLowEventHandler -= value;
970 // Callback for Application MemoryLowSignal
971 private void OnNUIApplicationMemoryLow(MemoryStatus status)
973 NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
975 // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
976 e.MemoryStatus = status;
977 applicationMemoryLowEventHandler?.Invoke(this, e);
981 * @brief Event for AppControl signal which can be used to subscribe/unsubscribe the event handler
982 * provided by the user. AppControl signal is emitted when another application sends a launch request to the application.
984 public event DaliEventHandler<object, NUIApplicationAppControlEventArgs> AppControl
988 // Restricted to only one listener
989 if (applicationAppControlEventHandler == null)
991 applicationAppControlEventHandler += value;
993 applicationAppControlEventCallbackDelegate = new NUIApplicationAppControlEventCallbackDelegate(OnNUIApplicationAppControl);
994 appControlSignal = this.AppControlSignal();
995 appControlSignal?.Connect(applicationAppControlEventCallbackDelegate);
1001 if (applicationAppControlEventHandler != null)
1003 appControlSignal?.Disconnect(applicationAppControlEventCallbackDelegate);
1004 appControlSignal?.Dispose();
1005 appControlSignal = null;
1008 applicationAppControlEventHandler -= value;
1012 // Callback for Application AppControlSignal
1013 private void OnNUIApplicationAppControl(IntPtr application, IntPtr voidp)
1015 if (applicationAppControlEventHandler != null)
1017 NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs();
1019 e.Application = this;
1020 applicationAppControlEventHandler.Invoke(this, e);
1024 protected static Application instance; // singleton
1026 public static Application Instance
1034 public static Application GetApplicationFromPtr(global::System.IntPtr cPtr)
1036 if (cPtr == global::System.IntPtr.Zero)
1041 Application ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Application;
1042 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1046 public static Application NewApplication()
1048 return NewApplication("", NUIApplication.WindowMode.Opaque);
1051 public static Application NewApplication(string stylesheet)
1053 return NewApplication(stylesheet, NUIApplication.WindowMode.Opaque);
1056 public static Application NewApplication(string stylesheet, NUIApplication.WindowMode windowMode)
1058 // register all Views with the type registry, so that can be created / styled via JSON
1059 //ViewRegistryHelper.Initialize(); //moved to Application side.
1065 Application ret = New(1, stylesheet, windowMode);
1066 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1068 // set the singleton
1073 public static Application NewApplication(string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize)
1079 Application ret = New(1, stylesheet, windowMode, positionSize);
1080 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1082 // set the singleton
1087 public static Application NewApplication(string[] args, string stylesheet, NUIApplication.WindowMode windowMode)
1093 Application ret = New(args, stylesheet, windowMode);
1094 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1096 // set the singleton
1101 public static Application NewApplication(string[] args, string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize)
1107 Application ret = New(args, stylesheet, windowMode, positionSize);
1108 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1110 // set the singleton
1116 /// Ensures that the function passed in is called from the main loop when it is idle.
1118 /// <param name="func">The function to call</param>
1119 /// <returns>true if added successfully, false otherwise</returns>
1120 public bool AddIdle(System.Delegate func)
1122 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
1123 System.IntPtr ip2 = Interop.Application.MakeCallback(new System.Runtime.InteropServices.HandleRef(this, ip));
1125 bool ret = Interop.Application.AddIdle(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip2));
1127 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1132 * Outer::outer_method(int)
1134 public static Application New()
1136 Application ret = new Application(Interop.Application.New(), true);
1137 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1141 public static Application New(int argc)
1143 Application ret = new Application(Interop.Application.New(argc), true);
1144 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1148 public static Application New(int argc, string stylesheet)
1150 Application ret = new Application(Interop.Application.New(argc, stylesheet), true);
1151 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1155 public static Application New(int argc, string stylesheet, NUIApplication.WindowMode windowMode)
1157 Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode), true);
1158 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1163 public static Application New(string[] args, string stylesheet, NUIApplication.WindowMode windowMode)
1165 Application ret = null;
1167 string argvStr = "";
1171 argvStr = string.Join(" ", args);
1173 catch (Exception exception)
1175 Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, msg : " + exception.Message);
1176 Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber());
1177 Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace);
1181 ret = new Application(NDalicPINVOKE.ApplicationNewManual4(argc, argvStr, stylesheet, (int)windowMode), true);
1182 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1187 public static Application New(int argc, string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize)
1189 Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1190 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1194 public static Application New(string[] args, string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize)
1196 Application ret = null;
1198 string argvStr = "";
1202 argvStr = string.Join(" ", args);
1204 catch (Exception exception)
1206 Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, msg : " + exception.Message);
1207 Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber());
1208 Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace);
1212 ret = new Application(NDalicPINVOKE.ApplicationNewWithWindowSizePosition(argc, argvStr, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1213 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1218 public Application() : this(Interop.Application.NewApplication(), true)
1220 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1223 public Application(Application application) : this(Interop.Application.NewApplication(Application.getCPtr(application)), true)
1225 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1228 public Application Assign(Application application)
1230 Application ret = new Application(Interop.Application.Assign(SwigCPtr, Application.getCPtr(application)), false);
1231 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1235 public void MainLoop()
1237 NDalicPINVOKE.ApplicationMainLoop(SwigCPtr);
1238 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1243 Interop.Application.Lower(SwigCPtr);
1244 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1249 Interop.Application.Quit(SwigCPtr);
1250 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1253 internal bool AddIdle(SWIGTYPE_p_Dali__CallbackBase callback)
1255 bool ret = Interop.Application.AddIdle(SwigCPtr, SWIGTYPE_p_Dali__CallbackBase.getCPtr(callback));
1256 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1260 public Window GetWindow()
1262 win = Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindow(SwigCPtr)) as Window;
1265 win = new Window(Interop.Application.GetWindow(SwigCPtr), true);
1268 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1272 public static string GetResourcePath()
1274 string ret = Interop.Application.GetResourcePath();
1275 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1279 public string GetLanguage()
1281 string ret = Interop.Application.GetLanguage(SwigCPtr);
1282 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1286 public string GetRegion()
1288 string ret = Interop.Application.GetRegion(SwigCPtr);
1289 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1293 [EditorBrowsable(EditorBrowsableState.Never)]
1294 public static List<Window> GetWindowList()
1296 uint ListSize = Interop.Application.GetWindowsListSize();
1297 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1299 List<Window> WindowList = new List<Window>();
1300 for (uint i = 0; i < ListSize; ++i)
1302 Window currWin = Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindowsFromList(i)) as Window;
1303 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1306 WindowList.Add(currWin);
1312 internal ApplicationSignal InitSignal()
1314 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationInitSignal(SwigCPtr), false);
1315 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1319 internal ApplicationSignal TerminateSignal()
1321 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationTerminateSignal(SwigCPtr), false);
1322 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1326 internal ApplicationSignal PauseSignal()
1328 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationPauseSignal(SwigCPtr), false);
1329 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1333 internal ApplicationSignal ResumeSignal()
1335 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationResumeSignal(SwigCPtr), false);
1336 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1340 internal ApplicationSignal ResetSignal()
1342 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationResetSignal(SwigCPtr), false);
1343 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1347 internal ApplicationControlSignal AppControlSignal()
1349 ApplicationControlSignal ret = new ApplicationControlSignal(NDalicPINVOKE.ApplicationAppControlSignal(SwigCPtr), false);
1350 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1354 internal ApplicationSignal LanguageChangedSignal()
1356 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationLanguageChangedSignal(SwigCPtr), false);
1357 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1361 internal ApplicationSignal RegionChangedSignal()
1363 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationRegionChangedSignal(SwigCPtr), false);
1364 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1368 internal LowBatterySignalType BatteryLowSignal()
1370 LowBatterySignalType ret = new LowBatterySignalType(NDalicPINVOKE.ApplicationLowBatterySignal(SwigCPtr), false);
1371 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1375 internal LowMemorySignalType MemoryLowSignal()
1377 LowMemorySignalType ret = new LowMemorySignalType(NDalicPINVOKE.ApplicationLowMemorySignal(SwigCPtr), false);
1378 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();