[NUI] Add dispose.
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Window / Window.cs
1 /*
2  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 extern alias TizenSystemInformation;
19 using TizenSystemInformation.Tizen.System;
20
21 using System;
22 using System.ComponentModel;
23 using System.Collections.Generic;
24 using System.Runtime.InteropServices;
25
26 using Tizen.NUI.BaseComponents;
27
28 namespace Tizen.NUI
29 {
30     /// <summary>
31     /// The window class is used internally for drawing.<br />
32     /// The window has an orientation and indicator properties.<br />
33     /// </summary>
34     /// <since_tizen> 3 </since_tizen>
35     public partial class Window : BaseHandle
36     {
37         private HandleRef stageCPtr;
38         private Layer rootLayer;
39         private Layer borderLayer;
40         private string windowTitle;
41         private List<Layer> childLayers = new List<Layer>();
42         private LayoutController localController;
43
44         static internal bool IsSupportedMultiWindow()
45         {
46             bool isSupported = false;
47             try
48             {
49                 Information.TryGetValue("http://tizen.org/feature/opengles.surfaceless_context", out isSupported);
50             }
51             catch (DllNotFoundException e)
52             {
53                 Tizen.Log.Fatal("NUI", $"{e}\n");
54             }
55             return isSupported;
56         }
57
58         internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
59         {
60             if (Interop.Stage.IsInstalled())
61             {
62                 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.GetCurrent());
63
64                 localController = new LayoutController(this);
65                 NUILog.Debug("layoutController id:" + localController.GetId());
66             }
67         }
68
69         /// <summary>
70         /// A helper method to get the current window where the view is added
71         /// </summary>
72         /// <param name="view">The View added to the window</param>
73         /// <returns>A Window.</returns>
74         [EditorBrowsable(EditorBrowsableState.Never)]
75         static public Window Get(View view)
76         {
77             if (view == null)
78             {
79                 NUILog.Error("if there is no view, it can not get a window");
80                 return null;
81             }
82
83             //to fix memory leak issue, match the handle count with native side.
84             Window ret = view.GetInstanceSafely<Window>(Interop.Window.Get(View.getCPtr(view)));
85             if (NDalicPINVOKE.SWIGPendingException.Pending)throw NDalicPINVOKE.SWIGPendingException.Retrieve();
86             return ret;
87         }
88
89         /// <summary>
90         /// Creates a new Window.<br />
91         /// This creates an extra window in addition to the default main window<br />
92         /// </summary>
93         /// <param name="windowPosition">The position and size of the Window.</param>
94         /// <param name="isTranslucent">Whether Window is translucent.</param>
95         /// <returns>A new Window.</returns>
96         /// <since_tizen> 6 </since_tizen>
97         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
98         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
99         public Window(Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
100         {
101             if (IsSupportedMultiWindow() == false)
102             {
103                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
104             }
105             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
106         }
107
108         /// <summary>
109         /// Creates a new Window with a specific name.<br />
110         /// This creates an extra window in addition to the default main window<br />
111         /// </summary>
112         /// <param name="name">The name for extra window. </param>
113         /// <param name="windowPosition">The position and size of the Window.</param>
114         /// <param name="isTranslucent">Whether Window is translucent.</param>
115         /// <returns>A new Window.</returns>
116         /// <since_tizen> 6 </since_tizen>
117         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
118         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
119         public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
120         {
121             if (IsSupportedMultiWindow() == false)
122             {
123                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
124             }
125             this.windowTitle = name;
126             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
127         }
128
129         /// <summary>
130         /// Creates a new Window with a specific name.<br />
131         /// This creates an extra window in addition to the default main window<br />
132         /// </summary>
133         /// <param name="name">The name for extra window. </param>
134         /// <param name="borderInterface"><see cref="Tizen.NUI.IBorderInterface"/>If borderInterface is null, defaultBorder is enabled.</param>
135         /// <param name="windowPosition">The position and size of the Window.</param>
136         /// <param name="isTranslucent">Whether Window is translucent.</param>
137         /// <returns>A new Window.</returns>
138         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
139         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
140         [EditorBrowsable(EditorBrowsableState.Never)]
141         public Window(string name, IBorderInterface borderInterface, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
142         {
143             if (IsSupportedMultiWindow() == false)
144             {
145                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
146             }
147             this.windowTitle = name;
148             this.EnableBorder(borderInterface);
149             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
150         }
151
152
153         /// <summary>
154         /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
155         /// </summary>
156         /// <since_tizen> 3 </since_tizen>
157         public enum WindowOrientation
158         {
159             /// <summary>
160             /// Portrait orientation. The height of the display area is greater than the width.
161             /// </summary>
162             /// <since_tizen> 3 </since_tizen>
163             Portrait = 0,
164             /// <summary>
165             /// Landscape orientation. A wide view area is needed.
166             /// </summary>
167             /// <since_tizen> 3 </since_tizen>
168             Landscape = 90,
169             /// <summary>
170             /// Portrait inverse orientation.
171             /// </summary>
172             /// <since_tizen> 3 </since_tizen>
173             PortraitInverse = 180,
174             /// <summary>
175             /// Landscape inverse orientation.
176             /// </summary>
177             /// <since_tizen> 3 </since_tizen>
178             LandscapeInverse = 270,
179             /// <summary>
180             /// No orientation. It is for the preferred orientation
181             /// Especially, NoOrientationPreference only has the effect for the preferred orientation.
182             /// It is used to unset the preferred orientation with SetPreferredOrientation.
183             /// </summary>
184             [EditorBrowsable(EditorBrowsableState.Never)]
185             NoOrientationPreference = -1
186         }
187
188         /// <summary>
189         /// Enumeration for the key grab mode for platform-level APIs.
190         /// </summary>
191         /// <since_tizen> 3 </since_tizen>
192         public enum KeyGrabMode
193         {
194             /// <summary>
195             /// Grabs a key only when on the top of the grabbing-window stack mode.
196             /// </summary>
197             Topmost = 0,
198             /// <summary>
199             /// Grabs a key together with the other client window(s) mode.
200             /// </summary>
201             Shared,
202             /// <summary>
203             /// 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.
204             /// </summary>
205             OverrideExclusive,
206             /// <summary>
207             /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
208             /// </summary>
209             Exclusive
210         };
211
212         /// <summary>
213         /// Enumeration for transition effect's state.
214         /// </summary>
215         [Obsolete("Please do not use! This will be removed. Please use Window.EffectState instead!")]
216         [EditorBrowsable(EditorBrowsableState.Never)]
217         //  This is already deprecated, so suppress warning here.
218         [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "<Pending>")]
219         public enum EffectStates
220         {
221             /// <summary>
222             /// None state.
223             /// </summary>
224             [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.None instead!")]
225             [EditorBrowsable(EditorBrowsableState.Never)]
226             None = 0,
227             /// <summary>
228             /// Transition effect is started.
229             /// </summary>
230             [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.Start instead!")]
231             [EditorBrowsable(EditorBrowsableState.Never)]
232             Start,
233             /// <summary>
234             /// Transition effect is ended.
235             /// </summary>
236             [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.End instead!")]
237             [EditorBrowsable(EditorBrowsableState.Never)]
238             End,
239         }
240
241         /// <summary>
242         /// Enumeration for transition effect's state.
243         /// </summary>
244         [EditorBrowsable(EditorBrowsableState.Never)]
245         public enum EffectState
246         {
247             /// <summary>
248             /// None state.
249             /// </summary>
250             [EditorBrowsable(EditorBrowsableState.Never)]
251             None = 0,
252             /// <summary>
253             /// Transition effect is started.
254             /// </summary>
255             [EditorBrowsable(EditorBrowsableState.Never)]
256             Start,
257             /// <summary>
258             /// Transition effect is ended.
259             /// </summary>
260             [EditorBrowsable(EditorBrowsableState.Never)]
261             End,
262         }
263
264         /// <summary>
265         /// Enumeration for transition effect's type.
266         /// </summary>
267         [Obsolete("Please do not use! This will be removed. Please use Window.EffectType instead!")]
268         [EditorBrowsable(EditorBrowsableState.Never)]
269         //  This is already deprecated, so suppress warning here.
270         [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "<Pending>")]
271         public enum EffectTypes
272         {
273             /// <summary>
274             /// None type.
275             /// </summary>
276             [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.None instead!")]
277             [EditorBrowsable(EditorBrowsableState.Never)]
278             None = 0,
279             /// <summary>
280             /// Window show effect.
281             /// </summary>
282             [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.Show instead!")]
283             [EditorBrowsable(EditorBrowsableState.Never)]
284             Show,
285             /// <summary>
286             /// Window hide effect.
287             /// </summary>
288             [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.Hide instead!")]
289             [EditorBrowsable(EditorBrowsableState.Never)]
290             Hide,
291         }
292
293         /// <summary>
294         /// Enumeration for transition effect's type.
295         /// </summary>
296         [EditorBrowsable(EditorBrowsableState.Never)]
297         public enum EffectType
298         {
299             /// <summary>
300             /// None type.
301             /// </summary>
302             [EditorBrowsable(EditorBrowsableState.Never)]
303             None = 0,
304             /// <summary>
305             /// Window show effect.
306             /// </summary>
307             [EditorBrowsable(EditorBrowsableState.Never)]
308             Show,
309             /// <summary>
310             /// Window hide effect.
311             /// </summary>
312             [EditorBrowsable(EditorBrowsableState.Never)]
313             Hide,
314         }
315
316         /// <summary>
317         /// Enumeration for result of window operation.
318         /// </summary>
319         internal enum OperationResult
320         {
321             /// <summary>
322             /// Failed for unknown reason
323             /// </summary>
324             UnknownError = 0,
325             /// <summary>
326             /// Succeed
327             /// </summary>
328             Succeed,
329             /// <summary>
330             /// Permission denied
331             /// </summary>
332             PermissionDenied,
333             /// <summary>
334             /// The operation is not supported.
335             /// </summary>
336             NotSupported,
337         }
338
339         /// <summary>
340         /// Enumeration for window resized mode by display server.
341         /// </summary>
342         [EditorBrowsable(EditorBrowsableState.Never)]
343         public enum ResizeDirection
344         {
345             /// <summary>
346             /// None type.
347             /// </summary>
348             [EditorBrowsable(EditorBrowsableState.Never)]
349             None = 0,
350             /// <summary>
351             /// Start resizing window to the top-left edge.
352             /// </summary>
353             [EditorBrowsable(EditorBrowsableState.Never)]
354             TopLeft = 1,
355             /// <summary>
356             /// Start resizing window to the top side.
357             /// </summary>
358             [EditorBrowsable(EditorBrowsableState.Never)]
359             Top = 2,
360             /// <summary>
361             /// Start resizing window to the top-right edge.
362             /// </summary>
363             [EditorBrowsable(EditorBrowsableState.Never)]
364             TopRight = 3,
365             /// <summary>
366             /// Start resizing window to the left side.
367             /// </summary>
368             [EditorBrowsable(EditorBrowsableState.Never)]
369             Left = 4,
370             /// <summary>
371             /// Start resizing window to the right side.
372             /// </summary>
373             [EditorBrowsable(EditorBrowsableState.Never)]
374             Right = 5,
375             /// <summary>
376             /// Start resizing window to the bottom-left edge.
377             /// </summary>
378             [EditorBrowsable(EditorBrowsableState.Never)]
379             BottomLeft = 6,
380             /// <summary>
381             /// Start resizing window to the bottom side.
382             /// </summary>
383             [EditorBrowsable(EditorBrowsableState.Never)]
384             Bottom = 7,
385             /// <summary>
386             /// Start resizing window to the bottom-right edge.
387             /// </summary>
388             [EditorBrowsable(EditorBrowsableState.Never)]
389             BottomRight = 8,
390         }
391
392
393         /// <summary>
394         /// The stage instance property (read-only).<br />
395         /// Gets the current window.<br />
396         /// </summary>
397         /// <since_tizen> 3 </since_tizen>
398         public static Window Instance { get; internal set; }
399
400         /// <summary>
401         /// Gets or sets a window type.
402         /// Most of window type can be set to use WindowType, except for IME type.
403         /// IME type can be set to use one of NUIApplication's constrcutors.
404         /// </summary>
405         /// <since_tizen> 3 </since_tizen>
406         public WindowType Type
407         {
408             get
409             {
410                 WindowType ret = (WindowType)Interop.Window.GetType(SwigCPtr);
411                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
412                 return ret;
413             }
414             set
415             {
416                 Interop.Window.SetType(SwigCPtr, (int)value);
417                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
418             }
419         }
420
421         /// <summary>
422         /// Gets/Sets a window title.
423         /// </summary>
424         /// <since_tizen> 4 </since_tizen>
425         public string Title
426         {
427             get
428             {
429                 return windowTitle;
430             }
431             set
432             {
433                 windowTitle = value;
434                 SetClass(windowTitle, "");
435             }
436         }
437
438         /// <summary>
439         /// The rendering behavior of a Window.
440         /// </summary>
441         /// <since_tizen> 5 </since_tizen>
442         public RenderingBehaviorType RenderingBehavior
443         {
444             get
445             {
446                 return GetRenderingBehavior();
447             }
448             set
449             {
450                 SetRenderingBehavior(value);
451             }
452         }
453
454         /// <summary>
455         /// The window size property (read-only).
456         /// </summary>
457         /// <since_tizen> 3 </since_tizen>
458         public Size2D Size
459         {
460             get
461             {
462                 Size2D ret = GetSize();
463                 return ret;
464             }
465         }
466
467         /// <summary>
468         /// The background color property.
469         /// </summary>
470         /// <since_tizen> 3 </since_tizen>
471         public Color BackgroundColor
472         {
473             set
474             {
475                 SetBackgroundColor(value);
476             }
477             get
478             {
479                 Color ret = GetBackgroundColor();
480                 return ret;
481             }
482         }
483
484         /// <summary>
485         /// The DPI property (read-only).<br />
486         /// Retrieves the DPI of the display device to which the Window is connected.<br />
487         /// </summary>
488         /// <since_tizen> 3 </since_tizen>
489         public Vector2 Dpi
490         {
491             get
492             {
493                 return GetDpi();
494             }
495         }
496
497         /// <summary>
498         /// The layer count property (read-only).<br />
499         /// Queries the number of on-Window layers.<br />
500         /// </summary>
501         /// <since_tizen> 3 </since_tizen>
502         public uint LayerCount
503         {
504             get
505             {
506                 return GetLayerCount();
507             }
508         }
509
510         /// <summary>
511         /// Gets or sets a size of the window.
512         /// </summary>
513         /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
514         /// <since_tizen> 4 </since_tizen>
515         public Size2D WindowSize
516         {
517             get
518             {
519                 return GetWindowSize();
520             }
521             set
522             {
523                 SetWindowSize(value);
524             }
525         }
526
527         /// <summary>
528         /// Gets or sets a position of the window.
529         /// </summary>
530         /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
531         /// <since_tizen> 4 </since_tizen>
532         public Position2D WindowPosition
533         {
534             get
535             {
536                 return GetPosition();
537             }
538             set
539             {
540                 SetPosition(value);
541             }
542         }
543
544         /// <summary>
545         /// Sets position and size of the window. This API guarantees that
546         /// both moving and resizing of window will appear on the screen at once.
547         /// </summary>
548         [EditorBrowsable(EditorBrowsableState.Never)]
549         public Rectangle WindowPositionSize
550         {
551             get
552             {
553                 Position2D position = GetPosition();
554                 Size2D size = GetSize();
555                 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
556                 position.Dispose();
557                 return ret;
558             }
559             set
560             {
561                 SetPositionSize(value);
562             }
563         }
564
565         internal static Vector4 DEFAULT_BACKGROUND_COLOR
566         {
567             get
568             {
569                 global::System.IntPtr cPtr = Interop.Stage.DefaultBackgroundColorGet();
570                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
571                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
572                 return ret;
573             }
574         }
575
576         internal static Vector4 DEBUG_BACKGROUND_COLOR
577         {
578             get
579             {
580                 global::System.IntPtr cPtr = Interop.Stage.DebugBackgroundColorGet();
581                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
582                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
583                 return ret;
584             }
585         }
586
587         internal List<Layer> LayersChildren
588         {
589             get
590             {
591                 return childLayers;
592             }
593         }
594
595         /// <summary>
596         ///  Get the LayoutController for this Window.
597         /// </summary>
598         internal LayoutController LayoutController
599         {
600             get
601             {
602                 return localController;
603             }
604         }
605
606         /// <summary>
607         /// Feed a key-event into the window.
608         /// </summary>
609         /// <param name="keyEvent">The key event to feed.</param>
610         /// <since_tizen> 4 </since_tizen>
611         [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
612         public static void FeedKeyEvent(Key keyEvent)
613         {
614             Interop.Window.FeedKeyEvent(Key.getCPtr(keyEvent));
615             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
616         }
617
618         /// <summary>
619         /// Sets whether the window accepts a focus or not.
620         /// </summary>
621         /// <param name="accept">If a focus is accepted or not. The default is true.</param>
622         /// <since_tizen> 3 </since_tizen>
623         public void SetAcceptFocus(bool accept)
624         {
625             Interop.Window.SetAcceptFocus(SwigCPtr, accept);
626             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
627         }
628
629         /// <summary>
630         /// Returns whether the window accepts a focus or not.
631         /// </summary>
632         /// <returns>True if the window accepts a focus, false otherwise.</returns>
633         /// <since_tizen> 3 </since_tizen>
634         public bool IsFocusAcceptable()
635         {
636             bool ret = Interop.Window.IsFocusAcceptable(SwigCPtr);
637             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
638
639             return ret;
640         }
641
642         /// <summary>
643         /// Shows the window if it is hidden.
644         /// </summary>
645         /// <since_tizen> 3 </since_tizen>
646         public void Show()
647         {
648             Interop.Window.Show(SwigCPtr);
649             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
650         }
651
652         /// <summary>
653         /// Hides the window if it is showing.
654         /// </summary>
655         /// <since_tizen> 3 </since_tizen>
656         public void Hide()
657         {
658             Interop.Window.Hide(SwigCPtr);
659             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
660         }
661
662         /// <summary>
663         /// Retrieves whether the window is visible or not.
664         /// </summary>
665         /// <returns>True if the window is visible.</returns>
666         /// <since_tizen> 3 </since_tizen>
667         public bool IsVisible()
668         {
669             bool temp = Interop.Window.IsVisible(SwigCPtr);
670             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
671             return temp;
672         }
673
674         /// <summary>
675         /// Gets the count of supported auxiliary hints of the window.
676         /// </summary>
677         /// <returns>The number of supported auxiliary hints.</returns>
678         /// <since_tizen> 3 </since_tizen>
679         public uint GetSupportedAuxiliaryHintCount()
680         {
681             uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(SwigCPtr);
682             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
683             return ret;
684         }
685
686         /// <summary>
687         /// Gets the supported auxiliary hint string of the window.
688         /// </summary>
689         /// <param name="index">The index of the supported auxiliary hint lists.</param>
690         /// <returns>The auxiliary hint string of the index.</returns>
691         /// <since_tizen> 3 </since_tizen>
692         public string GetSupportedAuxiliaryHint(uint index)
693         {
694             string ret = Interop.Window.GetSupportedAuxiliaryHint(SwigCPtr, index);
695             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
696             return ret;
697         }
698
699         /// <summary>
700         /// Creates an auxiliary hint of the window.
701         /// </summary>
702         /// <param name="hint">The auxiliary hint string.</param>
703         /// <param name="value">The value string.</param>
704         /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
705         /// <since_tizen> 3 </since_tizen>
706         public uint AddAuxiliaryHint(string hint, string value)
707         {
708             uint ret = Interop.Window.AddAuxiliaryHint(SwigCPtr, hint, value);
709             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
710             return ret;
711         }
712
713         /// <summary>
714         /// Removes an auxiliary hint of the window.
715         /// </summary>
716         /// <param name="id">The ID of the auxiliary hint.</param>
717         /// <returns>True if no error occurred, false otherwise.</returns>
718         /// <since_tizen> 3 </since_tizen>
719         public bool RemoveAuxiliaryHint(uint id)
720         {
721             bool ret = Interop.Window.RemoveAuxiliaryHint(SwigCPtr, id);
722             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
723             return ret;
724         }
725
726         /// <summary>
727         /// Changes a value of the auxiliary hint.
728         /// </summary>
729         /// <param name="id">The auxiliary hint ID.</param>
730         /// <param name="value">The value string to be set.</param>
731         /// <returns>True if no error occurred, false otherwise.</returns>
732         /// <since_tizen> 3 </since_tizen>
733         public bool SetAuxiliaryHintValue(uint id, string value)
734         {
735             bool ret = Interop.Window.SetAuxiliaryHintValue(SwigCPtr, id, value);
736             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
737             return ret;
738         }
739
740         /// <summary>
741         /// Gets a value of the auxiliary hint.
742         /// </summary>
743         /// <param name="id">The auxiliary hint ID.</param>
744         /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
745         /// <since_tizen> 3 </since_tizen>
746         public string GetAuxiliaryHintValue(uint id)
747         {
748             string ret = Interop.Window.GetAuxiliaryHintValue(SwigCPtr, id);
749             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
750             return ret;
751         }
752
753         /// <summary>
754         /// Gets an ID of the auxiliary hint string.
755         /// </summary>
756         /// <param name="hint">The auxiliary hint string.</param>
757         /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
758         /// <since_tizen> 3 </since_tizen>
759         public uint GetAuxiliaryHintId(string hint)
760         {
761             uint ret = Interop.Window.GetAuxiliaryHintId(SwigCPtr, hint);
762             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
763             return ret;
764         }
765
766         /// <summary>
767         /// Sets a region to accept input events.
768         /// </summary>
769         /// <param name="inputRegion">The region to accept input events.</param>
770         /// <since_tizen> 3 </since_tizen>
771         public void SetInputRegion(Rectangle inputRegion)
772         {
773             Interop.Window.IncludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
774             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
775         }
776
777         /// <summary>
778         /// Sets a priority level for the specified notification window.
779         /// </summary>
780         /// <param name="level">The notification window level.</param>
781         /// <returns>True if no error occurred, false otherwise.</returns>
782         /// <since_tizen> 3 </since_tizen>
783         public bool SetNotificationLevel(NotificationLevel level)
784         {
785             var ret = (OperationResult)Interop.Window.SetNotificationLevel(SwigCPtr, (int)level);
786             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
787             return ret == OperationResult.Succeed;
788         }
789
790         /// <summary>
791         /// Gets a priority level for the specified notification window.
792         /// </summary>
793         /// <returns>The notification window level.</returns>
794         /// <since_tizen> 3 </since_tizen>
795         public NotificationLevel GetNotificationLevel()
796         {
797             NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(SwigCPtr);
798             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
799             return ret;
800         }
801
802         /// <summary>
803         /// Sets a transparent window's visual state to opaque. <br />
804         /// If a visual state of a transparent window is opaque, <br />
805         /// then the window manager could handle it as an opaque window when calculating visibility.
806         /// </summary>
807         /// <param name="opaque">Whether the window's visual state is opaque.</param>
808         /// <remarks>This will have no effect on an opaque window. <br />
809         /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
810         /// </remarks>
811         /// <since_tizen> 3 </since_tizen>
812         public void SetOpaqueState(bool opaque)
813         {
814             Interop.Window.SetOpaqueState(SwigCPtr, opaque);
815             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
816         }
817
818         /// <summary>
819         /// Returns whether a transparent window's visual state is opaque or not.
820         /// </summary>
821         /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
822         /// <remarks> The return value has no meaning on an opaque window. </remarks>
823         /// <since_tizen> 3 </since_tizen>
824         public bool IsOpaqueState()
825         {
826             bool ret = Interop.Window.IsOpaqueState(SwigCPtr);
827             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
828             return ret;
829         }
830
831         /// <summary>
832         /// Sets a window's screen off mode.
833         /// </summary>
834         /// <param name="screenOffMode">The screen mode.</param>
835         /// <returns>True if no error occurred, false otherwise.</returns>
836         /// <since_tizen> 4 </since_tizen>
837         public bool SetScreenOffMode(ScreenOffMode screenOffMode)
838         {
839             var ret = (OperationResult)Interop.Window.SetScreenOffMode(SwigCPtr, (int)screenOffMode);
840             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
841             return ret == OperationResult.Succeed;
842         }
843
844         /// <summary>
845         /// Gets the screen mode of the window.
846         /// </summary>
847         /// <returns>The screen off mode.</returns>
848         /// <since_tizen> 4 </since_tizen>
849         public ScreenOffMode GetScreenOffMode()
850         {
851             ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(SwigCPtr);
852             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
853             return ret;
854         }
855
856         /// <summary>
857         /// Sets preferred brightness of the window.
858         /// </summary>
859         /// <param name="brightness">The preferred brightness (0 to 100).</param>
860         /// <returns>True if no error occurred, false otherwise.</returns>
861         /// <since_tizen> 3 </since_tizen>
862         public bool SetBrightness(int brightness)
863         {
864             var ret = (OperationResult)Interop.Window.SetBrightness(SwigCPtr, brightness);
865             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
866             return ret == OperationResult.Succeed;
867         }
868
869         /// <summary>
870         /// Gets the preferred brightness of the window.
871         /// </summary>
872         /// <returns>The preferred brightness.</returns>
873         /// <since_tizen> 3 </since_tizen>
874         public int GetBrightness()
875         {
876             int ret = Interop.Window.GetBrightness(SwigCPtr);
877             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
878             return ret;
879         }
880
881         /// <summary>
882         /// Sets the window name and the class string.
883         /// </summary>
884         /// <param name="name">The name of the window.</param>
885         /// <param name="klass">The class of the window.</param>
886         /// <since_tizen> 4 </since_tizen>
887         public void SetClass(string name, string klass)
888         {
889             Interop.Window.SetClass(SwigCPtr, name, klass);
890             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
891         }
892
893         /// <summary>
894         /// Raises the window to the top of the window stack.
895         /// </summary>
896         /// <since_tizen> 3 </since_tizen>
897         public void Raise()
898         {
899             Interop.Window.Raise(SwigCPtr);
900             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
901         }
902
903         /// <summary>
904         /// Lowers the window to the bottom of the window stack.
905         /// </summary>
906         /// <since_tizen> 3 </since_tizen>
907         public void Lower()
908         {
909             Interop.Window.Lower(SwigCPtr);
910             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
911         }
912
913         /// <summary>
914         /// Activates the window to the top of the window stack even it is iconified.
915         /// </summary>
916         /// <since_tizen> 3 </since_tizen>
917         public void Activate()
918         {
919             Interop.Window.Activate(SwigCPtr);
920             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
921         }
922
923         /// <summary>
924         /// Gets the default ( root ) layer.
925         /// </summary>
926         /// <returns>The root layer.</returns>
927         /// <since_tizen> 3 </since_tizen>
928         public Layer GetDefaultLayer()
929         {
930             return this.GetRootLayer();
931         }
932
933         /// <summary>
934         /// Add a child view to window.
935         /// </summary>
936         /// <param name="view">the child should be added to the window.</param>
937         /// <since_tizen> 3 </since_tizen>
938         public void Add(View view)
939         {
940             this.GetRootLayer().Add(view);
941         }
942
943         /// <summary>
944         /// Remove a child view from window.
945         /// </summary>
946         /// <param name="view">the child to be removed.</param>
947         /// <since_tizen> 3 </since_tizen>
948         public void Remove(View view)
949         {
950             this.GetRootLayer().Remove(view);
951         }
952
953         /// <summary>
954         /// Retrieves the layer at a specified depth.
955         /// </summary>
956         /// <param name="depth">The layer's depth index.</param>
957         /// <returns>The layer found at the given depth.</returns>
958         /// <since_tizen> 3 </since_tizen>
959         public Layer GetLayer(uint depth)
960         {
961             if (depth < LayersChildren?.Count)
962             {
963                 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
964                 return ret;
965             }
966             else
967             {
968                 return null;
969             }
970         }
971
972         /// <summary>
973         /// Destroy the window immediately.
974         /// </summary>
975         [EditorBrowsable(EditorBrowsableState.Never)]
976         public void Destroy()
977         {
978             this.Dispose();
979         }
980
981         /// <summary>
982         /// Keep rendering for at least the given amount of time.
983         /// </summary>
984         /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
985         /// <since_tizen> 3 </since_tizen>
986         public void KeepRendering(float durationSeconds)
987         {
988             Interop.Stage.KeepRendering(stageCPtr, durationSeconds);
989             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
990         }
991
992         /// <summary>
993         /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
994         /// This function can be used for following example scenarios: <br />
995         /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
996         /// </summary>
997         /// <param name="DaliKey">The key code to grab.</param>
998         /// <returns>True if the grab succeeds.</returns>
999         /// <since_tizen> 3 </since_tizen>
1000         public bool GrabKeyTopmost(int DaliKey)
1001         {
1002             bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1003             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1004             return ret;
1005         }
1006
1007         /// <summary>
1008         /// Ungrabs the key specified by a key for the window.<br />
1009         /// 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 />
1010         /// </summary>
1011         /// <param name="DaliKey">The key code to ungrab.</param>
1012         /// <returns>True if the ungrab succeeds.</returns>
1013         /// <since_tizen> 3 </since_tizen>
1014         public bool UngrabKeyTopmost(int DaliKey)
1015         {
1016             bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1017             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1018             return ret;
1019         }
1020
1021         /// <summary>
1022         ///  Grabs the key specified by a key for a window in a GrabMode. <br />
1023         ///  Details: This function can be used for following example scenarios: <br />
1024         ///  - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
1025         ///  - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
1026         ///  - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
1027         /// </summary>
1028         /// <param name="DaliKey">The key code to grab.</param>
1029         /// <param name="GrabMode">The grab mode for the key.</param>
1030         /// <returns>True if the grab succeeds.</returns>
1031         /// <since_tizen> 3 </since_tizen>
1032         public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
1033         {
1034             bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey, (int)GrabMode);
1035             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1036             return ret;
1037         }
1038
1039         /// <summary>
1040         /// Ungrabs the key specified by a key for a window.<br />
1041         /// 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 />
1042         /// </summary>
1043         /// <param name="DaliKey">The key code to ungrab.</param>
1044         /// <returns>True if the ungrab succeeds.</returns>
1045         /// <since_tizen> 3 </since_tizen>
1046         public bool UngrabKey(int DaliKey)
1047         {
1048             bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1049             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1050             return ret;
1051         }
1052
1053         /// <summary>
1054         /// Sets the keyboard repeat information.
1055         /// </summary>
1056         /// <param name="rate">The key repeat rate value in seconds.</param>
1057         /// <param name="delay">The key repeat delay value in seconds.</param>
1058         /// <returns>True if setting the keyboard repeat succeeds.</returns>
1059         /// <since_tizen> 5 </since_tizen>
1060         public bool SetKeyboardRepeatInfo(float rate, float delay)
1061         {
1062             bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
1063             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1064             return ret;
1065         }
1066
1067         /// <summary>
1068         /// Gets the keyboard repeat information.
1069         /// </summary>
1070         /// <param name="rate">The key repeat rate value in seconds.</param>
1071         /// <param name="delay">The key repeat delay value in seconds.</param>
1072         /// <returns>True if setting the keyboard repeat succeeds.</returns>
1073         /// <since_tizen> 5 </since_tizen>
1074         public bool GetKeyboardRepeatInfo(out float rate, out float delay)
1075         {
1076             bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
1077             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1078             return ret;
1079         }
1080
1081         /// <summary>
1082         /// Adds a layer to the stage.
1083         /// </summary>
1084         /// <param name="layer">Layer to add.</param>
1085         /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1086         /// <since_tizen> 3 </since_tizen>
1087         public void AddLayer(Layer layer)
1088         {
1089             Add(layer);
1090         }
1091
1092         /// <summary>
1093         /// Removes a layer from the stage.
1094         /// </summary>
1095         /// <param name="layer">Layer to remove.</param>
1096         /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1097         /// <since_tizen> 3 </since_tizen>
1098         public void RemoveLayer(Layer layer)
1099         {
1100             Remove(layer);
1101         }
1102
1103         /// <summary>
1104         /// Feeds a key event into the window.
1105         /// </summary>
1106         /// <param name="keyEvent">The key event to feed.</param>
1107         /// <since_tizen> 5 </since_tizen>
1108         public void FeedKey(Key keyEvent)
1109         {
1110             Interop.Window.FeedKeyEvent(SwigCPtr, Key.getCPtr(keyEvent));
1111             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1112         }
1113
1114         /// <summary>
1115         /// Feeds a touch point into the window.
1116         /// </summary>
1117         /// <param name="touchPoint">The touch point to feed.</param>
1118         /// <param name="timeStamp">The timeStamp.</param>
1119         internal void FeedTouch(TouchPoint touchPoint, int timeStamp)
1120         {
1121             Interop.Window.FeedTouchPoint(SwigCPtr, TouchPoint.getCPtr(touchPoint), timeStamp);
1122             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1123         }
1124
1125         /// <summary>
1126         /// Feeds a wheel event into the window.
1127         /// </summary>
1128         /// <param name="wheelEvent">The wheel event to feed.</param>
1129         internal void FeedWheel(Wheel wheelEvent)
1130         {
1131             Interop.Window.FeedWheelEvent(SwigCPtr, Wheel.getCPtr(wheelEvent));
1132             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1133         }
1134
1135         /// <summary>
1136         /// Allows at least one more render, even when paused.
1137         /// The window should be shown, not minimised.
1138         /// </summary>
1139         /// <since_tizen> 4 </since_tizen>
1140         public void RenderOnce()
1141         {
1142             Interop.Window.RenderOnce(SwigCPtr);
1143             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1144         }
1145
1146         /// <summary>
1147         /// Sets whether the window is transparent or not.
1148         /// </summary>
1149         /// <param name="transparent">Whether the window is transparent or not.</param>
1150         /// <since_tizen> 5 </since_tizen>
1151         public void SetTransparency(bool transparent)
1152         {
1153             Interop.Window.SetTransparency(SwigCPtr, transparent);
1154             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1155
1156             // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
1157         }
1158
1159         /// <summary>
1160         /// Sets parent window of the window.
1161         /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1162         /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
1163         /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
1164         /// </summary>
1165         /// <param name="parent">The parent window.</param>
1166         /// <since_tizen> 6 </since_tizen>
1167         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1168         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1169         public void SetParent(Window parent)
1170         {
1171             if (IsSupportedMultiWindow() == false)
1172             {
1173                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1174             }
1175             Interop.Window.SetParent(SwigCPtr, Window.getCPtr(parent));
1176             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1177         }
1178
1179         /// <summary>
1180         /// Sets parent window of the window.
1181         /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1182         /// This function has the additional flag whether the child is located above or below of the parent.
1183         /// </summary>
1184         /// <param name="parent">The parent window.</param>
1185         /// <param name="belowParent">The flag is whether the child is located above or below of the parent.</param>
1186         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1187         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1188         [EditorBrowsable(EditorBrowsableState.Never)]
1189         public void SetParent(Window parent, bool belowParent)
1190         {
1191             if (IsSupportedMultiWindow() == false)
1192             {
1193                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1194             }
1195             Interop.Window.SetParentWithStack(SwigCPtr, Window.getCPtr(parent), belowParent);
1196             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1197         }
1198
1199         /// <summary>
1200         /// Unsets parent window of the window.
1201         /// After unsetting, the window is disconnected his parent window.
1202         /// </summary>
1203         /// <since_tizen> 6 </since_tizen>
1204         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1205         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1206         public void Unparent()
1207         {
1208             if (IsSupportedMultiWindow() == false)
1209             {
1210                 NUILog.Error("Fail to create window. because this device does not support opengles.surfaceless_context.");
1211             }
1212             Interop.Window.Unparent(SwigCPtr);
1213             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1214         }
1215
1216         /// <summary>
1217         /// Gets parent window of the window.
1218         /// </summary>
1219         /// <returns>The parent window of the window.</returns>
1220         /// <since_tizen> 6 </since_tizen>
1221         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1222         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1223         [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1721: Property names should not match get methods")]
1224         public Window GetParent()
1225         {
1226             if (IsSupportedMultiWindow() == false)
1227             {
1228                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1229             }
1230             Window ret = this.GetInstanceSafely<Window>(Interop.Window.GetParent(SwigCPtr));
1231             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1232             return ret;
1233         }
1234
1235         /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
1236         [EditorBrowsable(EditorBrowsableState.Never)]
1237         public void ObjectDump()
1238         {
1239             Layer rootLayer = GetRootLayer();
1240             foreach (View view in rootLayer.Children)
1241             {
1242                 view.ObjectDump();
1243             }
1244         }
1245
1246         internal static bool IsInstalled()
1247         {
1248             bool ret = Interop.Stage.IsInstalled();
1249             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1250             return ret;
1251         }
1252
1253         /// <summary>
1254         /// Adds an orientation to the list of available orientations.
1255         /// </summary>
1256         /// <param name="orientation">The available orientation to add</param>
1257         /// <since_tizen> 6 </since_tizen>
1258         public void AddAvailableOrientation(Window.WindowOrientation orientation)
1259         {
1260             Interop.Window.AddAvailableOrientation(SwigCPtr, (int)orientation);
1261             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1262         }
1263
1264         /// <summary>
1265         /// Removes an orientation from the list of available orientations.
1266         /// </summary>
1267         /// <param name="orientation">The available orientation to remove.</param>
1268         /// <since_tizen> 6 </since_tizen>
1269         public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1270         {
1271             Interop.Window.RemoveAvailableOrientation(SwigCPtr, (int)orientation);
1272             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1273         }
1274
1275         /// <summary>
1276         /// Sets a preferred orientation.
1277         /// </summary>
1278         /// <param name="orientation">The preferred orientation.</param>
1279         /// <since_tizen> 6 </since_tizen>
1280         public void SetPreferredOrientation(Window.WindowOrientation orientation)
1281         {
1282             Interop.Window.SetPreferredOrientation(SwigCPtr, (int)orientation);
1283             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1284         }
1285
1286         /// <summary>
1287         /// Gets the preferred orientation.
1288         /// </summary>
1289         /// <since_tizen> 6 </since_tizen>
1290         /// <returns>The preferred orientation if previously set, or none.</returns>
1291         public Window.WindowOrientation GetPreferredOrientation()
1292         {
1293             Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetPreferredOrientation(SwigCPtr);
1294             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1295             return ret;
1296         }
1297
1298         /// <summary>
1299         /// Gets current orientation of the window.
1300         /// </summary>
1301         /// <since_tizen> 6 </since_tizen>
1302         /// <returns>The current window orientation if previously set, or none.</returns>
1303         [EditorBrowsable(EditorBrowsableState.Never)]
1304         public Window.WindowOrientation GetCurrentOrientation()
1305         {
1306             Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetCurrentOrientation(SwigCPtr);
1307             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1308             return ret;
1309         }
1310
1311         /// <summary>
1312         /// Sets available orientations of the window.
1313         /// This API is for setting several orientations one time.
1314         /// </summary>
1315         /// <param name="orientations">The list of orientations.</param>
1316         /// <since_tizen> 6 </since_tizen>
1317         [EditorBrowsable(EditorBrowsableState.Never)]
1318         public void SetAvailableOrientations(List<Window.WindowOrientation> orientations)
1319         {
1320             if (null == orientations)
1321             {
1322                 throw new ArgumentNullException(nameof(orientations));
1323             }
1324
1325             PropertyArray orientationArray = new PropertyArray();
1326             for (int i = 0; i < orientations.Count; i++)
1327             {
1328                 PropertyValue value = new PropertyValue((int)orientations[i]);
1329                 orientationArray.PushBack(value);
1330                 value.Dispose();
1331             }
1332
1333             Interop.Window.SetAvailableOrientations(SwigCPtr, PropertyArray.getCPtr(orientationArray), orientations.Count);
1334             orientationArray.Dispose();
1335             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1336         }
1337
1338         /// <summary>
1339         /// Get native window ID
1340         /// </summary>
1341         /// <returns>native window ID</returns>
1342         [EditorBrowsable(EditorBrowsableState.Never)]
1343         public int GetNativeId()
1344         {
1345             int ret = Interop.Window.GetNativeId(SwigCPtr);
1346             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1347             return ret;
1348         }
1349
1350         internal Any GetNativeHandle()
1351         {
1352             Any ret = new Any(Interop.WindowInternal.WindowGetNativeHandle(SwigCPtr), true);
1353             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1354             return ret;
1355         }
1356
1357         internal void Add(Layer layer)
1358         {
1359             if (null == layer)
1360             {
1361                 throw new ArgumentNullException(nameof(layer));
1362             }
1363
1364             if (isBorderWindow)
1365             {
1366                 Interop.Actor.Add(GetBorderWindowRootLayer().SwigCPtr, layer.SwigCPtr);
1367                 if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); }
1368             }
1369             else
1370             {
1371                 Interop.Window.Add(SwigCPtr, Layer.getCPtr(layer));
1372                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1373             }
1374
1375             LayersChildren?.Add(layer);
1376             layer.SetWindow(this);
1377         }
1378
1379         internal void Remove(Layer layer)
1380         {
1381             if (null == layer)
1382             {
1383                 throw new ArgumentNullException(nameof(layer));
1384             }
1385             Interop.Window.Remove(SwigCPtr, Layer.getCPtr(layer));
1386             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1387
1388             LayersChildren?.Remove(layer);
1389             layer.SetWindow(null);
1390         }
1391
1392         internal Vector2 GetSize()
1393         {
1394             var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1395
1396             convertRealWindowSizeToBorderWindowSize(val);
1397
1398             Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1399             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1400             val.Dispose();
1401             return ret;
1402         }
1403
1404         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
1405         [EditorBrowsable(EditorBrowsableState.Never)]
1406         public RenderTaskList GetRenderTaskList()
1407         {
1408             RenderTaskList ret = new RenderTaskList(Interop.Stage.GetRenderTaskList(stageCPtr), true);
1409             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1410             return ret;
1411         }
1412
1413         /// <summary>
1414         /// Queries the number of on-window layers.
1415         /// </summary>
1416         /// <returns>The number of layers.</returns>
1417         /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1418         internal uint GetLayerCount()
1419         {
1420             if (LayersChildren == null || LayersChildren.Count < 0)
1421                 return 0;
1422
1423             return (uint)LayersChildren.Count;
1424         }
1425
1426         internal Layer GetRootLayer()
1427         {
1428             if (isBorderWindow)
1429             {
1430                 if(borderLayer == null)
1431                 {
1432                     borderLayer = GetBorderWindowRootLayer();
1433                     LayersChildren?.Add(borderLayer);
1434                     borderLayer.SetWindow(this);
1435                 }
1436                 return borderLayer;
1437             }
1438             else
1439             {
1440                 // Window.IsInstalled() is actually true only when called from event thread and
1441                 // Core has been initialized, not when Stage is ready.
1442                 if (rootLayer == null && Window.IsInstalled())
1443                 {
1444                     rootLayer = new Layer(Interop.Window.GetRootLayer(SwigCPtr), true);
1445                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1446                     LayersChildren?.Add(rootLayer);
1447                     rootLayer.SetWindow(this);
1448                 }
1449                 return rootLayer;
1450             }
1451         }
1452
1453         internal void SetBackgroundColor(Vector4 color)
1454         {
1455             Interop.Window.SetBackgroundColor(SwigCPtr, Vector4.getCPtr(color));
1456             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1457         }
1458
1459         internal Vector4 GetBackgroundColor()
1460         {
1461             Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(SwigCPtr), true);
1462             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1463             return ret;
1464         }
1465
1466         internal Vector2 GetDpi()
1467         {
1468             Vector2 ret = new Vector2(Interop.Stage.GetDpi(stageCPtr), true);
1469             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1470             return ret;
1471         }
1472
1473         internal ObjectRegistry GetObjectRegistry()
1474         {
1475             ObjectRegistry ret = new ObjectRegistry(Interop.Stage.GetObjectRegistry(stageCPtr), true);
1476             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1477             return ret;
1478         }
1479
1480         internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1481         {
1482             Interop.Stage.SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1483             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1484         }
1485
1486         internal RenderingBehaviorType GetRenderingBehavior()
1487         {
1488             RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.GetRenderingBehavior(stageCPtr);
1489             if (NDalicPINVOKE.SWIGPendingException.Pending)
1490                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1491             return ret;
1492         }
1493
1494         internal void SetWindowSize(Size2D size)
1495         {
1496             if (null == size)
1497             {
1498                 throw new ArgumentNullException(nameof(size));
1499             }
1500             var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1501
1502             convertBorderWindowSizeToRealWindowSize(val);
1503
1504             Interop.Window.SetSize(SwigCPtr, Uint16Pair.getCPtr(val));
1505             val.Dispose();
1506             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1507             // Resetting Window size should request a relayout of the tree.
1508         }
1509
1510         internal Size2D GetWindowSize()
1511         {
1512             var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1513
1514             convertRealWindowSizeToBorderWindowSize(val);
1515
1516             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1517             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1518             val.Dispose();
1519             return ret;
1520         }
1521
1522         internal void SetPosition(Position2D position)
1523         {
1524             if (null == position)
1525             {
1526                 throw new ArgumentNullException(nameof(position));
1527             }
1528             var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1529             Interop.Window.SetPosition(SwigCPtr, Uint16Pair.getCPtr(val));
1530             val.Dispose();
1531             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1532             // Setting Position of the window should request a relayout of the tree.
1533         }
1534
1535         internal Position2D GetPosition()
1536         {
1537             var val = new Uint16Pair(Interop.Window.GetPosition(SwigCPtr), true);
1538             Position2D ret = new Position2D(val.GetX(), val.GetY());
1539             val.Dispose();
1540             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1541             return ret;
1542         }
1543
1544         internal void SetPositionSize(Rectangle positionSize)
1545         {
1546             if (positionSize == null)
1547             {
1548                 throw new ArgumentNullException(nameof(positionSize));
1549             }
1550             var val = new Uint16Pair((uint)positionSize.Width, (uint)positionSize.Height);
1551
1552             convertBorderWindowSizeToRealWindowSize(val);
1553
1554             positionSize.Width = val.GetX();
1555             positionSize.Height = val.GetY();
1556
1557             Interop.Window.SetPositionSize(SwigCPtr, Rectangle.getCPtr(positionSize));
1558             val.Dispose();
1559
1560             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1561
1562             // Setting Position of the window should request a relayout of the tree.
1563         }
1564
1565         /// <summary>
1566         /// Enables the floating mode of window.
1567         /// The floating mode is to support window is moved or resized by display server.
1568         /// For example, if the video-player window sets the floating mode,
1569         /// then display server changes its geometry and handles it like a popup.
1570         /// The way of handling floating mode window is decided by display server.
1571         /// A special display server(as a Tizen display server) supports this mode.
1572         /// </summary>
1573         /// <param name="enable">Enable floating mode or not.</param>
1574         [EditorBrowsable(EditorBrowsableState.Never)]
1575         public void EnableFloatingMode(bool enable)
1576         {
1577             Interop.Window.EnableFloatingMode(SwigCPtr, enable);
1578             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1579         }
1580
1581         /// <summary>
1582         /// Requests to display server for the window is moved by display server.
1583         /// It can be work with setting window floating mode.
1584         /// </summary>
1585         [EditorBrowsable(EditorBrowsableState.Never)]
1586         public void RequestMoveToServer()
1587         {
1588             Interop.Window.RequestMoveToServer(SwigCPtr);
1589             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1590         }
1591
1592         /// <summary>
1593         ///  Requests to display server for the window is resized by display server.
1594         /// It can be work with setting window floating mode.
1595         /// </summary>
1596         /// <param name="direction">It is indicated the window's side or edge for starting point.</param>
1597         [EditorBrowsable(EditorBrowsableState.Never)]
1598         public void RequestResizeToServer(ResizeDirection direction)
1599         {
1600             Interop.Window.RequestResizeToServer(SwigCPtr, (int)direction);
1601             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1602         }
1603
1604         /// <summary>
1605         /// Includes input region.
1606         /// This function inlcudes input regions.
1607         /// It can be used multiple times and supports multiple regions.
1608         /// It means input region will be extended.
1609         /// This input is related to mouse and touch event.
1610         /// If device has touch screen, this function is useful.
1611         /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1612         /// </summary>
1613         /// <param name="inputRegion">The included region to accept input events.</param>
1614         [EditorBrowsable(EditorBrowsableState.Never)]
1615         public void IncludeInputRegion(Rectangle inputRegion)
1616         {
1617             Interop.Window.IncludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1618             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1619         }
1620
1621         /// <summary>
1622         /// This function excludes input regions.
1623         /// It can be used multiple times and supports multiple regions.
1624         /// It means input region will be reduced.
1625         /// Nofice, should be set input area by IncludeInputRegion() before this function is used.
1626         /// This input is related to mouse and touch event.
1627         /// If device has touch screen, this function is useful.
1628         /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1629         /// </summary>
1630         /// <param name="inputRegion">The excluded region to except input events.</param>
1631         [EditorBrowsable(EditorBrowsableState.Never)]
1632         public void ExcludeInputRegion(Rectangle inputRegion)
1633         {
1634             Interop.Window.ExcludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1635             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1636         }
1637
1638         /// <summary>
1639         /// Maximizes window's size.
1640         /// If this function is called with true, window will be resized with screen size.
1641         /// Otherwise window will be resized with previous size.
1642         /// It is for the window's MAX button in window's border.
1643         /// If window border is supported by display server, it is not necessary.
1644         /// </summary>
1645         /// <param name="max">If window is maximized or unmaximized.</param>
1646         [EditorBrowsable(EditorBrowsableState.Never)]
1647         public void Maximize(bool max)
1648         {
1649             Interop.Window.Maximize(SwigCPtr, max);
1650             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1651         }
1652
1653         /// <summary>
1654         /// Returns whether the window is maximized or not.
1655         /// </summary>
1656         /// <returns>True if the window is maximized, false otherwise.</returns>
1657         [EditorBrowsable(EditorBrowsableState.Never)]
1658         public bool IsMaximized()
1659         {
1660             bool ret = Interop.Window.IsMaximized(SwigCPtr);
1661             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1662             return ret;
1663         }
1664
1665         /// <summary>
1666         /// Minimizes window's size.
1667         /// If this function is called with true, window will be iconified.
1668         /// Otherwise window will be activated.
1669         /// It is for the window's MIN button in window border.
1670         /// If window border is supported by display server, it is not necessary.
1671         /// </summary>
1672         /// <param name="min">If window is minimized or unminimized.</param>
1673         [EditorBrowsable(EditorBrowsableState.Never)]
1674         public void Minimize(bool min)
1675         {
1676             Interop.Window.Minimize(SwigCPtr, min);
1677             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1678         }
1679
1680         /// <summary>
1681         /// Returns whether the window is minimized or not.
1682         /// </summary>
1683         /// <returns>True if the window is minimized, false otherwise.</returns>
1684         [EditorBrowsable(EditorBrowsableState.Never)]
1685         public bool IsMinimized()
1686         {
1687             bool ret = Interop.Window.IsMinimized(SwigCPtr);
1688             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1689             return ret;
1690         }
1691
1692         /// <summary>
1693         /// Query whether window is rotating or not.
1694         /// </summary>
1695         /// <returns>True if window is rotating, false otherwise.</returns>
1696         [EditorBrowsable(EditorBrowsableState.Never)]
1697         public bool IsWindowRotating()
1698         {
1699             bool ret = Interop.Window.IsWindowRotating(SwigCPtr);
1700             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1701             return ret;
1702         }
1703
1704         /// <summary>
1705         /// Gets the last key event the window gets.
1706         /// </summary>
1707         /// <returns>The last key event the window gets.</returns>
1708         [EditorBrowsable(EditorBrowsableState.Never)]
1709         public Key GetLastKeyEvent()
1710         {
1711             Key ret = new Key(Interop.Window.GetLastKeyEvent(SwigCPtr), false);
1712             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1713             return ret;
1714         }
1715
1716         /// <summary>
1717         /// Gets the last touch event the window gets.
1718         /// </summary>
1719         /// <returns>The last touch event the window gets.</returns>
1720         [EditorBrowsable(EditorBrowsableState.Never)]
1721         public Touch GetLastTouchEvent()
1722         {
1723             Touch ret = new Touch(Interop.Window.GetLastTouchEvent(SwigCPtr), false);
1724             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1725             return ret;
1726         }
1727
1728         /// <summary>
1729         /// Add FrameUpdateCallback
1730         /// </summary>
1731         [EditorBrowsable(EditorBrowsableState.Never)]
1732         public void AddFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1733         {
1734             frameUpdateCallback?.AddFrameUpdateCallback(stageCPtr, Layer.getCPtr(GetRootLayer()));
1735         }
1736
1737         /// <summary>
1738         /// Remove FrameUpdateCallback
1739         /// </summary>
1740         [EditorBrowsable(EditorBrowsableState.Never)]
1741         public void RemoveFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1742         {
1743             frameUpdateCallback?.RemoveFrameUpdateCallback(stageCPtr);
1744         }
1745
1746         /// <summary>
1747         /// Dispose for Window
1748         /// </summary>
1749         [EditorBrowsable(EditorBrowsableState.Never)]
1750         protected override void Dispose(DisposeTypes type)
1751         {
1752             if (disposed)
1753             {
1754                 return;
1755             }
1756
1757             if (type == DisposeTypes.Explicit)
1758             {
1759                 //Called by User
1760                 //Release your own managed resources here.
1761                 //You should release all of your own disposable objects here.
1762
1763                 if (IsBorderEnabled)
1764                 {
1765                     DisposeBorder();
1766                 }
1767
1768                 foreach (var layer in childLayers)
1769                 {
1770                     if (layer != null)
1771                     {
1772                         layer.Dispose();
1773                     }
1774                 }
1775
1776                 childLayers.Clear();
1777
1778                 localController?.Dispose();
1779             }
1780
1781             this.DisconnectNativeSignals();
1782
1783             base.Dispose(type);
1784         }
1785
1786         /// This will not be public opened.
1787         [EditorBrowsable(EditorBrowsableState.Never)]
1788         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1789         {
1790             Interop.Window.DeleteWindow(swigCPtr);
1791         }
1792
1793         private static Dictionary<int, internalHookCallbackType> frameCallbackList = new Dictionary<int, internalHookCallbackType>();
1794
1795         private static readonly object locker = new object();
1796
1797         private static int key = 0;
1798
1799         private static FrameCallbackType internalHookFrameCallback = OnInternalHookFrameCallback;
1800
1801         private struct internalHookCallbackType
1802         {
1803             public FrameCallbackType userCallback;
1804             public int frameId;
1805         }
1806
1807         private static void OnInternalHookFrameCallback(int id)
1808         {
1809             lock (locker)
1810             {
1811                 if (frameCallbackList.ContainsKey(id))
1812                 {
1813                     if (frameCallbackList[id].userCallback != null)
1814                     {
1815                         frameCallbackList[id].userCallback.Invoke(frameCallbackList[id].frameId);
1816                         frameCallbackList.Remove(id);
1817                     }
1818                     else
1819                     {
1820                         NUILog.Error($"found userCallback is NULL");
1821                         frameCallbackList.Remove(id);
1822                     }
1823                 }
1824             }
1825         }
1826
1827         private int AddInterHookCallback(FrameCallbackType callback, int frameId)
1828         {
1829             if (null == callback)
1830             {
1831                 throw new ArgumentNullException(nameof(callback), "FrameCallbackType should not be null");
1832             }
1833             var assignedKey = 0;
1834             lock (locker)
1835             {
1836                 key++;
1837                 assignedKey = key;
1838                 frameCallbackList.Add(assignedKey, new internalHookCallbackType()
1839                 {
1840                     userCallback = callback,
1841                     frameId = frameId,
1842                 });
1843             }
1844             return assignedKey;
1845         }
1846
1847         /// <summary>
1848         /// Type of callback which is called when the frame rendering is done by graphics driver or when the frame is displayed on display.
1849         /// </summary>
1850         /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1851         [EditorBrowsable(EditorBrowsableState.Never)]
1852         public delegate void FrameCallbackType(int frameId);
1853
1854         /// <summary>
1855         /// Adds a callback that is called when the frame rendering is done by the graphics driver.
1856         /// A callback of the following type may be used:
1857         /// <code>
1858         /// void MyFunction( int frameId )
1859         /// </code>
1860         /// This callback will be deleted once it is called.
1861         /// <remarks>
1862         /// Ownership of the callback is passed onto this class
1863         /// </remarks>
1864         /// </summary>
1865         /// <param name="callback">The function to call</param>
1866         /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1867         /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1868         [EditorBrowsable(EditorBrowsableState.Never)]
1869         public void AddFrameRenderedCallback(FrameCallbackType callback, int frameId)
1870         {
1871             var assignedKey = AddInterHookCallback(callback, frameId);
1872             Interop.WindowInternal.AddFrameRenderedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1873
1874             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1875         }
1876
1877         /// <summary>
1878         /// Adds a callback that is called when the frame is displayed on the display.
1879         /// A callback of the following type may be used:
1880         /// <code>
1881         /// void MyFunction( int frameId )
1882         /// </code>
1883         /// This callback will be deleted once it is called.
1884         /// <remarks>
1885         /// Ownership of the callback is passed onto this class
1886         /// </remarks>
1887         /// </summary>
1888         /// <param name="callback">The function to call</param>
1889         /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1890         /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1891         [EditorBrowsable(EditorBrowsableState.Never)]
1892         public void AddFramePresentedCallback(FrameCallbackType callback, int frameId)
1893         {
1894             var assignedKey = AddInterHookCallback(callback, frameId);
1895             Interop.WindowInternal.AddFramePresentedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1896
1897             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1898         }
1899
1900         /// <summary>
1901         /// Search through this Window for a Layer with the given unique ID.
1902         /// </summary>
1903         /// <param name="id">The ID of the Layer to find.</param>
1904         /// <remarks>Hidden-API</remarks>
1905         /// <returns>A handle to the Layer if found, or an empty handle if not.</returns>
1906         [EditorBrowsable(EditorBrowsableState.Never)]
1907         public Layer FindLayerByID(uint id)
1908         {
1909             Layer defaultLayer = this.GetDefaultLayer();
1910             IntPtr cPtr = Interop.Actor.FindChildById(defaultLayer.SwigCPtr, id);
1911             Layer ret = this.GetInstanceSafely<Layer>(cPtr);
1912
1913             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1914             return ret;
1915         }
1916
1917         /// <summary>
1918         /// Get Native Window handle.
1919         /// <example>
1920         /// How to get Native Window handle
1921         /// <code>
1922         /// Window window = NUIApplication.GetDefaultWindow();
1923         /// var handle = window.NativeHandle;
1924         /// if(handle.IsInvalid == false)
1925         /// {
1926         ///     IntPtr nativeHandle = handle.DangerousGetHandle();
1927         ///     // do something with nativeHandle
1928         /// }
1929         /// </code>
1930         /// </example>
1931         /// </summary>
1932         /// <since_tizen> 9 </since_tizen>
1933         public SafeHandle NativeHandle
1934         {
1935             get
1936             {
1937                 return new NUI.SafeNativeWindowHandle(this);
1938             }
1939         }
1940     }
1941 }