[NUI] Fix build warning & clean code [CA1051]
[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 global::System;
21 using System.ComponentModel;
22 using System.Collections.Generic;
23 using global::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.Upcast(cPtr), cMemoryOwn)
50         {
51             if (Interop.Stage.IsInstalled())
52             {
53                 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.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.New(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.New(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         /// The stage instance property (read-only).<br />
207         /// Gets the current window.<br />
208         /// </summary>
209         /// <since_tizen> 3 </since_tizen>
210         public static Window Instance
211         {
212             get
213             {
214                 return instance;
215             }
216         }
217
218         /// <summary>
219         /// Gets or sets a window type.
220         /// </summary>
221         /// <since_tizen> 3 </since_tizen>
222         public WindowType Type
223         {
224             get
225             {
226                 WindowType ret = (WindowType)Interop.Window.GetType(SwigCPtr);
227                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
228                 return ret;
229             }
230             set
231             {
232                 Interop.Window.SetType(SwigCPtr, (int)value);
233                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
234             }
235         }
236
237         /// <summary>
238         /// Gets/Sets a window title.
239         /// </summary>
240         /// <since_tizen> 4 </since_tizen>
241         public string Title
242         {
243             get
244             {
245                 return _windowTitle;
246             }
247             set
248             {
249                 _windowTitle = value;
250                 SetClass(_windowTitle, "");
251             }
252         }
253
254         /// <summary>
255         /// The rendering behavior of a Window.
256         /// </summary>
257         /// <since_tizen> 5 </since_tizen>
258         public RenderingBehaviorType RenderingBehavior
259         {
260             get
261             {
262                 return GetRenderingBehavior();
263             }
264             set
265             {
266                 SetRenderingBehavior(value);
267             }
268         }
269
270         /// <summary>
271         /// The window size property (read-only).
272         /// </summary>
273         /// <since_tizen> 3 </since_tizen>
274         public Size2D Size
275         {
276             get
277             {
278                 Size2D ret = GetSize();
279                 return ret;
280             }
281         }
282
283         /// <summary>
284         /// The background color property.
285         /// </summary>
286         /// <since_tizen> 3 </since_tizen>
287         public Color BackgroundColor
288         {
289             set
290             {
291                 SetBackgroundColor(value);
292             }
293             get
294             {
295                 Color ret = GetBackgroundColor();
296                 return ret;
297             }
298         }
299
300         /// <summary>
301         /// The DPI property (read-only).<br />
302         /// Retrieves the DPI of the display device to which the Window is connected.<br />
303         /// </summary>
304         /// <since_tizen> 3 </since_tizen>
305         public Vector2 Dpi
306         {
307             get
308             {
309                 return GetDpi();
310             }
311         }
312
313         /// <summary>
314         /// The layer count property (read-only).<br />
315         /// Queries the number of on-Window layers.<br />
316         /// </summary>
317         /// <since_tizen> 3 </since_tizen>
318         public uint LayerCount
319         {
320             get
321             {
322                 return GetLayerCount();
323             }
324         }
325
326         /// <summary>
327         /// Gets or sets a size of the window.
328         /// </summary>
329         /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
330         /// <since_tizen> 4 </since_tizen>
331         public Size2D WindowSize
332         {
333             get
334             {
335                 return GetWindowSize();
336             }
337             set
338             {
339                 SetWindowSize(value);
340             }
341         }
342
343         /// <summary>
344         /// Gets or sets a position of the window.
345         /// </summary>
346         /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
347         /// <since_tizen> 4 </since_tizen>
348         public Position2D WindowPosition
349         {
350             get
351             {
352                 return GetPosition();
353             }
354             set
355             {
356                 SetPosition(value);
357             }
358         }
359
360         /// <summary>
361         /// Sets position and size of the window. This API guarantees that
362         /// both moving and resizing of window will appear on the screen at once.
363         /// </summary>
364         [EditorBrowsable(EditorBrowsableState.Never)]
365         public Rectangle WindowPositionSize
366         {
367             get
368             {
369                 Position2D position = GetPosition();
370                 Size2D size = GetSize();
371                 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
372                 return ret;
373             }
374             set
375             {
376                 SetPositionSize(value);
377             }
378         }
379
380         internal static Vector4 DEFAULT_BACKGROUND_COLOR
381         {
382             get
383             {
384                 global::System.IntPtr cPtr = Interop.Stage.DefaultBackgroundColorGet();
385                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
386                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
387                 return ret;
388             }
389         }
390
391         internal static Vector4 DEBUG_BACKGROUND_COLOR
392         {
393             get
394             {
395                 global::System.IntPtr cPtr = Interop.Stage.DebugBackgroundColorGet();
396                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
397                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
398                 return ret;
399             }
400         }
401
402         internal List<Layer> LayersChildren
403         {
404             get
405             {
406                 return _childLayers;
407             }
408         }
409
410         /// <summary>
411         ///  Get the LayoutController for this Window.
412         /// </summary>
413         internal LayoutController LayoutController
414         {
415             get
416             {
417                 return localController;
418             }
419         }
420
421         /// <summary>
422         /// Feed a key-event into the window.
423         /// </summary>
424         /// <param name="keyEvent">The key event to feed.</param>
425         /// <since_tizen> 4 </since_tizen>
426         [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
427         public static void FeedKeyEvent(Key keyEvent)
428         {
429             Interop.Window.FeedKeyEvent(Key.getCPtr(keyEvent));
430             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
431         }
432
433         /// <summary>
434         /// Sets whether the window accepts a focus or not.
435         /// </summary>
436         /// <param name="accept">If a focus is accepted or not. The default is true.</param>
437         /// <since_tizen> 3 </since_tizen>
438         public void SetAcceptFocus(bool accept)
439         {
440             Interop.Window.SetAcceptFocus(SwigCPtr, accept);
441             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
442         }
443
444         /// <summary>
445         /// Returns whether the window accepts a focus or not.
446         /// </summary>
447         /// <returns>True if the window accepts a focus, false otherwise.</returns>
448         /// <since_tizen> 3 </since_tizen>
449         public bool IsFocusAcceptable()
450         {
451             bool ret = Interop.Window.IsFocusAcceptable(SwigCPtr);
452             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
453
454             return ret;
455         }
456
457         /// <summary>
458         /// Shows the window if it is hidden.
459         /// </summary>
460         /// <since_tizen> 3 </since_tizen>
461         public void Show()
462         {
463             Interop.Window.Show(SwigCPtr);
464             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
465         }
466
467         /// <summary>
468         /// Hides the window if it is showing.
469         /// </summary>
470         /// <since_tizen> 3 </since_tizen>
471         public void Hide()
472         {
473             Interop.Window.Hide(SwigCPtr);
474             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
475         }
476
477         /// <summary>
478         /// Retrieves whether the window is visible or not.
479         /// </summary>
480         /// <returns>True if the window is visible.</returns>
481         /// <since_tizen> 3 </since_tizen>
482         public bool IsVisible()
483         {
484             bool temp = Interop.Window.IsVisible(SwigCPtr);
485             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
486             return temp;
487         }
488
489         /// <summary>
490         /// Gets the count of supported auxiliary hints of the window.
491         /// </summary>
492         /// <returns>The number of supported auxiliary hints.</returns>
493         /// <since_tizen> 3 </since_tizen>
494         public uint GetSupportedAuxiliaryHintCount()
495         {
496             uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(SwigCPtr);
497             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
498             return ret;
499         }
500
501         /// <summary>
502         /// Gets the supported auxiliary hint string of the window.
503         /// </summary>
504         /// <param name="index">The index of the supported auxiliary hint lists.</param>
505         /// <returns>The auxiliary hint string of the index.</returns>
506         /// <since_tizen> 3 </since_tizen>
507         public string GetSupportedAuxiliaryHint(uint index)
508         {
509             string ret = Interop.Window.GetSupportedAuxiliaryHint(SwigCPtr, index);
510             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
511             return ret;
512         }
513
514         /// <summary>
515         /// Creates an auxiliary hint of the window.
516         /// </summary>
517         /// <param name="hint">The auxiliary hint string.</param>
518         /// <param name="value">The value string.</param>
519         /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
520         /// <since_tizen> 3 </since_tizen>
521         public uint AddAuxiliaryHint(string hint, string value)
522         {
523             uint ret = Interop.Window.AddAuxiliaryHint(SwigCPtr, hint, value);
524             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
525             return ret;
526         }
527
528         /// <summary>
529         /// Removes an auxiliary hint of the window.
530         /// </summary>
531         /// <param name="id">The ID of the auxiliary hint.</param>
532         /// <returns>True if no error occurred, false otherwise.</returns>
533         /// <since_tizen> 3 </since_tizen>
534         public bool RemoveAuxiliaryHint(uint id)
535         {
536             bool ret = Interop.Window.RemoveAuxiliaryHint(SwigCPtr, id);
537             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
538             return ret;
539         }
540
541         /// <summary>
542         /// Changes a value of the auxiliary hint.
543         /// </summary>
544         /// <param name="id">The auxiliary hint ID.</param>
545         /// <param name="value">The value string to be set.</param>
546         /// <returns>True if no error occurred, false otherwise.</returns>
547         /// <since_tizen> 3 </since_tizen>
548         public bool SetAuxiliaryHintValue(uint id, string value)
549         {
550             bool ret = Interop.Window.SetAuxiliaryHintValue(SwigCPtr, id, value);
551             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
552             return ret;
553         }
554
555         /// <summary>
556         /// Gets a value of the auxiliary hint.
557         /// </summary>
558         /// <param name="id">The auxiliary hint ID.</param>
559         /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
560         /// <since_tizen> 3 </since_tizen>
561         public string GetAuxiliaryHintValue(uint id)
562         {
563             string ret = Interop.Window.GetAuxiliaryHintValue(SwigCPtr, id);
564             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
565             return ret;
566         }
567
568         /// <summary>
569         /// Gets an ID of the auxiliary hint string.
570         /// </summary>
571         /// <param name="hint">The auxiliary hint string.</param>
572         /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
573         /// <since_tizen> 3 </since_tizen>
574         public uint GetAuxiliaryHintId(string hint)
575         {
576             uint ret = Interop.Window.GetAuxiliaryHintId(SwigCPtr, hint);
577             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
578             return ret;
579         }
580
581         /// <summary>
582         /// Sets a region to accept input events.
583         /// </summary>
584         /// <param name="inputRegion">The region to accept input events.</param>
585         /// <since_tizen> 3 </since_tizen>
586         public void SetInputRegion(Rectangle inputRegion)
587         {
588             Interop.Window.SetInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
589             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
590         }
591
592         /// <summary>
593         /// Sets a priority level for the specified notification window.
594         /// </summary>
595         /// <param name="level">The notification window level.</param>
596         /// <returns>True if no error occurred, false otherwise.</returns>
597         /// <since_tizen> 3 </since_tizen>
598         public bool SetNotificationLevel(NotificationLevel level)
599         {
600             bool ret = Interop.Window.SetNotificationLevel(SwigCPtr, (int)level);
601             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
602             return ret;
603         }
604
605         /// <summary>
606         /// Gets a priority level for the specified notification window.
607         /// </summary>
608         /// <returns>The notification window level.</returns>
609         /// <since_tizen> 3 </since_tizen>
610         public NotificationLevel GetNotificationLevel()
611         {
612             NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(SwigCPtr);
613             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
614             return ret;
615         }
616
617         /// <summary>
618         /// Sets a transparent window's visual state to opaque. <br />
619         /// If a visual state of a transparent window is opaque, <br />
620         /// then the window manager could handle it as an opaque window when calculating visibility.
621         /// </summary>
622         /// <param name="opaque">Whether the window's visual state is opaque.</param>
623         /// <remarks>This will have no effect on an opaque window. <br />
624         /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
625         /// </remarks>
626         /// <since_tizen> 3 </since_tizen>
627         public void SetOpaqueState(bool opaque)
628         {
629             Interop.Window.SetOpaqueState(SwigCPtr, opaque);
630             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
631         }
632
633         /// <summary>
634         /// Returns whether a transparent window's visual state is opaque or not.
635         /// </summary>
636         /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
637         /// <remarks> The return value has no meaning on an opaque window. </remarks>
638         /// <since_tizen> 3 </since_tizen>
639         public bool IsOpaqueState()
640         {
641             bool ret = Interop.Window.IsOpaqueState(SwigCPtr);
642             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
643             return ret;
644         }
645
646         /// <summary>
647         /// Sets a window's screen off mode.
648         /// </summary>
649         /// <param name="screenOffMode">The screen mode.</param>
650         /// <returns>True if no error occurred, false otherwise.</returns>
651         /// <since_tizen> 4 </since_tizen>
652         public bool SetScreenOffMode(ScreenOffMode screenOffMode)
653         {
654             bool ret = Interop.Window.SetScreenOffMode(SwigCPtr, (int)screenOffMode);
655             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
656             return ret;
657         }
658
659         /// <summary>
660         /// Gets the screen mode of the window.
661         /// </summary>
662         /// <returns>The screen off mode.</returns>
663         /// <since_tizen> 4 </since_tizen>
664         public ScreenOffMode GetScreenOffMode()
665         {
666             ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(SwigCPtr);
667             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
668             return ret;
669         }
670
671         /// <summary>
672         /// Sets preferred brightness of the window.
673         /// </summary>
674         /// <param name="brightness">The preferred brightness (0 to 100).</param>
675         /// <returns>True if no error occurred, false otherwise.</returns>
676         /// <since_tizen> 3 </since_tizen>
677         public bool SetBrightness(int brightness)
678         {
679             bool ret = Interop.Window.SetBrightness(SwigCPtr, brightness);
680             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
681             return ret;
682         }
683
684         /// <summary>
685         /// Gets the preferred brightness of the window.
686         /// </summary>
687         /// <returns>The preferred brightness.</returns>
688         /// <since_tizen> 3 </since_tizen>
689         public int GetBrightness()
690         {
691             int ret = Interop.Window.GetBrightness(SwigCPtr);
692             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
693             return ret;
694         }
695
696         /// <summary>
697         /// Sets the window name and the class string.
698         /// </summary>
699         /// <param name="name">The name of the window.</param>
700         /// <param name="klass">The class of the window.</param>
701         /// <since_tizen> 4 </since_tizen>
702         public void SetClass(string name, string klass)
703         {
704             Interop.Window.SetClass(SwigCPtr, name, klass);
705             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
706         }
707
708         /// <summary>
709         /// Raises the window to the top of the window stack.
710         /// </summary>
711         /// <since_tizen> 3 </since_tizen>
712         public void Raise()
713         {
714             Interop.Window.Raise(SwigCPtr);
715             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
716         }
717
718         /// <summary>
719         /// Lowers the window to the bottom of the window stack.
720         /// </summary>
721         /// <since_tizen> 3 </since_tizen>
722         public void Lower()
723         {
724             Interop.Window.Lower(SwigCPtr);
725             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
726         }
727
728         /// <summary>
729         /// Activates the window to the top of the window stack even it is iconified.
730         /// </summary>
731         /// <since_tizen> 3 </since_tizen>
732         public void Activate()
733         {
734             Interop.Window.Activate(SwigCPtr);
735             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
736         }
737
738         /// <summary>
739         /// Gets the default ( root ) layer.
740         /// </summary>
741         /// <returns>The root layer.</returns>
742         /// <since_tizen> 3 </since_tizen>
743         public Layer GetDefaultLayer()
744         {
745             return this.GetRootLayer();
746         }
747
748         /// <summary>
749         /// Add a child view to window.
750         /// </summary>
751         /// <param name="view">the child should be added to the window.</param>
752         /// <since_tizen> 3 </since_tizen>
753         public void Add(View view)
754         {
755             Interop.Actor.Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
756             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
757             this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
758             if (null != view)
759             {
760                 view.InternalParent = this.GetRootLayer();
761             }
762         }
763
764         /// <summary>
765         /// Remove a child view from window.
766         /// </summary>
767         /// <param name="view">the child to be removed.</param>
768         /// <since_tizen> 3 </since_tizen>
769         public void Remove(View view)
770         {
771             Interop.Actor.Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
772             this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
773             if (null != view)
774             {
775                 view.InternalParent = null;
776             }
777         }
778
779         /// <summary>
780         /// Retrieves the layer at a specified depth.
781         /// </summary>
782         /// <param name="depth">The layer's depth index.</param>
783         /// <returns>The layer found at the given depth.</returns>
784         /// <since_tizen> 3 </since_tizen>
785         public Layer GetLayer(uint depth)
786         {
787             if (depth < LayersChildren?.Count)
788             {
789                 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
790                 return ret;
791             }
792             else
793             {
794                 return null;
795             }
796         }
797
798         /// <summary>
799         /// Destroy the window immediately.
800         /// </summary>
801         [EditorBrowsable(EditorBrowsableState.Never)]
802         public void Destroy()
803         {
804             this.Dispose();
805         }
806
807         /// <summary>
808         /// Keep rendering for at least the given amount of time.
809         /// </summary>
810         /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
811         /// <since_tizen> 3 </since_tizen>
812         public void KeepRendering(float durationSeconds)
813         {
814             Interop.Stage.KeepRendering(stageCPtr, durationSeconds);
815             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
816         }
817
818         /// <summary>
819         /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
820         /// This function can be used for following example scenarios: <br />
821         /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
822         /// </summary>
823         /// <param name="DaliKey">The key code to grab.</param>
824         /// <returns>True if the grab succeeds.</returns>
825         /// <since_tizen> 3 </since_tizen>
826         public bool GrabKeyTopmost(int DaliKey)
827         {
828             bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
829             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
830             return ret;
831         }
832
833         /// <summary>
834         /// Ungrabs the key specified by a key for the window.<br />
835         /// 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 />
836         /// </summary>
837         /// <param name="DaliKey">The key code to ungrab.</param>
838         /// <returns>True if the ungrab succeeds.</returns>
839         /// <since_tizen> 3 </since_tizen>
840         public bool UngrabKeyTopmost(int DaliKey)
841         {
842             bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
843             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
844             return ret;
845         }
846
847         /// <summary>
848         ///  Grabs the key specified by a key for a window in a GrabMode. <br />
849         ///  Details: This function can be used for following example scenarios: <br />
850         ///  - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
851         ///  - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
852         ///  - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
853         /// </summary>
854         /// <param name="DaliKey">The key code to grab.</param>
855         /// <param name="GrabMode">The grab mode for the key.</param>
856         /// <returns>True if the grab succeeds.</returns>
857         /// <since_tizen> 3 </since_tizen>
858         public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
859         {
860             bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey, (int)GrabMode);
861             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
862             return ret;
863         }
864
865         /// <summary>
866         /// Ungrabs the key specified by a key for a window.<br />
867         /// 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 />
868         /// </summary>
869         /// <param name="DaliKey">The key code to ungrab.</param>
870         /// <returns>True if the ungrab succeeds.</returns>
871         /// <since_tizen> 3 </since_tizen>
872         public bool UngrabKey(int DaliKey)
873         {
874             bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
875             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
876             return ret;
877         }
878
879         /// <summary>
880         /// Sets the keyboard repeat information.
881         /// </summary>
882         /// <param name="rate">The key repeat rate value in seconds.</param>
883         /// <param name="delay">The key repeat delay value in seconds.</param>
884         /// <returns>True if setting the keyboard repeat succeeds.</returns>
885         /// <since_tizen> 5 </since_tizen>
886         public bool SetKeyboardRepeatInfo(float rate, float delay)
887         {
888             bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
889             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
890             return ret;
891         }
892
893         /// <summary>
894         /// Gets the keyboard repeat information.
895         /// </summary>
896         /// <param name="rate">The key repeat rate value in seconds.</param>
897         /// <param name="delay">The key repeat delay value in seconds.</param>
898         /// <returns>True if setting the keyboard repeat succeeds.</returns>
899         /// <since_tizen> 5 </since_tizen>
900         public bool GetKeyboardRepeatInfo(out float rate, out float delay)
901         {
902             bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
903             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
904             return ret;
905         }
906
907         /// <summary>
908         /// Adds a layer to the stage.
909         /// </summary>
910         /// <param name="layer">Layer to add.</param>
911         /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
912         /// <since_tizen> 3 </since_tizen>
913         public void AddLayer(Layer layer)
914         {
915             Add(layer);
916         }
917
918         /// <summary>
919         /// Removes a layer from the stage.
920         /// </summary>
921         /// <param name="layer">Layer to remove.</param>
922         /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
923         /// <since_tizen> 3 </since_tizen>
924         public void RemoveLayer(Layer layer)
925         {
926             Remove(layer);
927         }
928
929         /// <summary>
930         /// Feeds a key event into the window.
931         /// </summary>
932         /// <param name="keyEvent">The key event to feed.</param>
933         /// <since_tizen> 5 </since_tizen>
934         public void FeedKey(Key keyEvent)
935         {
936             Interop.Window.FeedKeyEvent(Key.getCPtr(keyEvent));
937             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
938         }
939
940         /// <summary>
941         /// Allows at least one more render, even when paused.
942         /// The window should be shown, not minimised.
943         /// </summary>
944         /// <since_tizen> 4 </since_tizen>
945         public void RenderOnce()
946         {
947             Interop.Window.RenderOnce(SwigCPtr);
948             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
949         }
950
951         /// <summary>
952         /// Sets whether the window is transparent or not.
953         /// </summary>
954         /// <param name="transparent">Whether the window is transparent or not.</param>
955         /// <since_tizen> 5 </since_tizen>
956         public void SetTransparency(bool transparent)
957         {
958             Interop.Window.SetTransparency(SwigCPtr, transparent);
959             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
960
961             // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
962         }
963
964         /// <summary>
965         /// Sets parent window of the window.
966         /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
967         /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
968         /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
969         /// </summary>
970         /// <param name="parent">The parent window.</param>
971         /// <since_tizen> 6 </since_tizen>
972         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
973         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
974         public void SetParent(Window parent)
975         {
976             if (IsSupportedMultiWindow() == false)
977             {
978                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
979             }
980             Interop.Window.SetParent(SwigCPtr, Window.getCPtr(parent));
981             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
982         }
983
984         /// <summary>
985         /// Unsets parent window of the window.
986         /// After unsetting, the window is disconnected his parent window.
987         /// </summary>
988         /// <since_tizen> 6 </since_tizen>
989         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
990         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
991         public void Unparent()
992         {
993             if (IsSupportedMultiWindow() == false)
994             {
995                 NUILog.Error("Fail to create window. because this device does not support opengles.surfaceless_context.");
996             }
997             Interop.Window.Unparent(SwigCPtr);
998             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
999         }
1000
1001         /// <summary>
1002         /// Gets parent window of the window.
1003         /// </summary>
1004         /// <returns>The parent window of the window.</returns>
1005         /// <since_tizen> 6 </since_tizen>
1006         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1007         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1008         public Window GetParent()
1009         {
1010             if (IsSupportedMultiWindow() == false)
1011             {
1012                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1013             }
1014             Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.GetParent(SwigCPtr)) as Window;
1015             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1016             return ret;
1017         }
1018
1019         /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
1020         [EditorBrowsable(EditorBrowsableState.Never)]
1021         public void ObjectDump()
1022         {
1023             Layer rootLayer = GetRootLayer();
1024             foreach (View view in rootLayer.Children)
1025             {
1026                 view.ObjectDump();
1027             }
1028         }
1029
1030         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
1031         {
1032             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1033         }
1034
1035         internal static bool IsInstalled()
1036         {
1037             bool ret = Interop.Stage.IsInstalled();
1038             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1039             return ret;
1040         }
1041
1042         /// <summary>
1043         /// Adds an orientation to the list of available orientations.
1044         /// </summary>
1045         /// <param name="orientation">The available orientation to add</param>
1046         /// <since_tizen> 6 </since_tizen>
1047         public void AddAvailableOrientation(Window.WindowOrientation orientation)
1048         {
1049             Interop.Window.AddAvailableOrientation(SwigCPtr, (int)orientation);
1050             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1051         }
1052
1053         /// <summary>
1054         /// Removes an orientation from the list of available orientations.
1055         /// </summary>
1056         /// <param name="orientation">The available orientation to remove.</param>
1057         /// <since_tizen> 6 </since_tizen>
1058         public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1059         {
1060             Interop.Window.RemoveAvailableOrientation(SwigCPtr, (int)orientation);
1061             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1062         }
1063
1064         /// <summary>
1065         /// Sets a preferred orientation.
1066         /// </summary>
1067         /// <param name="orientation">The preferred orientation.</param>
1068         /// <since_tizen> 6 </since_tizen>
1069         public void SetPreferredOrientation(Window.WindowOrientation orientation)
1070         {
1071             Interop.Window.SetPreferredOrientation(SwigCPtr, (int)orientation);
1072             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1073         }
1074
1075         /// <summary>
1076         /// Gets the preferred orientation.
1077         /// </summary>
1078         /// <since_tizen> 6 </since_tizen>
1079         /// <returns>The preferred orientation if previously set, or none.</returns>
1080         public Window.WindowOrientation GetPreferredOrientation()
1081         {
1082             Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetPreferredOrientation(SwigCPtr);
1083             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1084             return ret;
1085         }
1086
1087         /// <summary>
1088         /// Gets current orientation of the window.
1089         /// </summary>
1090         /// <since_tizen> 6 </since_tizen>
1091         /// <returns>The current window orientation if previously set, or none.</returns>
1092         [EditorBrowsable(EditorBrowsableState.Never)]
1093         public Window.WindowOrientation GetCurrentOrientation()
1094         {
1095             Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetCurrentOrientation(SwigCPtr);
1096             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1097             return ret;
1098         }
1099
1100         /// <summary>
1101         /// Sets available orientations of the window.
1102         /// This API is for setting several orientations one time.
1103         /// </summary>
1104         /// <param name="orientations">The list of orientations.</param>
1105         /// <since_tizen> 6 </since_tizen>
1106         [EditorBrowsable(EditorBrowsableState.Never)]
1107         public void SetAvailableOrientations(List<Window.WindowOrientation> orientations)
1108         {
1109             PropertyArray orientationArray = new PropertyArray();
1110             if (null != orientations)
1111             {
1112                 for (int i = 0; i < orientations.Count; i++)
1113                 {
1114                     orientationArray.PushBack(new PropertyValue((int)orientations[i]));
1115                 }
1116             }
1117
1118             Interop.Window.SetAvailableOrientations(SwigCPtr, PropertyArray.getCPtr(orientationArray));
1119             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1120         }
1121
1122         /// <summary>
1123         /// Get native window ID
1124         /// </summary>
1125         /// <returns>native window ID</returns>
1126         [EditorBrowsable(EditorBrowsableState.Never)]
1127         public int GetNativeId()
1128         {
1129             int ret = Interop.Window.GetNativeId(SwigCPtr);
1130             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1131             return ret;
1132         }
1133
1134         internal Any GetNativeHandle()
1135         {
1136             Any ret = new Any(Interop.WindowInternal.WindowGetNativeHandle(SwigCPtr), true);
1137             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1138             return ret;
1139         }
1140
1141         internal void Add(Layer layer)
1142         {
1143             if (null == layer)
1144             {
1145                 throw new ArgumentNullException(nameof(layer));
1146             }
1147             Interop.Window.Add(SwigCPtr, Layer.getCPtr(layer));
1148             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1149
1150             LayersChildren?.Add(layer);
1151             layer.SetWindow(this);
1152         }
1153
1154         internal void Remove(Layer layer)
1155         {
1156             if (null == layer)
1157             {
1158                 throw new ArgumentNullException(nameof(layer));
1159             }
1160             Interop.Window.Remove(SwigCPtr, Layer.getCPtr(layer));
1161             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1162
1163             LayersChildren?.Remove(layer);
1164             layer.SetWindow(null);
1165         }
1166
1167         internal Vector2 GetSize()
1168         {
1169             var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), false);
1170             Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1171             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1172             return ret;
1173         }
1174
1175         internal RenderTaskList GetRenderTaskList()
1176         {
1177             RenderTaskList ret = new RenderTaskList(Interop.Stage.GetRenderTaskList(stageCPtr), true);
1178             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1179             return ret;
1180         }
1181
1182         /// <summary>
1183         /// Queries the number of on-window layers.
1184         /// </summary>
1185         /// <returns>The number of layers.</returns>
1186         /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1187         internal uint GetLayerCount()
1188         {
1189             if (LayersChildren == null || LayersChildren.Count < 0)
1190                 return 0;
1191
1192             return (uint)LayersChildren.Count;
1193         }
1194
1195         internal Layer GetRootLayer()
1196         {
1197             // Window.IsInstalled() is actually true only when called from event thread and
1198             // Core has been initialized, not when Stage is ready.
1199             if (_rootLayer == null && Window.IsInstalled())
1200             {
1201                 _rootLayer = new Layer(Interop.Window.GetRootLayer(SwigCPtr), true);
1202                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1203                 LayersChildren?.Add(_rootLayer);
1204                 _rootLayer.SetWindow(this);
1205             }
1206             return _rootLayer;
1207         }
1208
1209         internal void SetBackgroundColor(Vector4 color)
1210         {
1211             Interop.Window.SetBackgroundColor(SwigCPtr, Vector4.getCPtr(color));
1212             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1213         }
1214
1215         internal Vector4 GetBackgroundColor()
1216         {
1217             Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(SwigCPtr), true);
1218             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1219             return ret;
1220         }
1221
1222         internal Vector2 GetDpi()
1223         {
1224             Vector2 ret = new Vector2(Interop.Stage.GetDpi(stageCPtr), true);
1225             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1226             return ret;
1227         }
1228
1229         internal ObjectRegistry GetObjectRegistry()
1230         {
1231             ObjectRegistry ret = new ObjectRegistry(Interop.Stage.GetObjectRegistry(stageCPtr), true);
1232             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1233             return ret;
1234         }
1235
1236         internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1237         {
1238             Interop.Stage.SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1239             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1240         }
1241
1242         internal RenderingBehaviorType GetRenderingBehavior()
1243         {
1244             RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.GetRenderingBehavior(stageCPtr);
1245             if (NDalicPINVOKE.SWIGPendingException.Pending)
1246                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1247             return ret;
1248         }
1249
1250         internal void SetWindowSize(Size2D size)
1251         {
1252             if (null == size)
1253             {
1254                 throw new ArgumentNullException(nameof(size));
1255             }
1256             var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1257             Interop.Window.SetSize(SwigCPtr, Uint16Pair.getCPtr(val));
1258
1259             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1260
1261             // Resetting Window size should request a relayout of the tree.
1262         }
1263
1264         internal Size2D GetWindowSize()
1265         {
1266             var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), false);
1267             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1268
1269             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1270             return ret;
1271         }
1272
1273         internal void SetPosition(Position2D position)
1274         {
1275             if (null == position)
1276             {
1277                 throw new ArgumentNullException(nameof(position));
1278             }
1279             var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1280             Interop.Window.SetPosition(SwigCPtr, Uint16Pair.getCPtr(val));
1281
1282             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1283             // Setting Position of the window should request a relayout of the tree.
1284         }
1285
1286         internal Position2D GetPosition()
1287         {
1288             var val = new Uint16Pair(Interop.Window.GetPosition(SwigCPtr), true);
1289             Position2D ret = new Position2D(val.GetX(), val.GetY());
1290
1291             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1292             return ret;
1293         }
1294
1295         internal void SetPositionSize(Rectangle positionSize)
1296         {
1297             Interop.Window.SetPositionSize(SwigCPtr, Rectangle.getCPtr(positionSize));
1298
1299             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1300
1301             // Setting Position of the window should request a relayout of the tree.
1302         }
1303
1304         /// <summary>
1305         /// Add FrameUpdateCallback
1306         /// </summary>
1307         [EditorBrowsable(EditorBrowsableState.Never)]
1308         public void AddFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1309         {
1310             frameUpdateCallback?.AddFrameUpdateCallback(stageCPtr, Layer.getCPtr(GetRootLayer()));
1311         }
1312
1313         /// <summary>
1314         /// Remove FrameUpdateCallback
1315         /// </summary>
1316         [EditorBrowsable(EditorBrowsableState.Never)]
1317         public void RemoveFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1318         {
1319             frameUpdateCallback?.RemoveFrameUpdateCallback(stageCPtr);
1320         }
1321
1322         /// <summary>
1323         /// Dispose for Window
1324         /// </summary>
1325         [EditorBrowsable(EditorBrowsableState.Never)]
1326         protected override void Dispose(DisposeTypes type)
1327         {
1328             if (disposed)
1329             {
1330                 return;
1331             }
1332
1333             if (type == DisposeTypes.Explicit)
1334             {
1335                 //Called by User
1336                 //Release your own managed resources here.
1337                 //You should release all of your own disposable objects here.
1338
1339                 if (_rootLayer != null)
1340                 {
1341                     _rootLayer.Dispose();
1342                 }
1343
1344                 localController?.Dispose();
1345
1346                 foreach (var layer in _childLayers)
1347                 {
1348                     if (layer != null)
1349                     {
1350                         layer.Dispose();
1351                     }
1352                 }
1353
1354                 _childLayers.Clear();
1355             }
1356
1357             this.DisconnectNativeSignals();
1358
1359             base.Dispose(type);
1360         }
1361
1362         /// This will not be public opened.
1363         [EditorBrowsable(EditorBrowsableState.Never)]
1364         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1365         {
1366             Interop.Window.DeleteWindow(swigCPtr);
1367         }
1368
1369         private static Dictionary<int, internalHookCallbackType> frameCallbackList = new Dictionary<int, internalHookCallbackType>();
1370
1371         private static readonly object locker = new object();
1372
1373         private static int key = 0;
1374
1375         private static FrameCallbackType internalHookFrameCallback = OnInternalHookFrameCallback;
1376
1377         private struct internalHookCallbackType
1378         {
1379             public FrameCallbackType userCallback;
1380             public int frameId;
1381         }
1382
1383         private static void OnInternalHookFrameCallback(int id)
1384         {
1385             lock (locker)
1386             {
1387                 if (frameCallbackList.ContainsKey(id))
1388                 {
1389                     if (frameCallbackList[id].userCallback != null)
1390                     {
1391                         frameCallbackList[id].userCallback.Invoke(frameCallbackList[id].frameId);
1392                         frameCallbackList.Remove(id);
1393                     }
1394                     else
1395                     {
1396                         NUILog.Error($"found userCallback is NULL");
1397                         frameCallbackList.Remove(id);
1398                     }
1399                 }
1400             }
1401         }
1402
1403         private int AddInterHookCallback(FrameCallbackType callback, int frameId)
1404         {
1405             if (null == callback)
1406             {
1407                 throw new ArgumentNullException(nameof(callback), "FrameCallbackType should not be null");
1408             }
1409             var assignedKey = 0;
1410             lock (locker)
1411             {
1412                 key++;
1413                 assignedKey = key;
1414                 frameCallbackList.Add(assignedKey, new internalHookCallbackType()
1415                 {
1416                     userCallback = callback,
1417                     frameId = frameId,
1418                 });
1419             }
1420             return assignedKey;
1421         }
1422
1423         /// <summary>
1424         /// Type of callback which is called when the frame rendering is done by graphics driver or when the frame is displayed on display.
1425         /// </summary>
1426         /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1427         [EditorBrowsable(EditorBrowsableState.Never)]
1428         public delegate void FrameCallbackType(int frameId);
1429
1430         /// <summary>
1431         /// Adds a callback that is called when the frame rendering is done by the graphics driver.
1432         /// A callback of the following type may be used:
1433         /// <code>
1434         /// void MyFunction( int frameId )
1435         /// </code>
1436         /// This callback will be deleted once it is called. 
1437         /// <remarks>
1438         /// Ownership of the callback is passed onto this class
1439         /// </remarks>
1440         /// </summary>
1441         /// <param name="callback">The function to call</param>
1442         /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1443         /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1444         [EditorBrowsable(EditorBrowsableState.Never)]
1445         public void AddFrameRenderedCallback(FrameCallbackType callback, int frameId)
1446         {
1447             var assignedKey = AddInterHookCallback(callback, frameId);
1448             Interop.WindowInternal.AddFrameRenderedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1449
1450             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1451         }
1452
1453         /// <summary>
1454         /// Adds a callback that is called when the frame is displayed on the display.
1455         /// A callback of the following type may be used:
1456         /// <code>
1457         /// void MyFunction( int frameId )
1458         /// </code>
1459         /// This callback will be deleted once it is called. 
1460         /// <remarks>
1461         /// Ownership of the callback is passed onto this class
1462         /// </remarks>
1463         /// </summary>
1464         /// <param name="callback">The function to call</param>
1465         /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1466         /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1467         [EditorBrowsable(EditorBrowsableState.Never)]
1468         public void AddFramePresentedCallback(FrameCallbackType callback, int frameId)
1469         {
1470             var assignedKey = AddInterHookCallback(callback, frameId);
1471             Interop.WindowInternal.AddFramePresentedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1472
1473             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1474         }
1475     }
1476 }