eabcdef9ef485eddda0975e4bb306ceaebe0f2b9
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Application / NUIApplication.cs
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 using System;
19 using System.ComponentModel;
20 using System.Diagnostics.CodeAnalysis;
21 using System.Threading;
22 using System.Reflection;
23 using Tizen.Applications;
24 using Tizen.Applications.CoreBackend;
25 using Tizen.NUI.Xaml;
26
27 namespace Tizen.NUI
28 {
29
30     /// <summary>
31     /// Represents an application that have a UI screen. The NUIApplication class has a default stage.
32     /// </summary>
33     /// <since_tizen> 3 </since_tizen>
34     public class NUIApplication : CoreApplication
35     {
36         /// <summary>
37         /// The instance of ResourceManager.
38         /// </summary>
39         private static System.Resources.ResourceManager resourceManager = null;
40         private static string currentLoadedXaml = null;
41
42         /// <summary>
43         /// The border window
44         /// </summary>
45         private bool borderEnabled = false;
46         private IBorderInterface borderInterface = null;
47
48         /// <summary>
49         /// Xaml loaded delegate.
50         /// </summary>
51         [EditorBrowsable(EditorBrowsableState.Never)]
52         public delegate void XamlLoadedHandler(string xamlName);
53
54         static NUIApplication()
55         {
56             Registry.Instance.SavedApplicationThread = Thread.CurrentThread;
57         }
58
59         /// <summary>
60         /// The default constructor.
61         /// </summary>
62         /// <since_tizen> 3 </since_tizen>
63         [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
64         public NUIApplication() : base(new NUICoreBackend())
65         {
66         }
67
68         /// <summary>
69         /// The constructor with window size and position.
70         /// </summary>
71         /// <param name="windowSize">The window size.</param>
72         /// <param name="windowPosition">The window position.</param>
73         /// <since_tizen> 5 </since_tizen>
74         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
75         [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
76         [EditorBrowsable(EditorBrowsableState.Never)]
77         public NUIApplication(Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend("", NUIApplication.WindowMode.Opaque, windowSize, windowPosition))
78         {
79         }
80
81         /// <summary>
82         /// The constructor with a stylesheet.
83         /// </summary>
84         /// <param name="styleSheet">The styleSheet url.</param>
85         /// <since_tizen> 3 </since_tizen>
86         [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
87         public NUIApplication(string styleSheet) : base(new NUICoreBackend(styleSheet))
88         {
89         }
90
91         /// <summary>
92         /// The constructor with a stylesheet, window size, and position.
93         /// </summary>
94         /// <param name="styleSheet">The styleSheet URL.</param>
95         /// <param name="windowSize">The window size.</param>
96         /// <param name="windowPosition">The window position.</param>
97         /// <since_tizen> 5 </since_tizen>
98         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
99         [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
100         [EditorBrowsable(EditorBrowsableState.Never)]
101         public NUIApplication(string styleSheet, Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend(styleSheet, WindowMode.Opaque, windowSize, windowPosition))
102         {
103         }
104
105         /// <summary>
106         /// The constructor with a stylesheet and window mode.
107         /// </summary>
108         /// <param name="styleSheet">The styleSheet url.</param>
109         /// <param name="windowMode">The windowMode.</param>
110         /// <since_tizen> 3 </since_tizen>
111         [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
112         public NUIApplication(string styleSheet, WindowMode windowMode) : base(new NUICoreBackend(styleSheet, windowMode))
113         {
114         }
115
116         /// <summary>
117         /// The constructor with a stylesheet, window mode, window size, and position.
118         /// </summary>
119         /// <param name="styleSheet">The styleSheet URL.</param>
120         /// <param name="windowMode">The windowMode.</param>
121         /// <param name="windowSize">The window size.</param>
122         /// <param name="windowPosition">The window position.</param>
123         /// <since_tizen> 5 </since_tizen>
124         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
125         [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
126         [EditorBrowsable(EditorBrowsableState.Never)]
127         public NUIApplication(string styleSheet, WindowMode windowMode, Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition))
128         {
129         }
130
131         /// <summary>
132         /// Internal inhouse constructor with Graphics Backend Type
133         /// </summary>
134         /// <param name="backend"></param>
135         /// <param name="windowMode"></param>
136         /// <param name="windowSize"></param>
137         /// <param name="windowPosition"></param>
138         /// <param name="styleSheet"></param>
139         /// InhouseAPI, this could be opened in NextTizen
140         [Obsolete("Do not use! This will be deprecated!")]
141         [EditorBrowsable(EditorBrowsableState.Never)]
142         public NUIApplication(Graphics.BackendType backend, WindowMode windowMode = WindowMode.Opaque, Size2D windowSize = null, Position2D windowPosition = null, string styleSheet = "") : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition))
143         {
144             //windowMode and styleSheet will be added later. currently it's not working as expected.
145             Graphics.Backend = backend;
146             Tizen.Log.Error("NUI", "Plaese DO NOT set graphical backend type with this constructor! This will give no effect!");
147         }
148
149         /// <summary>
150         /// The constructor with theme option.
151         /// </summary>
152         /// <param name="option">The theme option.</param>
153         [EditorBrowsable(EditorBrowsableState.Never)]
154         [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
155         public NUIApplication(ThemeOptions option) : base(new NUICoreBackend())
156         {
157             ApplyThemeOption(option);
158         }
159
160         /// <summary>
161         /// The constructor with window size and position and theme option.
162         /// </summary>
163         /// <param name="windowSize">The window size.</param>
164         /// <param name="windowPosition">The window position.</param>
165         /// <param name="option">The theme option.</param>
166         [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
167         [EditorBrowsable(EditorBrowsableState.Never)]
168         public NUIApplication(Size2D windowSize, Position2D windowPosition, ThemeOptions option) : base(new NUICoreBackend("", NUIApplication.WindowMode.Opaque, windowSize, windowPosition))
169         {
170             ApplyThemeOption(option);
171         }
172
173         /// <summary>
174         /// The constructor with a stylesheet, window mode and default window type.
175         /// It is the only way to create an IME window.
176         /// </summary>
177         /// <param name="styleSheet">The styleSheet URL.</param>
178         /// <param name="windowMode">The windowMode.</param>
179         /// <param name="type">The default window type.</param>
180         /// <since_tizen> 9 </since_tizen>
181         [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
182         public NUIApplication(string styleSheet, WindowMode windowMode, WindowType type) : base(new NUICoreBackend(styleSheet, windowMode, type))
183         {
184             ExternalThemeManager.Initialize();
185         }
186
187         /// <summary>
188         /// The constructor with a stylesheet, size, position, boderInterface and window mode
189         /// </summary>
190         /// <param name="styleSheet">The styleSheet URL.</param>
191         /// <param name="windowSize">The window size.</param>
192         /// <param name="windowPosition">The window position.</param>
193         /// <param name="borderInterface"><see cref="Tizen.NUI.IBorderInterface"/>If borderInterface is null, defaultBorder is enabled.</param>
194         /// <param name="windowMode">The windowMode.</param>
195         [EditorBrowsable(EditorBrowsableState.Never)]
196         [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
197         public NUIApplication(string styleSheet, Size2D windowSize, Position2D windowPosition, IBorderInterface borderInterface, WindowMode windowMode = WindowMode.Opaque) : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition))
198         {
199             EnableBorder(borderInterface);
200         }
201
202         /// <summary>
203         /// The constructor with theme option and borderInterface.
204         /// </summary>
205         /// <param name="option">The theme option.</param>
206         /// <param name="borderInterface"><see cref="Tizen.NUI.IBorderInterface"/>If borderInterface is null, defaultBorder is enabled.</param>
207         [EditorBrowsable(EditorBrowsableState.Never)]
208         [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
209         public NUIApplication(ThemeOptions option, IBorderInterface borderInterface) : base(new NUICoreBackend())
210         {
211             EnableBorder(borderInterface);
212             ApplyThemeOption(option);
213         }
214
215         /// <summary>
216         /// The constructor with window size, position, theme option and borderInterface.
217         /// </summary>
218         /// <param name="windowSize">The window size.</param>
219         /// <param name="windowPosition">The window position.</param>
220         /// <param name="option">The theme option.</param>
221         /// <param name="borderInterface"><see cref="Tizen.NUI.IBorderInterface"/>If borderInterface is null, defaultBorder is enabled.</param>
222         [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
223         [EditorBrowsable(EditorBrowsableState.Never)]
224         public NUIApplication(Size2D windowSize, Position2D windowPosition, ThemeOptions option, IBorderInterface borderInterface) : base(new NUICoreBackend("", NUIApplication.WindowMode.Opaque, windowSize, windowPosition))
225         {
226             EnableBorder(borderInterface);
227             ApplyThemeOption(option);
228         }
229
230         /// <summary>
231         /// The constructor with a stylesheet, window mode, coretask
232         /// </summary>
233         /// <note>
234         /// There is the UI thread feature.
235         /// UI thread is an additional thread that an Application object creates. The thread is for UI events.
236         /// To enable the UI Thread, you have to pass CoreTask object using this contructor.
237         /// When the UI thread feature is enabled, The methods of CoreTask are emitted on the main thread,
238         /// and the NUIApplication's events are emitted on the UI thread.
239         /// If you want to handle windows or actors in cases like when the memory level of the device is low, you have to use the NUIApplication events, not the CoreTask methods.
240         /// The CoreTask is not for handling GUI.
241         /// Callbacks of the all events in NUIApplication except the CoreTask are emitted on the UI thread.
242         /// </note>
243         /// <param name="styleSheet">The styleSheet URL.</param>
244         /// <param name="windowMode">The windowMode.</param>
245         /// <param name="task">True If app creates a UI Thread</param>
246         [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
247         [EditorBrowsable(EditorBrowsableState.Never)]
248         public NUIApplication(string styleSheet, WindowMode windowMode, CoreTask task) : base(new NUICoreBackend(styleSheet, windowMode), task)
249         {
250         }
251
252         /// <summary>
253         /// The constructor with a stylesheet, window mode, window size, position, coretask
254         /// </summary>
255         /// <param name="styleSheet">The styleSheet URL.</param>
256         /// <param name="windowMode">The windowMode.</param>
257         /// <param name="windowSize">The window size.</param>
258         /// <param name="windowPosition">The window position.</param>
259         /// <param name="task">True If app creates a UI Thread</param>
260         [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
261         [EditorBrowsable(EditorBrowsableState.Never)]
262         public NUIApplication(string styleSheet, WindowMode windowMode, Size2D windowSize, Position2D windowPosition, CoreTask task) : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition), task)
263         {
264         }
265
266         /// <summary>
267         /// The constructor with a ThemeOptions, WindowData
268         /// </summary>
269         /// <param name="option">The theme option.</param>
270         /// <param name="windowData">The default window data</param>
271         [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
272         [EditorBrowsable(EditorBrowsableState.Never)]
273         public NUIApplication(ThemeOptions option, WindowData windowData) : base(new NUICoreBackend(windowData))
274         {
275             if (windowData.BorderInterface != null)
276             {
277                 EnableBorder(windowData.BorderInterface);
278             }
279             ApplyThemeOption(option);
280         }
281
282         /// <summary>
283         /// Occurs whenever the application is resumed.
284         /// </summary>
285         /// <since_tizen> 4 </since_tizen>
286         public event EventHandler Resumed;
287
288         /// <summary>
289         /// Occurs whenever the application is paused.
290         /// </summary>
291         /// <since_tizen> 4 </since_tizen>
292         public event EventHandler Paused;
293
294         /// <summary>
295         /// Xaml loaded event.
296         /// </summary>
297         [EditorBrowsable(EditorBrowsableState.Never)]
298         public static event XamlLoadedHandler XamlLoaded;
299
300         /// <summary>
301         /// Enumeration for deciding whether a NUI application window is opaque or transparent.
302         /// </summary>
303         /// <since_tizen> 3 </since_tizen>
304         public enum WindowMode
305         {
306             /// <summary>
307             /// Opaque
308             /// </summary>
309             /// <since_tizen> 3 </since_tizen>
310             Opaque = 0,
311             /// <summary>
312             /// Transparent
313             /// </summary>
314             /// <since_tizen> 3 </since_tizen>
315             Transparent = 1
316         }
317
318         /// <summary>
319         /// Enumeration for theme options of the NUIApplication.
320         /// </summary>
321         [Flags]
322         [EditorBrowsable(EditorBrowsableState.Never)]
323         public enum ThemeOptions : int
324         {
325             /// <summary>
326             /// No option specified.
327             /// </summary>
328             [EditorBrowsable(EditorBrowsableState.Never)]
329             None = 0,
330
331             /// <summary>
332             /// Enable platform theme.
333             /// When this option is on, all views in the NUIApplication is affected by platform theme (e.g. light/dark).
334             /// </summary>
335             [EditorBrowsable(EditorBrowsableState.Never)]
336             PlatformThemeEnabled = 1 << 0,
337
338             /// <summary>
339             /// Sets the default value of View.ThemeChangeSensitive.
340             /// when this option is on, all views are made sensitive on theme changing by default.
341             /// </summary>
342             [EditorBrowsable(EditorBrowsableState.Never)]
343             ThemeChangeSensitive = 1 << 1,
344         };
345
346         /// <summary>
347         /// Current loaded xaml's full name.
348         /// </summary>
349         [EditorBrowsable(EditorBrowsableState.Never)]
350         public static string CurrentLoadedXaml
351         {
352             get
353             {
354                 return currentLoadedXaml;
355             }
356             set
357             {
358                 if (currentLoadedXaml != value)
359                 {
360                     currentLoadedXaml = value;
361                     XamlLoaded?.Invoke(value);
362                 }
363             }
364         }
365
366         /// <summary>
367         /// ResourceManager to handle multilingual.
368         /// </summary>
369         /// <since_tizen> 4 </since_tizen>
370         public static System.Resources.ResourceManager MultilingualResourceManager
371         {
372             get
373             {
374                 return resourceManager;
375             }
376             set
377             {
378                 resourceManager = value;
379             }
380         }
381
382         /// <summary>
383         /// Gets the window instance.
384         /// </summary>
385         /// <since_tizen> 3 </since_tizen>
386         [Obsolete("Do not use! This will be deprecated!")]
387         [EditorBrowsable(EditorBrowsableState.Never)]
388         public Window Window
389         {
390             get
391             {
392                 return GetDefaultWindow();
393             }
394         }
395
396         /// <summary>
397         /// Gets the Application Id.
398         /// </summary>
399         /// <since_tizen> 6 </since_tizen>
400         [EditorBrowsable(EditorBrowsableState.Never)]
401         public string AppId
402         {
403             get
404             {
405                 return Tizen.Applications.Application.Current.ApplicationInfo.ApplicationId;
406             }
407         }
408
409         /// <summary>
410         /// Gets the default window.
411         /// </summary>
412         /// <returns>The default Window.</returns>
413         /// <since_tizen> 6 </since_tizen>
414         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
415         [EditorBrowsable(EditorBrowsableState.Never)]
416         public static Window GetDefaultWindow()
417         {
418             return Window.Instance;
419         }
420
421         internal Application ApplicationHandle
422         {
423             get
424             {
425                 return ((NUICoreBackend)this.Backend).ApplicationHandle;
426             }
427         }
428
429         /// <summary>
430         /// Register the assembly to XAML.
431         /// </summary>
432         /// <since_tizen> 5 </since_tizen>
433         public static void RegisterAssembly(Assembly assembly)
434         {
435             XamlParser.s_assemblies.Add(assembly);
436         }
437
438         /// <summary>
439         /// Runs the NUIApplication.
440         /// </summary>
441         /// <param name="args">Arguments from commandline.</param>
442         /// <since_tizen> 4 </since_tizen>
443         public override void Run(string[] args)
444         {
445             Backend.AddEventHandler(EventType.PreCreated, OnPreCreate);
446             Backend.AddEventHandler(EventType.Resumed, OnResume);
447             Backend.AddEventHandler(EventType.Paused, OnPause);
448             base.Run(args);
449         }
450
451         /// <summary>
452         /// Exits the NUIApplication.
453         /// </summary>
454         /// <since_tizen> 4 </since_tizen>
455         public override void Exit()
456         {
457             base.Exit();
458         }
459
460         /// <summary>
461         /// Ensures that the function passed in is called from the main loop when it is idle.
462         /// </summary>
463         /// <param name="func">The function to call</param>
464         /// <returns>true if added successfully, false otherwise</returns>
465         /// <since_tizen> 4 </since_tizen>
466         public bool AddIdle(System.Delegate func)
467         {
468             return ((NUICoreBackend)this.Backend).AddIdle(func);
469         }
470
471         /// <summary>
472         /// Flush render/update thread messages synchronously.
473         /// </summary>
474         /// <remarks>
475         /// This function will relayout forcibily.
476         /// This function is used for advanced developer. It will make main-thread overhead if you call this function frequencely.
477         /// </remarks>
478         // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
479         [EditorBrowsable(EditorBrowsableState.Never)]
480         public void FlushUpdateMessages()
481         {
482             ApplicationHandle.FlushUpdateMessages();
483         }
484
485         /// <summary>
486         /// Sets the number of frames per render.
487         /// </summary>
488         /// <param name="numberOfVSyncsPerRender">The number of vsyncs between successive renders.</param>
489         /// <remarks>
490         /// Suggest this is a power of two:
491         /// 1 - render each vsync frame.
492         /// 2 - render every other vsync frame.
493         /// 4 - render every fourth vsync frame.
494         /// 8 - render every eighth vsync frame. <br />
495         /// For example, if an application runs on 60 FPS and SetRenderRefreshRate(2) is called, the frames per second will be changed to 30.
496         ///</remarks>
497         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
498         [EditorBrowsable(EditorBrowsableState.Never)]
499         public static void SetRenderRefreshRate(uint numberOfVSyncsPerRender)
500         {
501             Adaptor.Instance.SetRenderRefreshRate(numberOfVSyncsPerRender);
502         }
503
504         /// <summary>
505         /// Gets the screen size
506         /// </summary>
507         /// <returns>Screen size</returns>
508         [EditorBrowsable(EditorBrowsableState.Never)]
509         static public Size GetScreenSize()
510         {
511             var ret = new Size(Interop.Application.GetScreenSize(), true);
512             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
513             return ret;
514         }
515
516         /// <summary>
517         /// Overrides this method if you want to handle behavior.
518         /// </summary>
519         /// <since_tizen> 3 </since_tizen>
520         protected override void OnLocaleChanged(LocaleChangedEventArgs e)
521         {
522             base.OnLocaleChanged(e);
523         }
524
525         /// <summary>
526         /// Overrides this method if you want to handle behavior.
527         /// </summary>
528         /// <since_tizen> 3 </since_tizen>
529         protected override void OnLowBattery(LowBatteryEventArgs e)
530         {
531             base.OnLowBattery(e);
532         }
533
534         /// <summary>
535         /// Overrides this method if you want to handle behavior.
536         /// </summary>
537         /// <since_tizen> 3 </since_tizen>
538         protected override void OnLowMemory(LowMemoryEventArgs e)
539         {
540             base.OnLowMemory(e);
541         }
542
543         /// <summary>
544         /// Overrides this method if you want to handle behavior.
545         /// </summary>
546         /// <since_tizen> 3 </since_tizen>
547         protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
548         {
549             base.OnRegionFormatChanged(e);
550         }
551
552         /// <summary>
553         /// This method is to handle behavior when the device orientation is changed.
554         ///
555         /// When device is rotated to ccw or cw, this event occurs.
556         /// In addition, this event is different to window orientation changed event.
557         /// The window orientation event is for per a window and occurs when some flags should be set before.
558         /// </summary>
559         /// <param name="e">The device orientation changed event argument</param>
560         [EditorBrowsable(EditorBrowsableState.Never)]
561         protected override void OnDeviceOrientationChanged(DeviceOrientationEventArgs e)
562         {
563             base.OnDeviceOrientationChanged(e);
564         }
565
566         /// <summary>
567         /// Overrides this method if you want to handle behavior.
568         /// </summary>
569         /// <since_tizen> 3 </since_tizen>
570         protected override void OnTerminate()
571         {
572             base.OnTerminate();
573         }
574
575         /// <summary>
576         /// Overrides this method if you want to handle behavior.
577         /// </summary>
578         /// <since_tizen> 3 </since_tizen>
579         protected virtual void OnPause()
580         {
581             Paused?.Invoke(this, EventArgs.Empty);
582         }
583
584         /// <summary>
585         /// Overrides this method if you want to handle behavior.
586         /// </summary>
587         /// <since_tizen> 3 </since_tizen>
588         protected virtual void OnResume()
589         {
590             Resumed?.Invoke(this, EventArgs.Empty);
591         }
592
593         /// <summary>
594         /// Overrides this method if you want to handle behavior.
595         /// </summary>
596         /// <since_tizen> 3 </since_tizen>
597         protected virtual void OnPreCreate()
598         {
599             Tizen.Tracer.Begin("[NUI] OnPreCreate()");
600
601             if (borderEnabled && GetDefaultWindow() != null)
602             {
603                 GetDefaultWindow().EnableBorder(borderInterface, new Window.BorderCloseDelegate(Exit));
604             }
605
606             Tizen.Tracer.End();
607         }
608
609         /// <summary>
610         /// Overrides this method if you want to handle behavior.
611         /// </summary>
612         /// <since_tizen> 3 </since_tizen>
613         protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
614         {
615             if (e != null && e.ReceivedAppControl != null)
616             {
617                 Log.Info("NUI", "OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId);
618                 Log.Info("NUI", "CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + "   IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest);
619             }
620             base.OnAppControlReceived(e);
621         }
622
623         /// <summary>
624         /// Overrides this method if you want to handle behavior.
625         /// </summary>
626         /// <since_tizen> 3 </since_tizen>
627         protected override void OnCreate()
628         {
629             Tizen.Tracer.Begin("[NUI] OnCreate()");
630
631             base.OnCreate();
632
633             Tizen.Tracer.End();
634         }
635
636         /// <summary>
637         /// This is used to improve application launch performance.
638         /// </summary>
639         [EditorBrowsable(EditorBrowsableState.Never)]
640         static public void Preload()
641         {
642             Interop.Application.PreInitialize();
643
644             // Initialize some static utility
645             var disposalbeQueue = DisposeQueue.Instance;
646             var registry = Registry.Instance;
647
648             // Initialize some BaseComponent static variables now
649             BaseComponents.View.Preload();
650             BaseComponents.ImageView.Preload();
651             BaseComponents.TextLabel.Preload();
652             BaseComponents.TextEditor.Preload();
653             BaseComponents.TextField.Preload();
654             Disposable.Preload();
655
656             // Initialize exception tasks. It must be called end of Preload()
657             NDalicPINVOKE.Preload();
658
659             IsPreload = true;
660         }
661
662         /// <summary>
663         /// Check if it is loaded as dotnet-loader-nui.
664         /// </summary>
665         static internal bool IsPreload { get; set; }
666
667         private void ApplyThemeOption(ThemeOptions option)
668         {
669             if ((option & ThemeOptions.PlatformThemeEnabled) != 0)
670             {
671                 ThemeManager.PlatformThemeEnabled = true;
672             }
673
674             if ((option & ThemeOptions.ThemeChangeSensitive) != 0)
675             {
676                 ThemeManager.ApplicationThemeChangeSensitive = true;
677             }
678         }
679
680         private void EnableBorder(IBorderInterface borderInterface)
681         {
682             borderEnabled = true;
683             this.borderInterface = borderInterface;
684         }
685     }
686
687     /// <summary>
688     /// Graphics Backend Type.
689     /// </summary>
690     [SuppressMessage("Microsoft.Design", "CA1052:StaticHolderTypesShouldBeStaticOrNotInheritable")]
691     [EditorBrowsable(EditorBrowsableState.Never)]
692     [Obsolete("Do not use! This will be deprecated!")]
693     public class Graphics
694     {
695         /// <summary>
696         /// Graphics Backend Type.
697         /// </summary>
698         public enum BackendType
699         {
700             /// <summary>
701             /// The GLES backend.
702             /// </summary>
703             Gles,
704             /// <summary>
705             /// The Vulkan backend.
706             /// </summary>
707             Vulkan
708         }
709
710         /// <summary>
711         /// The backend used by the NUIApplication.
712         /// </summary>
713         [EditorBrowsable(EditorBrowsableState.Never)]
714         internal static BackendType Backend = BackendType.Gles;
715
716         internal const string GlesCSharpBinder = NDalicPINVOKE.Lib;
717         internal const string VulkanCSharpBinder = "libdali-csharp-binder-vk.so";
718     }
719 }