[NUI] Add Feature for multi window (#1605)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Window.cs
1 /*
2  * Copyright(c) 2019 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 extern alias TizenSystemInformation;
19 using TizenSystemInformation.Tizen.System;
20 using System;
21 using System.ComponentModel;
22 using System.Collections.Generic;
23 using System.Runtime.InteropServices;
24 using Tizen.NUI.BaseComponents;
25
26 namespace Tizen.NUI
27 {
28     /// <summary>
29     /// The window class is used internally for drawing.<br />
30     /// The window has an orientation and indicator properties.<br />
31     /// </summary>
32     /// <since_tizen> 3 </since_tizen>
33     public partial class Window : BaseHandle
34     {
35         private static readonly Window instance = Application.Instance?.GetWindow();
36         private global::System.Runtime.InteropServices.HandleRef stageCPtr;
37         private Layer _rootLayer;
38         private string _windowTitle;
39         private List<Layer> _childLayers = new List<Layer>();
40         private LayoutController localController;
41
42         private bool IsSupportedMultiWindow()
43         {
44             bool isSupported = false;
45             Information.TryGetValue("http://tizen.org/feature/opengles.surfaceless_context", out isSupported);
46             return isSupported;
47         }
48
49         internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Window.Window_SWIGUpcast(cPtr), cMemoryOwn)
50         {
51             if (Interop.Stage.Stage_IsInstalled())
52             {
53                 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.Stage_GetCurrent());
54
55                 localController = new LayoutController(this);
56                 NUILog.Debug("layoutController id:" + localController.GetId() );
57             }
58         }
59                 
60         /// <summary>
61         /// Creates a new Window.<br />
62         /// This creates an extra window in addition to the default main window<br />
63         /// </summary>
64         /// <param name="windowPosition">The position and size of the Window.</param>
65         /// <param name="isTranslucent">Whether Window is translucent.</param>
66         /// <returns>A new Window.</returns>
67         /// <since_tizen> 6 </since_tizen>
68         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
69         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
70         public Window(Rectangle windowPosition = null , bool isTranslucent = false) : this(Interop.Window.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
71         {
72             if( IsSupportedMultiWindow() == false )
73             {
74                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
75             }
76             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
77         }
78
79         /// <summary>
80         /// Creates a new Window with a specific name.<br />
81         /// This creates an extra window in addition to the default main window<br />
82         /// </summary>
83         /// <param name="name">The name for extra window. </param>
84         /// <param name="windowPosition">The position and size of the Window.</param>
85         /// <param name="isTranslucent">Whether Window is translucent.</param>
86         /// <returns>A new Window.</returns>
87         /// <since_tizen> 6 </since_tizen>
88         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
89         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
90         public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
91         {
92             if (IsSupportedMultiWindow() == false)
93             {
94                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
95             }
96             this._windowTitle = name;
97             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
98         }
99
100         /// <summary>
101         /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
102         /// </summary>
103         /// <since_tizen> 3 </since_tizen>
104         public enum WindowOrientation
105         {
106             /// <summary>
107             /// Portrait orientation. The height of the display area is greater than the width.
108             /// </summary>
109             /// <since_tizen> 3 </since_tizen>
110             Portrait = 0,
111             /// <summary>
112             /// Landscape orientation. A wide view area is needed.
113             /// </summary>
114             /// <since_tizen> 3 </since_tizen>
115             Landscape = 90,
116             /// <summary>
117             /// Portrait inverse orientation.
118             /// </summary>
119             /// <since_tizen> 3 </since_tizen>
120             PortraitInverse = 180,
121             /// <summary>
122             /// Landscape inverse orientation.
123             /// </summary>
124             /// <since_tizen> 3 </since_tizen>
125             LandscapeInverse = 270,
126             /// <summary>
127             /// No orientation. It is for the preferred orientation
128             /// Especially, NoOrientationPreference only has the effect for the preferred orientation.
129             /// It is used to unset the preferred orientation with SetPreferredOrientation.
130             /// </summary>
131             [EditorBrowsable(EditorBrowsableState.Never)]
132             NoOrientationPreference = -1
133         }
134
135         /// <summary>
136         /// Enumeration for the key grab mode for platform-level APIs.
137         /// </summary>
138         /// <since_tizen> 3 </since_tizen>
139         public enum KeyGrabMode
140         {
141             /// <summary>
142             /// Grabs a key only when on the top of the grabbing-window stack mode.
143             /// </summary>
144             Topmost = 0,
145             /// <summary>
146             /// Grabs a key together with the other client window(s) mode.
147             /// </summary>
148             Shared,
149             /// <summary>
150             /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack with the possibility of overriding the grab by the other client window mode.
151             /// </summary>
152             OverrideExclusive,
153             /// <summary>
154             /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
155             /// </summary>
156             Exclusive
157         };
158
159         /// <summary>
160         /// Enumeration for transition effect's state.
161         /// </summary>
162         [EditorBrowsable(EditorBrowsableState.Never)]
163         public enum EffectStates
164         {
165             /// <summary>
166             /// None state.
167             /// </summary>
168             [EditorBrowsable(EditorBrowsableState.Never)]
169             None = 0,
170             /// <summary>
171             /// Transition effect is started.
172             /// </summary>
173             [EditorBrowsable(EditorBrowsableState.Never)]
174             Start,
175             /// <summary>
176             /// Transition effect is ended.
177             /// </summary>
178             [EditorBrowsable(EditorBrowsableState.Never)]
179             End,
180         }
181
182         /// <summary>
183         /// Enumeration for transition effect's type.
184         /// </summary>
185         [EditorBrowsable(EditorBrowsableState.Never)]
186         public enum EffectTypes
187         {
188             /// <summary>
189             /// None type.
190             /// </summary>
191             [EditorBrowsable(EditorBrowsableState.Never)]
192             None = 0,
193             /// <summary>
194             /// Window show effect.
195             /// </summary>
196             [EditorBrowsable(EditorBrowsableState.Never)]
197             Show,
198             /// <summary>
199             /// Window hide effect.
200             /// </summary>
201             [EditorBrowsable(EditorBrowsableState.Never)]
202             Hide,
203         }
204
205         /// <summary>
206         /// Enumeration for opacity of the indicator.
207         /// </summary>
208         internal enum IndicatorBackgroundOpacity
209         {
210             Opaque = 100,
211             Translucent = 50,
212             Transparent = 0
213         }
214
215         /// <summary>
216         /// Enumeration for visible mode of the indicator.
217         /// </summary>
218         internal enum IndicatorVisibleMode
219         {
220             Invisible = 0,
221             Visible = 1,
222             Auto = 2
223         }
224
225         /// <summary>
226         /// The stage instance property (read-only).<br />
227         /// Gets the current window.<br />
228         /// </summary>
229         /// <since_tizen> 3 </since_tizen>
230         public static Window Instance
231         {
232             get
233             {
234                 return instance;
235             }
236         }
237
238         /// <summary>
239         /// Get Resource ID of window
240         /// </summary>
241         internal int ResourceID
242         {
243             get
244             {
245                 int ret = Interop.Window.GetResouceID(swigCPtr);
246                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
247                 return ret;
248             }
249         }
250
251         /// <summary>
252         /// Gets or sets a window type.
253         /// </summary>
254         /// <since_tizen> 3 </since_tizen>
255         public WindowType Type
256         {
257             get
258             {
259                 WindowType ret = (WindowType)Interop.Window.GetType(swigCPtr);
260                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
261                 return ret;
262             }
263             set
264             {
265                 Interop.Window.SetType(swigCPtr, (int)value);
266                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
267             }
268         }
269
270         /// <summary>
271         /// Gets/Sets a window title.
272         /// </summary>
273         /// <since_tizen> 4 </since_tizen>
274         public string Title
275         {
276             get
277             {
278                 return _windowTitle;
279             }
280             set
281             {
282                 _windowTitle = value;
283                 SetClass(_windowTitle, "");
284             }
285         }
286
287         /// <summary>
288         /// The rendering behavior of a Window.
289         /// </summary>
290         /// <since_tizen> 5 </since_tizen>
291         public RenderingBehaviorType RenderingBehavior
292         {
293             get
294             {
295                 return GetRenderingBehavior();
296             }
297             set
298             {
299                 SetRenderingBehavior(value);
300             }
301         }
302
303         /// <summary>
304         /// The window size property (read-only).
305         /// </summary>
306         /// <since_tizen> 3 </since_tizen>
307         public Size2D Size
308         {
309             get
310             {
311                 Size2D ret = GetSize();
312                 return ret;
313             }
314         }
315
316         /// <summary>
317         /// The background color property.
318         /// </summary>
319         /// <since_tizen> 3 </since_tizen>
320         public Color BackgroundColor
321         {
322             set
323             {
324                 SetBackgroundColor(value);
325             }
326             get
327             {
328                 Color ret = GetBackgroundColor();
329                 return ret;
330             }
331         }
332
333         /// <summary>
334         /// The DPI property (read-only).<br />
335         /// Retrieves the DPI of the display device to which the Window is connected.<br />
336         /// </summary>
337         /// <since_tizen> 3 </since_tizen>
338         public Vector2 Dpi
339         {
340             get
341             {
342                 return GetDpi();
343             }
344         }
345
346         /// <summary>
347         /// The layer count property (read-only).<br />
348         /// Queries the number of on-Window layers.<br />
349         /// </summary>
350         /// <since_tizen> 3 </since_tizen>
351         public uint LayerCount
352         {
353             get
354             {
355                 return GetLayerCount();
356             }
357         }
358
359         /// <summary>
360         /// Gets or sets a size of the window.
361         /// </summary>
362         /// <since_tizen> 4 </since_tizen>
363         public Size2D WindowSize
364         {
365             get
366             {
367                 return GetWindowSize();
368             }
369             set
370             {
371                 SetWindowSize(value);
372             }
373         }
374
375         /// <summary>
376         /// Gets or sets a position of the window.
377         /// </summary>
378         /// <since_tizen> 4 </since_tizen>
379         public Position2D WindowPosition
380         {
381             get
382             {
383                 return GetPosition();
384             }
385             set
386             {
387                 SetPosition(value);
388             }
389         }
390
391         /// <summary>
392         /// Sets position and size of the window. This API guarantees that
393         /// both moving and resizing of window will appear on the screen at once.
394         /// </summary>
395         [EditorBrowsable(EditorBrowsableState.Never)]
396         public Rectangle WindowPositionSize
397         {
398             get
399             {
400                 Position2D position = GetPosition();
401                 Size2D size = GetSize();
402                 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
403                 return ret;
404             }
405             set
406             {
407                 SetPositionSize(value);
408             }
409         }
410
411         internal static Vector4 DEFAULT_BACKGROUND_COLOR
412         {
413             get
414             {
415                 global::System.IntPtr cPtr = Interop.Stage.Stage_DEFAULT_BACKGROUND_COLOR_get();
416                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
417                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
418                 return ret;
419             }
420         }
421
422         internal static Vector4 DEBUG_BACKGROUND_COLOR
423         {
424             get
425             {
426                 global::System.IntPtr cPtr = Interop.Stage.Stage_DEBUG_BACKGROUND_COLOR_get();
427                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
428                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
429                 return ret;
430             }
431         }
432
433         internal List<Layer> LayersChildren
434         {
435             get
436             {
437                 return _childLayers;
438             }
439         }
440
441         /// <summary>
442         ///  Get the LayoutController for this Window.
443         /// </summary>
444         internal LayoutController LayoutController
445         {
446             get
447             {
448                 return localController;
449             }
450         }
451
452         /// <summary>
453         /// Feed a key-event into the window.
454         /// </summary>
455         /// <param name="keyEvent">The key event to feed.</param>
456         /// <since_tizen> 4 </since_tizen>
457         [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
458         public static void FeedKeyEvent(Key keyEvent)
459         {
460             Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
461             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
462         }
463
464         /// <summary>
465         /// Sets whether the window accepts a focus or not.
466         /// </summary>
467         /// <param name="accept">If a focus is accepted or not. The default is true.</param>
468         /// <since_tizen> 3 </since_tizen>
469         public void SetAcceptFocus(bool accept)
470         {
471             Interop.Window.SetAcceptFocus(swigCPtr, accept);
472             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
473         }
474
475         /// <summary>
476         /// Returns whether the window accepts a focus or not.
477         /// </summary>
478         /// <returns>True if the window accepts a focus, false otherwise.</returns>
479         /// <since_tizen> 3 </since_tizen>
480         public bool IsFocusAcceptable()
481         {
482             bool ret = Interop.Window.IsFocusAcceptable(swigCPtr);
483             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
484
485             return ret;
486         }
487
488         /// <summary>
489         /// Shows the window if it is hidden.
490         /// </summary>
491         /// <since_tizen> 3 </since_tizen>
492         public void Show()
493         {
494             Interop.Window.Show(swigCPtr);
495             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
496         }
497
498         /// <summary>
499         /// Hides the window if it is showing.
500         /// </summary>
501         /// <since_tizen> 3 </since_tizen>
502         public void Hide()
503         {
504             Interop.Window.Hide(swigCPtr);
505             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
506         }
507
508         /// <summary>
509         /// Retrieves whether the window is visible or not.
510         /// </summary>
511         /// <returns>True if the window is visible.</returns>
512         /// <since_tizen> 3 </since_tizen>
513         public bool IsVisible()
514         {
515             bool temp = Interop.Window.IsVisible(swigCPtr);
516             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
517             return temp;
518         }
519
520         /// <summary>
521         /// Gets the count of supported auxiliary hints of the window.
522         /// </summary>
523         /// <returns>The number of supported auxiliary hints.</returns>
524         /// <since_tizen> 3 </since_tizen>
525         public uint GetSupportedAuxiliaryHintCount()
526         {
527             uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(swigCPtr);
528             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
529             return ret;
530         }
531
532         /// <summary>
533         /// Gets the supported auxiliary hint string of the window.
534         /// </summary>
535         /// <param name="index">The index of the supported auxiliary hint lists.</param>
536         /// <returns>The auxiliary hint string of the index.</returns>
537         /// <since_tizen> 3 </since_tizen>
538         public string GetSupportedAuxiliaryHint(uint index)
539         {
540             string ret = Interop.Window.GetSupportedAuxiliaryHint(swigCPtr, index);
541             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
542             return ret;
543         }
544
545         /// <summary>
546         /// Creates an auxiliary hint of the window.
547         /// </summary>
548         /// <param name="hint">The auxiliary hint string.</param>
549         /// <param name="value">The value string.</param>
550         /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
551         /// <since_tizen> 3 </since_tizen>
552         public uint AddAuxiliaryHint(string hint, string value)
553         {
554             uint ret = Interop.Window.AddAuxiliaryHint(swigCPtr, hint, value);
555             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
556             return ret;
557         }
558
559         /// <summary>
560         /// Removes an auxiliary hint of the window.
561         /// </summary>
562         /// <param name="id">The ID of the auxiliary hint.</param>
563         /// <returns>True if no error occurred, false otherwise.</returns>
564         /// <since_tizen> 3 </since_tizen>
565         public bool RemoveAuxiliaryHint(uint id)
566         {
567             bool ret = Interop.Window.RemoveAuxiliaryHint(swigCPtr, id);
568             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
569             return ret;
570         }
571
572         /// <summary>
573         /// Changes a value of the auxiliary hint.
574         /// </summary>
575         /// <param name="id">The auxiliary hint ID.</param>
576         /// <param name="value">The value string to be set.</param>
577         /// <returns>True if no error occurred, false otherwise.</returns>
578         /// <since_tizen> 3 </since_tizen>
579         public bool SetAuxiliaryHintValue(uint id, string value)
580         {
581             bool ret = Interop.Window.SetAuxiliaryHintValue(swigCPtr, id, value);
582             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
583             return ret;
584         }
585
586         /// <summary>
587         /// Gets a value of the auxiliary hint.
588         /// </summary>
589         /// <param name="id">The auxiliary hint ID.</param>
590         /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
591         /// <since_tizen> 3 </since_tizen>
592         public string GetAuxiliaryHintValue(uint id)
593         {
594             string ret = Interop.Window.GetAuxiliaryHintValue(swigCPtr, id);
595             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
596             return ret;
597         }
598
599         /// <summary>
600         /// Gets an ID of the auxiliary hint string.
601         /// </summary>
602         /// <param name="hint">The auxiliary hint string.</param>
603         /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
604         /// <since_tizen> 3 </since_tizen>
605         public uint GetAuxiliaryHintId(string hint)
606         {
607             uint ret = Interop.Window.GetAuxiliaryHintId(swigCPtr, hint);
608             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
609             return ret;
610         }
611
612         /// <summary>
613         /// Sets a region to accept input events.
614         /// </summary>
615         /// <param name="inputRegion">The region to accept input events.</param>
616         /// <since_tizen> 3 </since_tizen>
617         public void SetInputRegion(Rectangle inputRegion)
618         {
619             Interop.Window.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
620             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
621         }
622
623         /// <summary>
624         /// Sets a priority level for the specified notification window.
625         /// </summary>
626         /// <param name="level">The notification window level.</param>
627         /// <returns>True if no error occurred, false otherwise.</returns>
628         /// <since_tizen> 3 </since_tizen>
629         public bool SetNotificationLevel(NotificationLevel level)
630         {
631             bool ret = Interop.Window.SetNotificationLevel(swigCPtr, (int)level);
632             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
633             return ret;
634         }
635
636         /// <summary>
637         /// Gets a priority level for the specified notification window.
638         /// </summary>
639         /// <returns>The notification window level.</returns>
640         /// <since_tizen> 3 </since_tizen>
641         public NotificationLevel GetNotificationLevel()
642         {
643             NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(swigCPtr);
644             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
645             return ret;
646         }
647
648         /// <summary>
649         /// Sets a transparent window's visual state to opaque. <br />
650         /// If a visual state of a transparent window is opaque, <br />
651         /// then the window manager could handle it as an opaque window when calculating visibility.
652         /// </summary>
653         /// <param name="opaque">Whether the window's visual state is opaque.</param>
654         /// <remarks>This will have no effect on an opaque window. <br />
655         /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
656         /// </remarks>
657         /// <since_tizen> 3 </since_tizen>
658         public void SetOpaqueState(bool opaque)
659         {
660             Interop.Window.SetOpaqueState(swigCPtr, opaque);
661             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
662         }
663
664         /// <summary>
665         /// Returns whether a transparent window's visual state is opaque or not.
666         /// </summary>
667         /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
668         /// <remarks> The return value has no meaning on an opaque window. </remarks>
669         /// <since_tizen> 3 </since_tizen>
670         public bool IsOpaqueState()
671         {
672             bool ret = Interop.Window.IsOpaqueState(swigCPtr);
673             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
674             return ret;
675         }
676
677         /// <summary>
678         /// Sets a window's screen off mode.
679         /// </summary>
680         /// <param name="screenOffMode">The screen mode.</param>
681         /// <returns>True if no error occurred, false otherwise.</returns>
682         /// <since_tizen> 4 </since_tizen>
683         public bool SetScreenOffMode(ScreenOffMode screenOffMode)
684         {
685             bool ret = Interop.Window.SetScreenOffMode(swigCPtr, (int)screenOffMode);
686             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
687             return ret;
688         }
689
690         /// <summary>
691         /// Gets the screen mode of the window.
692         /// </summary>
693         /// <returns>The screen off mode.</returns>
694         /// <since_tizen> 4 </since_tizen>
695         public ScreenOffMode GetScreenOffMode()
696         {
697             ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(swigCPtr);
698             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
699             return ret;
700         }
701
702         /// <summary>
703         /// Sets preferred brightness of the window.
704         /// </summary>
705         /// <param name="brightness">The preferred brightness (0 to 100).</param>
706         /// <returns>True if no error occurred, false otherwise.</returns>
707         /// <since_tizen> 3 </since_tizen>
708         public bool SetBrightness(int brightness)
709         {
710             bool ret = Interop.Window.SetBrightness(swigCPtr, brightness);
711             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
712             return ret;
713         }
714
715         /// <summary>
716         /// Gets the preferred brightness of the window.
717         /// </summary>
718         /// <returns>The preferred brightness.</returns>
719         /// <since_tizen> 3 </since_tizen>
720         public int GetBrightness()
721         {
722             int ret = Interop.Window.GetBrightness(swigCPtr);
723             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
724             return ret;
725         }
726
727         /// <summary>
728         /// Sets the window name and the class string.
729         /// </summary>
730         /// <param name="name">The name of the window.</param>
731         /// <param name="klass">The class of the window.</param>
732         /// <since_tizen> 4 </since_tizen>
733         public void SetClass(string name, string klass)
734         {
735             Interop.Window.Window_SetClass(swigCPtr, name, klass);
736             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
737         }
738
739         /// <summary>
740         /// Raises the window to the top of the window stack.
741         /// </summary>
742         /// <since_tizen> 3 </since_tizen>
743         public void Raise()
744         {
745             Interop.Window.Window_Raise(swigCPtr);
746             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
747         }
748
749         /// <summary>
750         /// Lowers the window to the bottom of the window stack.
751         /// </summary>
752         /// <since_tizen> 3 </since_tizen>
753         public void Lower()
754         {
755             Interop.Window.Window_Lower(swigCPtr);
756             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
757         }
758
759         /// <summary>
760         /// Activates the window to the top of the window stack even it is iconified.
761         /// </summary>
762         /// <since_tizen> 3 </since_tizen>
763         public void Activate()
764         {
765             Interop.Window.Window_Activate(swigCPtr);
766             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
767         }
768
769         /// <summary>
770         /// Gets the default ( root ) layer.
771         /// </summary>
772         /// <returns>The root layer.</returns>
773         /// <since_tizen> 3 </since_tizen>
774         public Layer GetDefaultLayer()
775         {
776             return this.GetRootLayer();
777         }
778
779         /// <summary>
780         /// Add a child view to window.
781         /// </summary>
782         /// <param name="view">the child should be added to the window.</param>
783         /// <since_tizen> 3 </since_tizen>
784         public void Add(View view)
785         {
786             Interop.Actor.Actor_Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
787             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
788             this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
789             view.InternalParent = this.GetRootLayer();
790         }
791
792         /// <summary>
793         /// Remove a child view from window.
794         /// </summary>
795         /// <param name="view">the child to be removed.</param>
796         /// <since_tizen> 3 </since_tizen>
797         public void Remove(View view)
798         {
799             Interop.Actor.Actor_Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
800             this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
801             view.InternalParent = null;
802         }
803
804         /// <summary>
805         /// Retrieves the layer at a specified depth.
806         /// </summary>
807         /// <param name="depth">The layer's depth index.</param>
808         /// <returns>The layer found at the given depth.</returns>
809         /// <since_tizen> 3 </since_tizen>
810         public Layer GetLayer(uint depth)
811         {
812             if (depth < LayersChildren?.Count)
813             {
814                 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
815                 return ret;
816             }
817             else
818             {
819                 return null;
820             }
821         }
822
823         /// <summary>
824         /// Destroy the window immediately.
825         /// </summary>
826         [EditorBrowsable(EditorBrowsableState.Never)]
827         public void Destroy()
828         {
829             this.Dispose();
830         }
831
832         /// <summary>
833         /// Keep rendering for at least the given amount of time.
834         /// </summary>
835         /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
836         /// <since_tizen> 3 </since_tizen>
837         public void KeepRendering(float durationSeconds)
838         {
839             Interop.Stage.Stage_KeepRendering(stageCPtr, durationSeconds);
840             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
841         }
842
843         /// <summary>
844         /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
845         /// This function can be used for following example scenarios: <br />
846         /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
847         /// </summary>
848         /// <param name="DaliKey">The key code to grab.</param>
849         /// <returns>True if the grab succeeds.</returns>
850         /// <since_tizen> 3 </since_tizen>
851         public bool GrabKeyTopmost(int DaliKey)
852         {
853             bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
854             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
855             return ret;
856         }
857
858         /// <summary>
859         /// Ungrabs the key specified by a key for the window.<br />
860         /// Note: If this function is called between key down and up events of a grabbed key, an application doesn't receive the key up event.<br />
861         /// </summary>
862         /// <param name="DaliKey">The key code to ungrab.</param>
863         /// <returns>True if the ungrab succeeds.</returns>
864         /// <since_tizen> 3 </since_tizen>
865         public bool UngrabKeyTopmost(int DaliKey)
866         {
867             bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
868             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
869             return ret;
870         }
871
872         /// <summary>
873         ///  Grabs the key specified by a key for a window in a GrabMode. <br />
874         ///  Details: This function can be used for following example scenarios: <br />
875         ///  - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
876         ///  - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
877         ///  - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
878         /// </summary>
879         /// <param name="DaliKey">The key code to grab.</param>
880         /// <param name="GrabMode">The grab mode for the key.</param>
881         /// <returns>True if the grab succeeds.</returns>
882         /// <since_tizen> 3 </since_tizen>
883         public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
884         {
885             bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
886             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
887             return ret;
888         }
889
890         /// <summary>
891         /// Ungrabs the key specified by a key for a window.<br />
892         /// Note: If this function is called between key down and up events of a grabbed key, an application doesn't receive the key up event. <br />
893         /// </summary>
894         /// <param name="DaliKey">The key code to ungrab.</param>
895         /// <returns>True if the ungrab succeeds.</returns>
896         /// <since_tizen> 3 </since_tizen>
897         public bool UngrabKey(int DaliKey)
898         {
899             bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
900             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
901             return ret;
902         }
903
904         /// <summary>
905         /// Sets the keyboard repeat information.
906         /// </summary>
907         /// <param name="rate">The key repeat rate value in seconds.</param>
908         /// <param name="delay">The key repeat delay value in seconds.</param>
909         /// <returns>True if setting the keyboard repeat succeeds.</returns>
910         /// <since_tizen> 5 </since_tizen>
911         public bool SetKeyboardRepeatInfo(float rate, float delay)
912         {
913             bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
914             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
915             return ret;
916         }
917
918         /// <summary>
919         /// Gets the keyboard repeat information.
920         /// </summary>
921         /// <param name="rate">The key repeat rate value in seconds.</param>
922         /// <param name="delay">The key repeat delay value in seconds.</param>
923         /// <returns>True if setting the keyboard repeat succeeds.</returns>
924         /// <since_tizen> 5 </since_tizen>
925         public bool GetKeyboardRepeatInfo(out float rate, out float delay)
926         {
927             bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
928             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
929             return ret;
930         }
931
932         /// <summary>
933         /// Adds a layer to the stage.
934         /// </summary>
935         /// <param name="layer">Layer to add.</param>
936         /// <since_tizen> 3 </since_tizen>
937         public void AddLayer(Layer layer)
938         {
939             Add(layer);
940         }
941
942         /// <summary>
943         /// Removes a layer from the stage.
944         /// </summary>
945         /// <param name="layer">Layer to remove.</param>
946         /// <since_tizen> 3 </since_tizen>
947         public void RemoveLayer(Layer layer)
948         {
949             Remove(layer);
950         }
951
952         /// <summary>
953         /// Feeds a key event into the window.
954         /// </summary>
955         /// <param name="keyEvent">The key event to feed.</param>
956         /// <since_tizen> 5 </since_tizen>
957         public void FeedKey(Key keyEvent)
958         {
959             Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
960             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
961         }
962
963         /// <summary>
964         /// Allows at least one more render, even when paused.
965         /// The window should be shown, not minimised.
966         /// </summary>
967         /// <since_tizen> 4 </since_tizen>
968         public void RenderOnce()
969         {
970             Interop.Window.Window_RenderOnce(swigCPtr);
971             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
972         }
973
974         /// <summary>
975         /// Sets whether the window is transparent or not.
976         /// </summary>
977         /// <param name="transparent">Whether the window is transparent or not.</param>
978         /// <since_tizen> 5 </since_tizen>
979         public void SetTransparency(bool transparent)
980         {
981             Interop.Window.SetTransparency(swigCPtr, transparent);
982             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
983
984             // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
985         }
986
987         /// <summary>
988         /// Sets parent window of the window.
989         /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
990         /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
991         /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
992         /// </summary>
993         /// <param name="parent">The parent window.</param>
994         /// <since_tizen> 6 </since_tizen>
995         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
996         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
997         public void SetParent(Window parent)
998         {
999             if (IsSupportedMultiWindow() == false)
1000             {
1001                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1002             }
1003             Interop.Window.SetParent(swigCPtr, Window.getCPtr(parent));
1004             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1005         }
1006
1007         /// <summary>
1008         /// Unsets parent window of the window.
1009         /// After unsetting, the window is disconnected his parent window.
1010         /// </summary>
1011         /// <since_tizen> 6 </since_tizen>
1012         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1013         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1014         public void Unparent()
1015         {
1016             if (IsSupportedMultiWindow() == false)
1017             {
1018                 NUILog.Error("Fail to create window. because this device does not support opengles.surfaceless_context.");
1019             }
1020             Interop.Window.Unparent(swigCPtr);
1021             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1022         }
1023
1024         /// <summary>
1025         /// Gets parent window of the window.
1026         /// </summary>
1027         /// <returns>The parent window of the window.</returns>
1028         /// <since_tizen> 6 </since_tizen>
1029         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1030         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1031         public Window GetParent()
1032         {
1033             if (IsSupportedMultiWindow() == false)
1034             {
1035                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1036             }
1037             Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.GetParent(swigCPtr)) as Window;
1038             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1039             return ret;
1040         }
1041
1042         /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
1043         [EditorBrowsable(EditorBrowsableState.Never)]
1044         public void ObjectDump()
1045         {
1046             Layer rootLayer = GetRootLayer();
1047             foreach (View view in rootLayer.Children)
1048             {
1049                 view.ObjectDump();
1050             }
1051         }
1052
1053         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
1054         {
1055             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
1056         }
1057
1058         internal static bool IsInstalled()
1059         {
1060             bool ret = Interop.Stage.Stage_IsInstalled();
1061             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1062             return ret;
1063         }
1064
1065         internal void ShowIndicator(Window.IndicatorVisibleMode visibleMode)
1066         {
1067             Interop.WindowInternal.Window_ShowIndicator(swigCPtr, (int)visibleMode);
1068             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1069         }
1070
1071         internal void SetIndicatorBackgroundOpacity(Window.IndicatorBackgroundOpacity opacity)
1072         {
1073             Interop.WindowInternal.Window_SetIndicatorBgOpacity(swigCPtr, (int)opacity);
1074             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1075         }
1076
1077         internal void RotateIndicator(Window.WindowOrientation orientation)
1078         {
1079             Interop.WindowInternal.Window_RotateIndicator(swigCPtr, (int)orientation);
1080             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1081         }
1082
1083         /// <summary>
1084         /// Adds an orientation to the list of available orientations.
1085         /// </summary>
1086         /// <param name="orientation">The available orientation to add</param>
1087         /// <since_tizen> 6 </since_tizen>
1088         public void AddAvailableOrientation(Window.WindowOrientation orientation)
1089         {
1090             Interop.Window.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
1091             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1092         }
1093
1094         /// <summary>
1095         /// Removes an orientation from the list of available orientations.
1096         /// </summary>
1097         /// <param name="orientation">The available orientation to remove.</param>
1098         /// <since_tizen> 6 </since_tizen>
1099         public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1100         {
1101             Interop.Window.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
1102             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1103         }
1104
1105         /// <summary>
1106         /// Sets a preferred orientation.
1107         /// </summary>
1108         /// <param name="orientation">The preferred orientation.</param>
1109         /// <since_tizen> 6 </since_tizen>
1110         public void SetPreferredOrientation(Window.WindowOrientation orientation)
1111         {
1112             Interop.Window.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
1113             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1114         }
1115
1116         /// <summary>
1117         /// Gets the preferred orientation.
1118         /// </summary>
1119         /// <since_tizen> 6 </since_tizen>
1120         /// <returns>The preferred orientation if previously set, or none.</returns>
1121         public Window.WindowOrientation GetPreferredOrientation()
1122         {
1123             Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.Window_GetPreferredOrientation(swigCPtr);
1124             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1125             return ret;
1126         }
1127
1128         /// <summary>
1129         /// Gets current orientation of the window.
1130         /// </summary>
1131         /// <since_tizen> 6 </since_tizen>
1132         /// <returns>The current window orientation if previously set, or none.</returns>
1133         [EditorBrowsable(EditorBrowsableState.Never)]
1134         public Window.WindowOrientation GetCurrentOrientation()
1135         {
1136             Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.Window_GetCurrentOrientation(swigCPtr);
1137             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1138             return ret;
1139         }
1140
1141         /// <summary>
1142         /// Sets available orientations of the window.
1143         /// This API is for setting several orientations one time.
1144         /// </summary>
1145         /// <param name="orientations">The list of orientations.</param>
1146         /// <since_tizen> 6 </since_tizen>
1147         [EditorBrowsable(EditorBrowsableState.Never)]
1148         public void SetAvailableOrientations( List<Window.WindowOrientation> orientations )
1149         {
1150             PropertyArray orientationArray = new PropertyArray();
1151             for( int i = 0; i < orientations.Count; i++ )
1152             {
1153               orientationArray.PushBack(new PropertyValue((int)orientations[i]));
1154             }
1155
1156             Interop.Window.Window_SetAvailableOrientations(swigCPtr, PropertyArray.getCPtr(orientationArray));
1157             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1158         }
1159
1160         /// <summary>
1161         /// Get native window ID
1162         /// </summary>
1163         /// <returns>native window ID</returns>
1164         [EditorBrowsable(EditorBrowsableState.Never)]
1165         public int GetNativeId()
1166         {
1167             int ret = Interop.Window.GetNativeId(swigCPtr);
1168             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1169             return ret;
1170         }
1171
1172         internal Any GetNativeHandle()
1173         {
1174             Any ret = new Any(Interop.WindowInternal.Window_GetNativeHandle(swigCPtr), true);
1175             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1176             return ret;
1177         }
1178
1179         internal void Add(Layer layer)
1180         {
1181             Interop.Window.Add(swigCPtr, Layer.getCPtr(layer));
1182             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1183
1184             LayersChildren?.Add(layer);
1185             layer.SetWindow(this);
1186         }
1187
1188         internal void Remove(Layer layer)
1189         {
1190             Interop.Window.Remove(swigCPtr, Layer.getCPtr(layer));
1191             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1192
1193             LayersChildren?.Remove(layer);
1194             layer.SetWindow(null);
1195         }
1196
1197         internal Vector2 GetSize()
1198         {
1199             var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1200             Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1201             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1202             return ret;
1203         }
1204
1205         internal RenderTaskList GetRenderTaskList()
1206         {
1207             RenderTaskList ret = new RenderTaskList(Interop.Stage.Stage_GetRenderTaskList(stageCPtr), true);
1208             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1209             return ret;
1210         }
1211
1212         /// <summary>
1213         /// Queries the number of on-window layers.
1214         /// </summary>
1215         /// <returns>The number of layers.</returns>
1216         /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1217         internal uint GetLayerCount()
1218         {
1219             if (LayersChildren == null || LayersChildren.Count < 0)
1220                 return 0;
1221
1222             return (uint) LayersChildren.Count;
1223         }
1224
1225         internal Layer GetRootLayer()
1226         {
1227             // Window.IsInstalled() is actually true only when called from event thread and
1228             // Core has been initialized, not when Stage is ready.
1229             if (_rootLayer == null && Window.IsInstalled())
1230             {
1231                 _rootLayer = new Layer(Interop.Window.GetRootLayer(swigCPtr), true);
1232                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1233                 LayersChildren?.Add(_rootLayer);
1234                 _rootLayer.SetWindow(this);
1235             }
1236             return _rootLayer;
1237         }
1238
1239         internal void SetBackgroundColor(Vector4 color)
1240         {
1241             Interop.Window.SetBackgroundColor(swigCPtr, Vector4.getCPtr(color));
1242             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1243         }
1244
1245         internal Vector4 GetBackgroundColor()
1246         {
1247             Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(swigCPtr), true);
1248             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1249             return ret;
1250         }
1251
1252         internal Vector2 GetDpi()
1253         {
1254             Vector2 ret = new Vector2(Interop.Stage.Stage_GetDpi(stageCPtr), true);
1255             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1256             return ret;
1257         }
1258
1259         internal ObjectRegistry GetObjectRegistry()
1260         {
1261             ObjectRegistry ret = new ObjectRegistry(Interop.Stage.Stage_GetObjectRegistry(stageCPtr), true);
1262             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1263             return ret;
1264         }
1265
1266         internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1267         {
1268             Interop.Stage.Stage_SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1269             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1270         }
1271
1272         internal RenderingBehaviorType GetRenderingBehavior()
1273         {
1274             RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.Stage_GetRenderingBehavior(stageCPtr);
1275             if (NDalicPINVOKE.SWIGPendingException.Pending)
1276                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1277             return ret;
1278         }
1279
1280         internal void SetWindowSize(Size2D size)
1281         {
1282             var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1283             Interop.Window.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1284
1285             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1286
1287             // Resetting Window size should request a relayout of the tree.
1288         }
1289
1290         internal Size2D GetWindowSize()
1291         {
1292             var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1293             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1294
1295             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1296             return ret;
1297         }
1298
1299         internal void SetPosition(Position2D position)
1300         {
1301             var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1302             Interop.Window.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1303
1304             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1305             // Setting Position of the window should request a relayout of the tree.
1306         }
1307
1308         internal Position2D GetPosition()
1309         {
1310             var val = new Uint16Pair(Interop.Window.GetPosition(swigCPtr), true);
1311             Position2D ret = new Position2D(val.GetX(), val.GetY());
1312
1313             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1314             return ret;
1315         }
1316
1317         internal void SetPositionSize(Rectangle positionSize)
1318         {
1319             Interop.Window.Window_SetPositionSize(swigCPtr, Rectangle.getCPtr(positionSize));
1320
1321             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1322
1323             // Setting Position of the window should request a relayout of the tree.
1324         }
1325
1326         /// <summary>
1327         /// Dispose for Window
1328         /// </summary>
1329         [EditorBrowsable(EditorBrowsableState.Never)]
1330         protected override void Dispose(DisposeTypes type)
1331         {
1332             if (disposed)
1333             {
1334                 return;
1335             }
1336
1337             if (type == DisposeTypes.Explicit)
1338             {
1339                 //Called by User
1340                 //Release your own managed resources here.
1341                 //You should release all of your own disposable objects here.
1342
1343                 _rootLayer.Dispose();
1344                 localController.Dispose();
1345
1346                 foreach(var layer in _childLayers)
1347                 {
1348                     layer.Dispose();
1349                 }
1350                 _childLayers.Clear();
1351             }
1352
1353             this.DisconnectNativeSignals();
1354
1355             base.Dispose(type);
1356         }
1357
1358         /// This will not be public opened.
1359         [EditorBrowsable(EditorBrowsableState.Never)]
1360         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1361         {
1362             Interop.Window.delete_Window(swigCPtr);
1363         }
1364     }
1365 }