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 internal event EventHandler<ResourcesChangedEventArgs> XamlResourceChanged;
313 internal override void OnResourcesChanged(object sender, ResourcesChangedEventArgs e)
315 base.OnResourcesChanged(sender, e);
316 XamlResourceChanged?.Invoke(sender, e);
319 public ResourceDictionary XamlResources
323 if (resources == null)
325 resources = new ResourceDictionary();
326 int hashCode = resources.GetHashCode();
327 ((IResourceDictionary)resources).ValuesChanged += OnResourcesChanged;
333 if (resources == value)
335 OnPropertyChanging();
337 if (resources != null)
338 ((IResourceDictionary)resources).ValuesChanged -= OnResourcesChanged;
340 OnResourcesChanged(value);
341 if (resources != null)
342 ((IResourceDictionary)resources).ValuesChanged += OnResourcesChanged;
348 protected override void OnParentSet()
350 throw new InvalidOperationException("Setting a Parent on Application is invalid.");
353 [EditorBrowsable(EditorBrowsableState.Never)]
354 public static bool IsApplicationOrNull(Element element)
356 return element == null || element is Application;
359 internal override void OnParentResourcesChanged(IEnumerable<KeyValuePair<string, object>> values)
361 if (!((IResourcesProvider)this).IsResourcesCreated || XamlResources.Count == 0)
363 base.OnParentResourcesChanged(values);
367 var innerKeys = new HashSet<string>();
368 var changedResources = new List<KeyValuePair<string, object>>();
369 foreach (KeyValuePair<string, object> c in XamlResources)
370 innerKeys.Add(c.Key);
371 foreach (KeyValuePair<string, object> value in values)
373 if (innerKeys.Add(value.Key))
374 changedResources.Add(value);
376 OnResourcesChanged(changedResources);
379 internal Application(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
381 SetCurrentApplication(this);
385 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Application obj)
387 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
390 protected override void Dispose(DisposeTypes type)
397 //Release your own unmanaged resources here.
398 //You should not access any managed member here except static instance.
399 //because the execution order of Finalizes is non-deterministic.
400 if (applicationInitEventCallbackDelegate != null)
402 initSignal?.Disconnect(applicationInitEventCallbackDelegate);
403 initSignal?.Dispose();
407 if (applicationTerminateEventCallbackDelegate != null)
409 terminateSignal?.Disconnect(applicationTerminateEventCallbackDelegate);
410 terminateSignal?.Dispose();
411 terminateSignal = null;
414 if (applicationPauseEventCallbackDelegate != null)
416 pauseSignal?.Disconnect(applicationPauseEventCallbackDelegate);
417 pauseSignal?.Dispose();
421 if (applicationResumeEventCallbackDelegate != null)
423 resumeSignal?.Disconnect(applicationResumeEventCallbackDelegate);
424 resumeSignal?.Dispose();
428 if (applicationResetEventCallbackDelegate != null)
430 resetSignal?.Disconnect(applicationResetEventCallbackDelegate);
431 resetSignal?.Dispose();
435 if (applicationLanguageChangedEventCallbackDelegate != null)
437 languageChangedSignal?.Disconnect(applicationLanguageChangedEventCallbackDelegate);
438 languageChangedSignal?.Dispose();
439 languageChangedSignal = null;
442 if (applicationRegionChangedEventCallbackDelegate != null)
444 regionChangedSignal?.Disconnect(applicationRegionChangedEventCallbackDelegate);
445 regionChangedSignal?.Dispose();
446 regionChangedSignal = null;
449 if (applicationBatteryLowEventCallbackDelegate != null)
451 batteryLowSignal?.Disconnect(applicationBatteryLowEventCallbackDelegate);
452 batteryLowSignal?.Dispose();
453 batteryLowSignal = null;
456 if (applicationMemoryLowEventCallbackDelegate != null)
458 memoryLowSignal?.Disconnect(applicationMemoryLowEventCallbackDelegate);
459 memoryLowSignal?.Dispose();
460 memoryLowSignal = null;
463 if (applicationAppControlEventCallbackDelegate != null)
465 appControlSignal?.Disconnect(applicationAppControlEventCallbackDelegate);
466 appControlSignal?.Dispose();
467 appControlSignal = null;
475 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
477 Interop.Application.DeleteApplication(swigCPtr);
480 public enum BatteryStatus
487 public enum MemoryStatus
494 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
495 private delegate void NUIApplicationInitEventCallbackDelegate(IntPtr application);
496 private DaliEventHandler<object, NUIApplicationInitEventArgs> applicationInitEventHandler;
497 private NUIApplicationInitEventCallbackDelegate applicationInitEventCallbackDelegate;
498 private ApplicationSignal initSignal;
500 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
501 private delegate void NUIApplicationTerminateEventCallbackDelegate(IntPtr application);
502 private DaliEventHandler<object, NUIApplicationTerminatingEventArgs> applicationTerminateEventHandler;
503 private NUIApplicationTerminateEventCallbackDelegate applicationTerminateEventCallbackDelegate;
504 private ApplicationSignal terminateSignal;
506 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
507 private delegate void NUIApplicationPauseEventCallbackDelegate(IntPtr application);
508 private DaliEventHandler<object, NUIApplicationPausedEventArgs> applicationPauseEventHandler;
509 private NUIApplicationPauseEventCallbackDelegate applicationPauseEventCallbackDelegate;
510 private ApplicationSignal pauseSignal;
512 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
513 private delegate void NUIApplicationResumeEventCallbackDelegate(IntPtr application);
514 private DaliEventHandler<object, NUIApplicationResumedEventArgs> applicationResumeEventHandler;
515 private NUIApplicationResumeEventCallbackDelegate applicationResumeEventCallbackDelegate;
516 private ApplicationSignal resumeSignal;
518 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
519 private delegate void NUIApplicationResetEventCallbackDelegate(IntPtr application);
520 private DaliEventHandler<object, NUIApplicationResetEventArgs> applicationResetEventHandler;
521 private NUIApplicationResetEventCallbackDelegate applicationResetEventCallbackDelegate;
522 private ApplicationSignal resetSignal;
524 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
525 private delegate void NUIApplicationLanguageChangedEventCallbackDelegate(IntPtr application);
526 private DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> applicationLanguageChangedEventHandler;
527 private NUIApplicationLanguageChangedEventCallbackDelegate applicationLanguageChangedEventCallbackDelegate;
528 private ApplicationSignal languageChangedSignal;
531 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
532 private delegate void NUIApplicationRegionChangedEventCallbackDelegate(IntPtr application);
533 private DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> applicationRegionChangedEventHandler;
534 private NUIApplicationRegionChangedEventCallbackDelegate applicationRegionChangedEventCallbackDelegate;
535 private ApplicationSignal regionChangedSignal;
537 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
538 private delegate void NUIApplicationBatteryLowEventCallbackDelegate(BatteryStatus status);
539 private DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> applicationBatteryLowEventHandler;
540 private NUIApplicationBatteryLowEventCallbackDelegate applicationBatteryLowEventCallbackDelegate;
541 private LowBatterySignalType batteryLowSignal;
543 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
544 private delegate void NUIApplicationMemoryLowEventCallbackDelegate(MemoryStatus status);
545 private DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> applicationMemoryLowEventHandler;
546 private NUIApplicationMemoryLowEventCallbackDelegate applicationMemoryLowEventCallbackDelegate;
547 private LowMemorySignalType memoryLowSignal;
549 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
550 private delegate void NUIApplicationAppControlEventCallbackDelegate(IntPtr application, IntPtr voidp);
551 private DaliEventHandler<object, NUIApplicationAppControlEventArgs> applicationAppControlEventHandler;
552 private NUIApplicationAppControlEventCallbackDelegate applicationAppControlEventCallbackDelegate;
553 private ApplicationControlSignal appControlSignal;
555 private Window window;
558 * @brief Event for Initialized signal which can be used to subscribe/unsubscribe the event handler
559 * provided by the user. Initialized signal is emitted when application is initialized
561 public event DaliEventHandler<object, NUIApplicationInitEventArgs> Initialized
565 // Restricted to only one listener
566 if (applicationInitEventHandler == null)
568 applicationInitEventHandler += value;
569 applicationInitEventCallbackDelegate = new NUIApplicationInitEventCallbackDelegate(OnApplicationInit);
570 initSignal = this.InitSignal();
571 initSignal?.Connect(applicationInitEventCallbackDelegate);
577 if (applicationInitEventHandler != null)
579 initSignal?.Disconnect(applicationInitEventCallbackDelegate);
580 initSignal?.Dispose();
584 applicationInitEventHandler -= value;
588 // Callback for Application InitSignal
589 private void OnApplicationInit(IntPtr data)
591 // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread.
592 DisposeQueue.Instance.Initialize();
593 Window.Instance = GetWindow();
595 // Notify that the window is displayed to the app core.
596 if (NUIApplication.IsPreload)
598 Window.Instance.Show();
601 if (applicationInitEventHandler != null)
603 NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs();
604 e.Application = this;
605 applicationInitEventHandler.Invoke(this, e);
611 * @brief Event for Terminated signal which can be used to subscribe/unsubscribe the event handler
612 * provided by the user. Terminated signal is emitted when application is terminating
614 public event DaliEventHandler<object, NUIApplicationTerminatingEventArgs> Terminating
618 // Restricted to only one listener
619 if (applicationTerminateEventHandler == null)
621 applicationTerminateEventHandler += value;
623 applicationTerminateEventCallbackDelegate = new NUIApplicationTerminateEventCallbackDelegate(OnNUIApplicationTerminate);
624 terminateSignal = this.TerminateSignal();
625 terminateSignal?.Connect(applicationTerminateEventCallbackDelegate);
631 if (applicationTerminateEventHandler != null)
633 terminateSignal?.Disconnect(applicationTerminateEventCallbackDelegate);
634 terminateSignal?.Dispose();
635 terminateSignal = null;
638 applicationTerminateEventHandler -= value;
642 // Callback for Application TerminateSignal
643 private void OnNUIApplicationTerminate(IntPtr data)
645 if (applicationTerminateEventHandler != null)
647 NUIApplicationTerminatingEventArgs e = new NUIApplicationTerminatingEventArgs();
648 e.Application = this;
649 applicationTerminateEventHandler.Invoke(this, e);
652 List<Window> windows = GetWindowList();
653 foreach (Window window in windows)
655 window?.DisconnectNativeSignals();
660 * @brief Event for Paused signal which can be used to subscribe/unsubscribe the event handler
661 * provided by the user. Paused signal is emitted when application is paused
663 public event DaliEventHandler<object, NUIApplicationPausedEventArgs> Paused
667 // Restricted to only one listener
668 if (applicationPauseEventHandler == null)
670 applicationPauseEventHandler += value;
672 applicationPauseEventCallbackDelegate = new NUIApplicationPauseEventCallbackDelegate(OnNUIApplicationPause);
673 pauseSignal = this.PauseSignal();
674 pauseSignal?.Connect(applicationPauseEventCallbackDelegate);
680 if (applicationPauseEventHandler != null)
682 pauseSignal?.Disconnect(applicationPauseEventCallbackDelegate);
683 pauseSignal?.Dispose();
687 applicationPauseEventHandler -= value;
691 // Callback for Application PauseSignal
692 private void OnNUIApplicationPause(IntPtr data)
694 if (applicationPauseEventHandler != null)
696 NUIApplicationPausedEventArgs e = new NUIApplicationPausedEventArgs();
697 e.Application = this;
698 applicationPauseEventHandler.Invoke(this, e);
703 * @brief Event for Resumed signal which can be used to subscribe/unsubscribe the event handler
704 * provided by the user. Resumed signal is emitted when application is resumed
706 public event DaliEventHandler<object, NUIApplicationResumedEventArgs> Resumed
710 // Restricted to only one listener
711 if (applicationResumeEventHandler == null)
713 applicationResumeEventHandler += value;
715 applicationResumeEventCallbackDelegate = new NUIApplicationResumeEventCallbackDelegate(OnNUIApplicationResume);
716 resumeSignal = this.ResumeSignal();
717 resumeSignal?.Connect(applicationResumeEventCallbackDelegate);
723 if (applicationResumeEventHandler != null)
725 resumeSignal?.Disconnect(applicationResumeEventCallbackDelegate);
726 resumeSignal?.Dispose();
730 applicationResumeEventHandler -= value;
734 // Callback for Application ResumeSignal
735 private void OnNUIApplicationResume(IntPtr data)
737 if (applicationResumeEventHandler != null)
739 NUIApplicationResumedEventArgs e = new NUIApplicationResumedEventArgs();
740 e.Application = this;
741 applicationResumeEventHandler.Invoke(this, e);
746 * @brief Event for Reset signal which can be used to subscribe/unsubscribe the event handler
747 * provided by the user. Reset signal is emitted when application is reset
749 public new event DaliEventHandler<object, NUIApplicationResetEventArgs> Reset
753 // Restricted to only one listener
754 if (applicationResetEventHandler == null)
756 applicationResetEventHandler += value;
758 applicationResetEventCallbackDelegate = new NUIApplicationResetEventCallbackDelegate(OnNUIApplicationReset);
759 resetSignal = this.ResetSignal();
760 resetSignal?.Connect(applicationResetEventCallbackDelegate);
766 if (applicationResetEventHandler != null)
768 resetSignal?.Disconnect(applicationResetEventCallbackDelegate);
769 resetSignal?.Dispose();
773 applicationResetEventHandler -= value;
777 // Callback for Application ResetSignal
778 private void OnNUIApplicationReset(IntPtr data)
780 if (applicationResetEventHandler != null)
782 NUIApplicationResetEventArgs e = new NUIApplicationResetEventArgs();
783 e.Application = this;
784 applicationResetEventHandler.Invoke(this, e);
789 * @brief Event for LanguageChanged signal which can be used to subscribe/unsubscribe the event handler
790 * provided by the user. LanguageChanged signal is emitted when the region of the device is changed.
792 public event DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> LanguageChanged
796 // Restricted to only one listener
797 if (applicationLanguageChangedEventHandler == null)
799 applicationLanguageChangedEventHandler += value;
801 applicationLanguageChangedEventCallbackDelegate = new NUIApplicationLanguageChangedEventCallbackDelegate(OnNUIApplicationLanguageChanged);
802 languageChangedSignal = this.LanguageChangedSignal();
803 languageChangedSignal?.Connect(applicationLanguageChangedEventCallbackDelegate);
809 if (applicationLanguageChangedEventHandler != null)
811 languageChangedSignal?.Disconnect(applicationLanguageChangedEventCallbackDelegate);
812 languageChangedSignal?.Dispose();
813 languageChangedSignal = null;
816 applicationLanguageChangedEventHandler -= value;
820 // Callback for Application LanguageChangedSignal
821 private void OnNUIApplicationLanguageChanged(IntPtr data)
823 if (applicationLanguageChangedEventHandler != null)
825 NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs();
826 e.Application = this;
827 applicationLanguageChangedEventHandler.Invoke(this, e);
832 * @brief Event for RegionChanged signal which can be used to subscribe/unsubscribe the event handler
833 * provided by the user. RegionChanged signal is emitted when the region of the device is changed.
835 public event DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> RegionChanged
839 // Restricted to only one listener
840 if (applicationRegionChangedEventHandler == null)
842 applicationRegionChangedEventHandler += value;
844 applicationRegionChangedEventCallbackDelegate = new NUIApplicationRegionChangedEventCallbackDelegate(OnNUIApplicationRegionChanged);
845 regionChangedSignal = this.RegionChangedSignal();
846 regionChangedSignal?.Connect(applicationRegionChangedEventCallbackDelegate);
852 if (applicationRegionChangedEventHandler != null)
854 regionChangedSignal?.Disconnect(applicationRegionChangedEventCallbackDelegate);
855 regionChangedSignal?.Dispose();
856 regionChangedSignal = null;
859 applicationRegionChangedEventHandler -= value;
863 // Callback for Application RegionChangedSignal
864 private void OnNUIApplicationRegionChanged(IntPtr data)
866 if (applicationRegionChangedEventHandler != null)
868 NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs();
869 e.Application = this;
870 applicationRegionChangedEventHandler.Invoke(this, e);
875 * @brief Event for BatteryLow signal which can be used to subscribe/unsubscribe the event handler
876 * provided by the user. BatteryLow signal is emitted when the battery level of the device is low.
878 public event DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> BatteryLow
882 // Restricted to only one listener
883 if (applicationBatteryLowEventHandler == null)
885 applicationBatteryLowEventHandler += value;
887 applicationBatteryLowEventCallbackDelegate = new NUIApplicationBatteryLowEventCallbackDelegate(OnNUIApplicationBatteryLow);
888 batteryLowSignal = this.BatteryLowSignal();
889 batteryLowSignal?.Connect(applicationBatteryLowEventCallbackDelegate);
895 if (applicationBatteryLowEventHandler != null)
897 batteryLowSignal?.Disconnect(applicationBatteryLowEventCallbackDelegate);
898 batteryLowSignal?.Dispose();
899 batteryLowSignal = null;
902 applicationBatteryLowEventHandler -= value;
906 // Callback for Application BatteryLowSignal
907 private void OnNUIApplicationBatteryLow(BatteryStatus status)
909 NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
911 // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
912 e.BatteryStatus = status;
913 applicationBatteryLowEventHandler?.Invoke(this, e);
917 * @brief Event for MemoryLow signal which can be used to subscribe/unsubscribe the event handler
918 * provided by the user. MemoryLow signal is emitted when the memory level of the device is low.
920 public event DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> MemoryLow
924 // Restricted to only one listener
925 if (applicationMemoryLowEventHandler == null)
927 applicationMemoryLowEventHandler += value;
929 applicationMemoryLowEventCallbackDelegate = new NUIApplicationMemoryLowEventCallbackDelegate(OnNUIApplicationMemoryLow);
930 memoryLowSignal = this.MemoryLowSignal();
931 memoryLowSignal?.Connect(applicationMemoryLowEventCallbackDelegate);
937 if (applicationMemoryLowEventHandler != null)
939 memoryLowSignal?.Disconnect(applicationMemoryLowEventCallbackDelegate);
940 memoryLowSignal?.Dispose();
941 memoryLowSignal = null;
944 applicationMemoryLowEventHandler -= value;
948 // Callback for Application MemoryLowSignal
949 private void OnNUIApplicationMemoryLow(MemoryStatus status)
951 NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
953 // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
954 e.MemoryStatus = status;
955 applicationMemoryLowEventHandler?.Invoke(this, e);
959 * @brief Event for AppControl signal which can be used to subscribe/unsubscribe the event handler
960 * provided by the user. AppControl signal is emitted when another application sends a launch request to the application.
962 public event DaliEventHandler<object, NUIApplicationAppControlEventArgs> AppControl
966 // Restricted to only one listener
967 if (applicationAppControlEventHandler == null)
969 applicationAppControlEventHandler += value;
971 applicationAppControlEventCallbackDelegate = new NUIApplicationAppControlEventCallbackDelegate(OnNUIApplicationAppControl);
972 appControlSignal = this.AppControlSignal();
973 appControlSignal?.Connect(applicationAppControlEventCallbackDelegate);
979 if (applicationAppControlEventHandler != null)
981 appControlSignal?.Disconnect(applicationAppControlEventCallbackDelegate);
982 appControlSignal?.Dispose();
983 appControlSignal = null;
986 applicationAppControlEventHandler -= value;
990 // Callback for Application AppControlSignal
991 private void OnNUIApplicationAppControl(IntPtr application, IntPtr voidp)
993 if (applicationAppControlEventHandler != null)
995 NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs();
997 e.Application = this;
998 applicationAppControlEventHandler.Invoke(this, e);
1002 protected static Application instance; // singleton
1004 public static Application Instance
1012 public static Application GetApplicationFromPtr(global::System.IntPtr cPtr)
1014 if (cPtr == global::System.IntPtr.Zero)
1019 Application ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Application;
1020 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1024 public static Application NewApplication()
1026 return NewApplication("", NUIApplication.WindowMode.Opaque);
1029 public static Application NewApplication(string stylesheet)
1031 return NewApplication(stylesheet, NUIApplication.WindowMode.Opaque);
1034 public static Application NewApplication(string stylesheet, NUIApplication.WindowMode windowMode)
1036 // register all Views with the type registry, so that can be created / styled via JSON
1037 //ViewRegistryHelper.Initialize(); //moved to Application side.
1043 Application ret = New(1, stylesheet, windowMode);
1044 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1046 // set the singleton
1051 public static Application NewApplication(string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize)
1057 Application ret = New(1, stylesheet, windowMode, positionSize);
1058 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1060 // set the singleton
1065 public static Application NewApplication(string[] args, string stylesheet, NUIApplication.WindowMode windowMode)
1071 Application ret = New(args, stylesheet, windowMode);
1072 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1074 // set the singleton
1079 public static Application NewApplication(string[] args, string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize)
1085 Application ret = New(args, stylesheet, windowMode, positionSize);
1086 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1088 // set the singleton
1094 /// Ensures that the function passed in is called from the main loop when it is idle.
1096 /// <param name="func">The function to call</param>
1097 /// <returns>true if added successfully, false otherwise</returns>
1098 public bool AddIdle(System.Delegate func)
1100 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
1101 System.IntPtr ip2 = Interop.Application.MakeCallback(new System.Runtime.InteropServices.HandleRef(this, ip));
1103 bool ret = Interop.Application.AddIdle(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip2));
1105 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1110 * Outer::outer_method(int)
1112 public static Application New()
1114 Application ret = new Application(Interop.Application.New(), true);
1115 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1119 public static Application New(int argc)
1121 Application ret = new Application(Interop.Application.New(argc), true);
1122 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1126 public static Application New(int argc, string stylesheet)
1128 Application ret = new Application(Interop.Application.New(argc, stylesheet), true);
1129 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1133 public static Application New(int argc, string stylesheet, NUIApplication.WindowMode windowMode)
1135 Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode), true);
1136 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1141 public static Application New(string[] args, string stylesheet, NUIApplication.WindowMode windowMode)
1143 Application ret = null;
1145 string argvStr = "";
1149 argvStr = string.Join(" ", args);
1151 catch (Exception exception)
1153 Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, message : " + exception.Message);
1154 Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber());
1155 Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace);
1159 ret = new Application(NDalicPINVOKE.ApplicationNewManual4(argc, argvStr, stylesheet, (int)windowMode), true);
1160 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1165 public static Application New(int argc, string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize)
1167 Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1168 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1172 public static Application New(string[] args, string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize)
1174 Application ret = null;
1176 string argvStr = "";
1180 argvStr = string.Join(" ", args);
1182 catch (Exception exception)
1184 Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, message : " + exception.Message);
1185 Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber());
1186 Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace);
1190 ret = new Application(NDalicPINVOKE.ApplicationNewWithWindowSizePosition(argc, argvStr, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1191 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1196 public Application() : this(Interop.Application.NewApplication(), true)
1198 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1201 public Application(Application application) : this(Interop.Application.NewApplication(Application.getCPtr(application)), true)
1203 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1206 public Application Assign(Application application)
1208 Application ret = new Application(Interop.Application.Assign(SwigCPtr, Application.getCPtr(application)), false);
1209 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1213 public void MainLoop()
1215 NDalicPINVOKE.ApplicationMainLoop(SwigCPtr);
1216 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1221 Interop.Application.Lower(SwigCPtr);
1222 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1227 Interop.Application.Quit(SwigCPtr);
1228 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1231 internal bool AddIdle(SWIGTYPE_p_Dali__CallbackBase callback)
1233 bool ret = Interop.Application.AddIdle(SwigCPtr, SWIGTYPE_p_Dali__CallbackBase.getCPtr(callback));
1234 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1238 public Window GetWindow()
1245 window = (Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindow(SwigCPtr)) as Window) ?? new Window(Interop.Application.GetWindow(SwigCPtr), true);
1247 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1251 public static string GetResourcePath()
1253 string ret = Interop.Application.GetResourcePath();
1254 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1258 public string GetLanguage()
1260 string ret = Interop.Application.GetLanguage(SwigCPtr);
1261 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1265 public string GetRegion()
1267 string ret = Interop.Application.GetRegion(SwigCPtr);
1268 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1272 [EditorBrowsable(EditorBrowsableState.Never)]
1273 public static List<Window> GetWindowList()
1275 uint ListSize = Interop.Application.GetWindowsListSize();
1276 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1278 List<Window> WindowList = new List<Window>();
1279 for (uint i = 0; i < ListSize; ++i)
1281 Window currWin = Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindowsFromList(i)) as Window;
1282 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1285 WindowList.Add(currWin);
1291 internal ApplicationSignal InitSignal()
1293 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationInitSignal(SwigCPtr), false);
1294 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1298 internal ApplicationSignal TerminateSignal()
1300 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationTerminateSignal(SwigCPtr), false);
1301 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1305 internal ApplicationSignal PauseSignal()
1307 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationPauseSignal(SwigCPtr), false);
1308 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1312 internal ApplicationSignal ResumeSignal()
1314 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationResumeSignal(SwigCPtr), false);
1315 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1319 internal ApplicationSignal ResetSignal()
1321 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationResetSignal(SwigCPtr), false);
1322 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1326 internal ApplicationControlSignal AppControlSignal()
1328 ApplicationControlSignal ret = new ApplicationControlSignal(NDalicPINVOKE.ApplicationAppControlSignal(SwigCPtr), false);
1329 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1333 internal ApplicationSignal LanguageChangedSignal()
1335 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationLanguageChangedSignal(SwigCPtr), false);
1336 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1340 internal ApplicationSignal RegionChangedSignal()
1342 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationRegionChangedSignal(SwigCPtr), false);
1343 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1347 internal LowBatterySignalType BatteryLowSignal()
1349 LowBatterySignalType ret = new LowBatterySignalType(NDalicPINVOKE.ApplicationLowBatterySignal(SwigCPtr), false);
1350 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1354 internal LowMemorySignalType MemoryLowSignal()
1356 LowMemorySignalType ret = new LowMemorySignalType(NDalicPINVOKE.ApplicationLowMemorySignal(SwigCPtr), false);
1357 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();