2 * Copyright(c) 2022 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 override void OnResourcesChanged(object sender, ResourcesChangedEventArgs e)
313 base.OnResourcesChanged(sender, e);
316 public ResourceDictionary XamlResources
320 if (resources == null)
322 resources = new ResourceDictionary();
323 int hashCode = resources.GetHashCode();
324 ((IResourceDictionary)resources).ValuesChanged += OnResourcesChanged;
330 if (resources == value)
332 OnPropertyChanging();
334 if (resources != null)
335 ((IResourceDictionary)resources).ValuesChanged -= OnResourcesChanged;
337 OnResourcesChanged(value);
338 if (resources != null)
339 ((IResourceDictionary)resources).ValuesChanged += OnResourcesChanged;
345 protected override void OnParentSet()
347 throw new InvalidOperationException("Setting a Parent on Application is invalid.");
350 [EditorBrowsable(EditorBrowsableState.Never)]
351 public static bool IsApplicationOrNull(Element element)
353 return element == null || element is Application;
356 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 if (changedResources.Count != 0)
377 OnResourcesChanged(changedResources);
380 internal Application(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
382 SetCurrentApplication(this);
386 protected override void Dispose(DisposeTypes type)
393 //Release your own unmanaged resources here.
394 //You should not access any managed member here except static instance.
395 //because the execution order of Finalizes is non-deterministic.
396 if (applicationInitEventCallbackDelegate != null)
398 initSignal?.Disconnect(applicationInitEventCallbackDelegate);
399 initSignal?.Dispose();
403 if (applicationTerminateEventCallbackDelegate != null)
405 terminateSignal?.Disconnect(applicationTerminateEventCallbackDelegate);
406 terminateSignal?.Dispose();
407 terminateSignal = null;
410 if (applicationPauseEventCallbackDelegate != null)
412 pauseSignal?.Disconnect(applicationPauseEventCallbackDelegate);
413 pauseSignal?.Dispose();
417 if (applicationResumeEventCallbackDelegate != null)
419 resumeSignal?.Disconnect(applicationResumeEventCallbackDelegate);
420 resumeSignal?.Dispose();
424 if (applicationResetEventCallbackDelegate != null)
426 resetSignal?.Disconnect(applicationResetEventCallbackDelegate);
427 resetSignal?.Dispose();
431 if (applicationLanguageChangedEventCallbackDelegate != null)
433 languageChangedSignal?.Disconnect(applicationLanguageChangedEventCallbackDelegate);
434 languageChangedSignal?.Dispose();
435 languageChangedSignal = null;
438 if (applicationRegionChangedEventCallbackDelegate != null)
440 regionChangedSignal?.Disconnect(applicationRegionChangedEventCallbackDelegate);
441 regionChangedSignal?.Dispose();
442 regionChangedSignal = null;
445 if (applicationBatteryLowEventCallbackDelegate != null)
447 batteryLowSignal?.Disconnect(applicationBatteryLowEventCallbackDelegate);
448 batteryLowSignal?.Dispose();
449 batteryLowSignal = null;
452 if (applicationMemoryLowEventCallbackDelegate != null)
454 memoryLowSignal?.Disconnect(applicationMemoryLowEventCallbackDelegate);
455 memoryLowSignal?.Dispose();
456 memoryLowSignal = null;
459 if (applicationAppControlEventCallbackDelegate != null)
461 appControlSignal?.Disconnect(applicationAppControlEventCallbackDelegate);
462 appControlSignal?.Dispose();
463 appControlSignal = null;
471 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
473 Interop.Application.DeleteApplication(swigCPtr);
476 public enum BatteryStatus
483 public enum MemoryStatus
490 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
491 private delegate void NUIApplicationInitEventCallbackDelegate(IntPtr application);
492 private DaliEventHandler<object, NUIApplicationInitEventArgs> applicationInitEventHandler;
493 private NUIApplicationInitEventCallbackDelegate applicationInitEventCallbackDelegate;
494 private ApplicationSignal initSignal;
496 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
497 private delegate void NUIApplicationTerminateEventCallbackDelegate(IntPtr application);
498 private DaliEventHandler<object, NUIApplicationTerminatingEventArgs> applicationTerminateEventHandler;
499 private NUIApplicationTerminateEventCallbackDelegate applicationTerminateEventCallbackDelegate;
500 private ApplicationSignal terminateSignal;
502 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
503 private delegate void NUIApplicationPauseEventCallbackDelegate(IntPtr application);
504 private DaliEventHandler<object, NUIApplicationPausedEventArgs> applicationPauseEventHandler;
505 private NUIApplicationPauseEventCallbackDelegate applicationPauseEventCallbackDelegate;
506 private ApplicationSignal pauseSignal;
508 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
509 private delegate void NUIApplicationResumeEventCallbackDelegate(IntPtr application);
510 private DaliEventHandler<object, NUIApplicationResumedEventArgs> applicationResumeEventHandler;
511 private NUIApplicationResumeEventCallbackDelegate applicationResumeEventCallbackDelegate;
512 private ApplicationSignal resumeSignal;
514 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
515 private delegate void NUIApplicationResetEventCallbackDelegate(IntPtr application);
516 private DaliEventHandler<object, NUIApplicationResetEventArgs> applicationResetEventHandler;
517 private NUIApplicationResetEventCallbackDelegate applicationResetEventCallbackDelegate;
518 private ApplicationSignal resetSignal;
520 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
521 private delegate void NUIApplicationLanguageChangedEventCallbackDelegate(IntPtr application);
522 private DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> applicationLanguageChangedEventHandler;
523 private NUIApplicationLanguageChangedEventCallbackDelegate applicationLanguageChangedEventCallbackDelegate;
524 private ApplicationSignal languageChangedSignal;
527 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
528 private delegate void NUIApplicationRegionChangedEventCallbackDelegate(IntPtr application);
529 private DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> applicationRegionChangedEventHandler;
530 private NUIApplicationRegionChangedEventCallbackDelegate applicationRegionChangedEventCallbackDelegate;
531 private ApplicationSignal regionChangedSignal;
533 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
534 private delegate void NUIApplicationBatteryLowEventCallbackDelegate(BatteryStatus status);
535 private DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> applicationBatteryLowEventHandler;
536 private NUIApplicationBatteryLowEventCallbackDelegate applicationBatteryLowEventCallbackDelegate;
537 private LowBatterySignalType batteryLowSignal;
539 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
540 private delegate void NUIApplicationMemoryLowEventCallbackDelegate(MemoryStatus status);
541 private DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> applicationMemoryLowEventHandler;
542 private NUIApplicationMemoryLowEventCallbackDelegate applicationMemoryLowEventCallbackDelegate;
543 private LowMemorySignalType memoryLowSignal;
545 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
546 private delegate void NUIApplicationAppControlEventCallbackDelegate(IntPtr application, IntPtr voidp);
547 private DaliEventHandler<object, NUIApplicationAppControlEventArgs> applicationAppControlEventHandler;
548 private NUIApplicationAppControlEventCallbackDelegate applicationAppControlEventCallbackDelegate;
549 private ApplicationControlSignal appControlSignal;
551 private Window window;
554 * @brief Event for Initialized signal which can be used to subscribe/unsubscribe the event handler
555 * provided by the user. Initialized signal is emitted when application is initialized
557 public event DaliEventHandler<object, NUIApplicationInitEventArgs> Initialized
561 // Restricted to only one listener
562 if (applicationInitEventHandler == null)
564 applicationInitEventHandler += value;
565 applicationInitEventCallbackDelegate = new NUIApplicationInitEventCallbackDelegate(OnApplicationInit);
566 initSignal = this.InitSignal();
567 initSignal?.Connect(applicationInitEventCallbackDelegate);
573 if (applicationInitEventHandler != null)
575 initSignal?.Disconnect(applicationInitEventCallbackDelegate);
576 initSignal?.Dispose();
580 applicationInitEventHandler -= value;
584 // Callback for Application InitSignal
585 private void OnApplicationInit(IntPtr data)
587 // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread.
588 DisposeQueue.Instance.Initialize();
589 Window.Instance = GetWindow();
591 // Notify that the window is displayed to the app core.
592 if (NUIApplication.IsPreload)
594 Window.Instance.Show();
597 if (applicationInitEventHandler != null)
599 NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs();
600 e.Application = this;
601 applicationInitEventHandler.Invoke(this, e);
607 * @brief Event for Terminated signal which can be used to subscribe/unsubscribe the event handler
608 * provided by the user. Terminated signal is emitted when application is terminating
610 public event DaliEventHandler<object, NUIApplicationTerminatingEventArgs> Terminating
614 // Restricted to only one listener
615 if (applicationTerminateEventHandler == null)
617 applicationTerminateEventHandler += value;
619 applicationTerminateEventCallbackDelegate = new NUIApplicationTerminateEventCallbackDelegate(OnNUIApplicationTerminate);
620 terminateSignal = this.TerminateSignal();
621 terminateSignal?.Connect(applicationTerminateEventCallbackDelegate);
627 if (applicationTerminateEventHandler != null)
629 terminateSignal?.Disconnect(applicationTerminateEventCallbackDelegate);
630 terminateSignal?.Dispose();
631 terminateSignal = null;
634 applicationTerminateEventHandler -= value;
638 // Callback for Application TerminateSignal
639 private void OnNUIApplicationTerminate(IntPtr data)
641 if (applicationTerminateEventHandler != null)
643 NUIApplicationTerminatingEventArgs e = new NUIApplicationTerminatingEventArgs();
644 e.Application = this;
645 applicationTerminateEventHandler.Invoke(this, e);
648 List<Window> windows = GetWindowList();
649 foreach (Window window in windows)
651 window?.DisconnectNativeSignals();
656 * @brief Event for Paused signal which can be used to subscribe/unsubscribe the event handler
657 * provided by the user. Paused signal is emitted when application is paused
659 public event DaliEventHandler<object, NUIApplicationPausedEventArgs> Paused
663 // Restricted to only one listener
664 if (applicationPauseEventHandler == null)
666 applicationPauseEventHandler += value;
668 applicationPauseEventCallbackDelegate = new NUIApplicationPauseEventCallbackDelegate(OnNUIApplicationPause);
669 pauseSignal = this.PauseSignal();
670 pauseSignal?.Connect(applicationPauseEventCallbackDelegate);
676 if (applicationPauseEventHandler != null)
678 pauseSignal?.Disconnect(applicationPauseEventCallbackDelegate);
679 pauseSignal?.Dispose();
683 applicationPauseEventHandler -= value;
687 // Callback for Application PauseSignal
688 private void OnNUIApplicationPause(IntPtr data)
690 if (applicationPauseEventHandler != null)
692 NUIApplicationPausedEventArgs e = new NUIApplicationPausedEventArgs();
693 e.Application = this;
694 applicationPauseEventHandler.Invoke(this, e);
699 * @brief Event for Resumed signal which can be used to subscribe/unsubscribe the event handler
700 * provided by the user. Resumed signal is emitted when application is resumed
702 public event DaliEventHandler<object, NUIApplicationResumedEventArgs> Resumed
706 // Restricted to only one listener
707 if (applicationResumeEventHandler == null)
709 applicationResumeEventHandler += value;
711 applicationResumeEventCallbackDelegate = new NUIApplicationResumeEventCallbackDelegate(OnNUIApplicationResume);
712 resumeSignal = this.ResumeSignal();
713 resumeSignal?.Connect(applicationResumeEventCallbackDelegate);
719 if (applicationResumeEventHandler != null)
721 resumeSignal?.Disconnect(applicationResumeEventCallbackDelegate);
722 resumeSignal?.Dispose();
726 applicationResumeEventHandler -= value;
730 // Callback for Application ResumeSignal
731 private void OnNUIApplicationResume(IntPtr data)
733 if (applicationResumeEventHandler != null)
735 NUIApplicationResumedEventArgs e = new NUIApplicationResumedEventArgs();
736 e.Application = this;
737 applicationResumeEventHandler.Invoke(this, e);
742 * @brief Event for Reset signal which can be used to subscribe/unsubscribe the event handler
743 * provided by the user. Reset signal is emitted when application is reset
745 public new event DaliEventHandler<object, NUIApplicationResetEventArgs> Reset
749 // Restricted to only one listener
750 if (applicationResetEventHandler == null)
752 applicationResetEventHandler += value;
754 applicationResetEventCallbackDelegate = new NUIApplicationResetEventCallbackDelegate(OnNUIApplicationReset);
755 resetSignal = this.ResetSignal();
756 resetSignal?.Connect(applicationResetEventCallbackDelegate);
762 if (applicationResetEventHandler != null)
764 resetSignal?.Disconnect(applicationResetEventCallbackDelegate);
765 resetSignal?.Dispose();
769 applicationResetEventHandler -= value;
773 // Callback for Application ResetSignal
774 private void OnNUIApplicationReset(IntPtr data)
776 if (applicationResetEventHandler != null)
778 NUIApplicationResetEventArgs e = new NUIApplicationResetEventArgs();
779 e.Application = this;
780 applicationResetEventHandler.Invoke(this, e);
785 * @brief Event for LanguageChanged signal which can be used to subscribe/unsubscribe the event handler
786 * provided by the user. LanguageChanged signal is emitted when the region of the device is changed.
788 public event DaliEventHandler<object, NUIApplicationLanguageChangedEventArgs> LanguageChanged
792 // Restricted to only one listener
793 if (applicationLanguageChangedEventHandler == null)
795 applicationLanguageChangedEventHandler += value;
797 applicationLanguageChangedEventCallbackDelegate = new NUIApplicationLanguageChangedEventCallbackDelegate(OnNUIApplicationLanguageChanged);
798 languageChangedSignal = this.LanguageChangedSignal();
799 languageChangedSignal?.Connect(applicationLanguageChangedEventCallbackDelegate);
805 if (applicationLanguageChangedEventHandler != null)
807 languageChangedSignal?.Disconnect(applicationLanguageChangedEventCallbackDelegate);
808 languageChangedSignal?.Dispose();
809 languageChangedSignal = null;
812 applicationLanguageChangedEventHandler -= value;
816 // Callback for Application LanguageChangedSignal
817 private void OnNUIApplicationLanguageChanged(IntPtr data)
819 if (applicationLanguageChangedEventHandler != null)
821 NUIApplicationLanguageChangedEventArgs e = new NUIApplicationLanguageChangedEventArgs();
822 e.Application = this;
823 applicationLanguageChangedEventHandler.Invoke(this, e);
828 * @brief Event for RegionChanged signal which can be used to subscribe/unsubscribe the event handler
829 * provided by the user. RegionChanged signal is emitted when the region of the device is changed.
831 public event DaliEventHandler<object, NUIApplicationRegionChangedEventArgs> RegionChanged
835 // Restricted to only one listener
836 if (applicationRegionChangedEventHandler == null)
838 applicationRegionChangedEventHandler += value;
840 applicationRegionChangedEventCallbackDelegate = new NUIApplicationRegionChangedEventCallbackDelegate(OnNUIApplicationRegionChanged);
841 regionChangedSignal = this.RegionChangedSignal();
842 regionChangedSignal?.Connect(applicationRegionChangedEventCallbackDelegate);
848 if (applicationRegionChangedEventHandler != null)
850 regionChangedSignal?.Disconnect(applicationRegionChangedEventCallbackDelegate);
851 regionChangedSignal?.Dispose();
852 regionChangedSignal = null;
855 applicationRegionChangedEventHandler -= value;
859 // Callback for Application RegionChangedSignal
860 private void OnNUIApplicationRegionChanged(IntPtr data)
862 if (applicationRegionChangedEventHandler != null)
864 NUIApplicationRegionChangedEventArgs e = new NUIApplicationRegionChangedEventArgs();
865 e.Application = this;
866 applicationRegionChangedEventHandler.Invoke(this, e);
871 * @brief Event for BatteryLow signal which can be used to subscribe/unsubscribe the event handler
872 * provided by the user. BatteryLow signal is emitted when the battery level of the device is low.
874 public event DaliEventHandler<object, NUIApplicationBatteryLowEventArgs> BatteryLow
878 // Restricted to only one listener
879 if (applicationBatteryLowEventHandler == null)
881 applicationBatteryLowEventHandler += value;
883 applicationBatteryLowEventCallbackDelegate = new NUIApplicationBatteryLowEventCallbackDelegate(OnNUIApplicationBatteryLow);
884 batteryLowSignal = this.BatteryLowSignal();
885 batteryLowSignal?.Connect(applicationBatteryLowEventCallbackDelegate);
891 if (applicationBatteryLowEventHandler != null)
893 batteryLowSignal?.Disconnect(applicationBatteryLowEventCallbackDelegate);
894 batteryLowSignal?.Dispose();
895 batteryLowSignal = null;
898 applicationBatteryLowEventHandler -= value;
902 // Callback for Application BatteryLowSignal
903 private void OnNUIApplicationBatteryLow(BatteryStatus status)
905 NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
907 // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
908 e.BatteryStatus = status;
909 applicationBatteryLowEventHandler?.Invoke(this, e);
913 * @brief Event for MemoryLow signal which can be used to subscribe/unsubscribe the event handler
914 * provided by the user. MemoryLow signal is emitted when the memory level of the device is low.
916 public event DaliEventHandler<object, NUIApplicationMemoryLowEventArgs> MemoryLow
920 // Restricted to only one listener
921 if (applicationMemoryLowEventHandler == null)
923 applicationMemoryLowEventHandler += value;
925 applicationMemoryLowEventCallbackDelegate = new NUIApplicationMemoryLowEventCallbackDelegate(OnNUIApplicationMemoryLow);
926 memoryLowSignal = this.MemoryLowSignal();
927 memoryLowSignal?.Connect(applicationMemoryLowEventCallbackDelegate);
933 if (applicationMemoryLowEventHandler != null)
935 memoryLowSignal?.Disconnect(applicationMemoryLowEventCallbackDelegate);
936 memoryLowSignal?.Dispose();
937 memoryLowSignal = null;
940 applicationMemoryLowEventHandler -= value;
944 // Callback for Application MemoryLowSignal
945 private void OnNUIApplicationMemoryLow(MemoryStatus status)
947 NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
949 // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
950 e.MemoryStatus = status;
951 applicationMemoryLowEventHandler?.Invoke(this, e);
955 * @brief Event for AppControl signal which can be used to subscribe/unsubscribe the event handler
956 * provided by the user. AppControl signal is emitted when another application sends a launch request to the application.
958 public event DaliEventHandler<object, NUIApplicationAppControlEventArgs> AppControl
962 // Restricted to only one listener
963 if (applicationAppControlEventHandler == null)
965 applicationAppControlEventHandler += value;
967 applicationAppControlEventCallbackDelegate = new NUIApplicationAppControlEventCallbackDelegate(OnNUIApplicationAppControl);
968 appControlSignal = this.AppControlSignal();
969 appControlSignal?.Connect(applicationAppControlEventCallbackDelegate);
975 if (applicationAppControlEventHandler != null)
977 appControlSignal?.Disconnect(applicationAppControlEventCallbackDelegate);
978 appControlSignal?.Dispose();
979 appControlSignal = null;
982 applicationAppControlEventHandler -= value;
986 // Callback for Application AppControlSignal
987 private void OnNUIApplicationAppControl(IntPtr application, IntPtr voidp)
989 if (applicationAppControlEventHandler != null)
991 NUIApplicationAppControlEventArgs e = new NUIApplicationAppControlEventArgs();
993 e.Application = this;
994 applicationAppControlEventHandler.Invoke(this, e);
998 protected static Application instance; // singleton
1000 public static Application Instance
1008 public static Application GetApplicationFromPtr(global::System.IntPtr cPtr)
1010 if (cPtr == global::System.IntPtr.Zero)
1015 Application ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Application;
1016 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1020 public static Application NewApplication()
1022 return NewApplication("", NUIApplication.WindowMode.Opaque);
1025 public static Application NewApplication(string stylesheet)
1027 return NewApplication(stylesheet, NUIApplication.WindowMode.Opaque);
1030 public static Application NewApplication(string stylesheet, NUIApplication.WindowMode windowMode)
1032 // register all Views with the type registry, so that can be created / styled via JSON
1033 //ViewRegistryHelper.Initialize(); //moved to Application side.
1034 if (instance != null)
1039 Application ret = New(1, stylesheet, windowMode);
1040 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1042 // set the singleton
1047 public static Application NewApplication(string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize)
1049 if (instance != null)
1053 Application ret = New(1, stylesheet, windowMode, positionSize);
1054 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1056 // set the singleton
1061 public static Application NewApplication(string[] args, string stylesheet, NUIApplication.WindowMode windowMode)
1063 if (instance != null)
1067 Application ret = New(args, stylesheet, windowMode);
1068 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1070 // set the singleton
1075 public static Application NewApplication(string[] args, string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize)
1077 if (instance != null)
1081 Application ret = New(args, stylesheet, windowMode, positionSize);
1082 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1084 // set the singleton
1089 public static Application NewApplication(string stylesheet, NUIApplication.WindowMode windowMode, WindowType type)
1091 if (instance != null)
1095 Application ret = New(1, stylesheet, windowMode, type);
1096 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1103 /// Ensures that the function passed in is called from the main loop when it is idle.
1105 /// <param name="func">The function to call</param>
1106 /// <returns>true if added successfully, false otherwise</returns>
1108 /// It will return false when one of the following conditions is met.
1109 /// 1) the <see cref="Window"/> is hidden.
1110 /// 2) the <see cref="Window"/> is iconified.
1112 public bool AddIdle(System.Delegate func)
1114 System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
1115 System.IntPtr ip2 = Interop.Application.MakeCallback(new System.Runtime.InteropServices.HandleRef(this, ip));
1117 bool ret = Interop.Application.AddIdle(SwigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip2));
1119 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1124 * Outer::outer_method(int)
1126 public static Application New()
1128 Application ret = new Application(Interop.Application.New(), true);
1129 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1133 public static Application New(int argc)
1135 Application ret = new Application(Interop.Application.New(argc), true);
1136 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1140 public static Application New(int argc, string stylesheet)
1142 Application ret = new Application(Interop.Application.New(argc, stylesheet), true);
1143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1147 public static Application New(int argc, string stylesheet, NUIApplication.WindowMode windowMode)
1149 Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode), true);
1150 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1155 public static Application New(string[] args, string stylesheet, NUIApplication.WindowMode windowMode)
1157 Application ret = null;
1159 string argvStr = "";
1163 argvStr = string.Join(" ", args);
1165 catch (Exception exception)
1167 Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, message : " + exception.Message);
1168 Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber());
1169 Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace);
1173 ret = new Application(NDalicPINVOKE.ApplicationNewManual4(argc, argvStr, stylesheet, (int)windowMode), true);
1174 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1179 public static Application New(int argc, string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize)
1181 Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1182 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1186 public static Application New(string[] args, string stylesheet, NUIApplication.WindowMode windowMode, Rectangle positionSize)
1188 Application ret = null;
1190 string argvStr = "";
1194 argvStr = string.Join(" ", args);
1196 catch (Exception exception)
1198 Tizen.Log.Fatal("NUI", "[Error] got exception during Application New(), this should not occur, message : " + exception.Message);
1199 Tizen.Log.Fatal("NUI", "[Error] error line number : " + new StackTrace(exception, true).GetFrame(0).GetFileLineNumber());
1200 Tizen.Log.Fatal("NUI", "[Error] Stack Trace : " + exception.StackTrace);
1204 ret = new Application(NDalicPINVOKE.ApplicationNewWithWindowSizePosition(argc, argvStr, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
1205 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1210 public static Application New(int argc, string stylesheet, NUIApplication.WindowMode windowMode, WindowType type)
1212 // It will be removed until dali APIs are prepared.
1213 Rectangle initRectangle = new Rectangle(0, 0, 0, 0);
1215 Application ret = new Application(Interop.Application.New(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(initRectangle), (int)type), true);
1216 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1220 public Application() : this(Interop.Application.NewApplication(), true)
1222 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1225 public Application(Application application) : this(Interop.Application.NewApplication(Application.getCPtr(application)), true)
1227 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1230 public Application Assign(Application application)
1232 Application ret = new Application(Interop.Application.Assign(SwigCPtr, Application.getCPtr(application)), false);
1233 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1237 public void MainLoop()
1239 NDalicPINVOKE.ApplicationMainLoop(SwigCPtr);
1240 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1245 Interop.Application.Lower(SwigCPtr);
1246 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1251 Interop.Application.Quit(SwigCPtr);
1252 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1255 internal bool AddIdle(SWIGTYPE_p_Dali__CallbackBase callback)
1257 bool ret = Interop.Application.AddIdle(SwigCPtr, SWIGTYPE_p_Dali__CallbackBase.getCPtr(callback));
1258 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1262 public Window GetWindow()
1269 window = (Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindow(SwigCPtr)) as Window) ?? new Window(Interop.Application.GetWindow(SwigCPtr), true);
1271 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1275 public static string GetResourcePath()
1277 string ret = Interop.Application.GetResourcePath();
1278 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1282 public string GetLanguage()
1284 string ret = Interop.Application.GetLanguage(SwigCPtr);
1285 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1289 public string GetRegion()
1291 string ret = Interop.Application.GetRegion(SwigCPtr);
1292 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1296 [EditorBrowsable(EditorBrowsableState.Never)]
1297 public static List<Window> GetWindowList()
1299 uint ListSize = Interop.Application.GetWindowsListSize();
1300 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1302 List<Window> WindowList = new List<Window>();
1303 for (uint i = 0; i < ListSize; ++i)
1305 Window currWin = Registry.GetManagedBaseHandleFromNativePtr(Interop.Application.GetWindowsFromList(i)) as Window;
1306 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1307 if (currWin != null)
1309 WindowList.Add(currWin);
1315 internal ApplicationSignal InitSignal()
1317 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationInitSignal(SwigCPtr), false);
1318 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1322 internal ApplicationSignal TerminateSignal()
1324 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationTerminateSignal(SwigCPtr), false);
1325 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1329 internal ApplicationSignal PauseSignal()
1331 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationPauseSignal(SwigCPtr), false);
1332 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1336 internal ApplicationSignal ResumeSignal()
1338 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationResumeSignal(SwigCPtr), false);
1339 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1343 internal ApplicationSignal ResetSignal()
1345 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationResetSignal(SwigCPtr), false);
1346 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1350 internal ApplicationControlSignal AppControlSignal()
1352 ApplicationControlSignal ret = new ApplicationControlSignal(NDalicPINVOKE.ApplicationAppControlSignal(SwigCPtr), false);
1353 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1357 internal ApplicationSignal LanguageChangedSignal()
1359 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationLanguageChangedSignal(SwigCPtr), false);
1360 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1364 internal ApplicationSignal RegionChangedSignal()
1366 ApplicationSignal ret = new ApplicationSignal(NDalicPINVOKE.ApplicationRegionChangedSignal(SwigCPtr), false);
1367 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1371 internal LowBatterySignalType BatteryLowSignal()
1373 LowBatterySignalType ret = new LowBatterySignalType(NDalicPINVOKE.ApplicationLowBatterySignal(SwigCPtr), false);
1374 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1378 internal LowMemorySignalType MemoryLowSignal()
1380 LowMemorySignalType ret = new LowMemorySignalType(NDalicPINVOKE.ApplicationLowMemorySignal(SwigCPtr), false);
1381 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();