e21644cd2cc3b6012ef18558ff21c6f9120c7899
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Window.cs
1 /*
2  * Copyright(c) 2017 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 using System;
18 using System.Runtime.InteropServices;
19 using Tizen.NUI.BaseComponents;
20 using System.ComponentModel;
21 using System.Collections.Generic;
22
23 namespace Tizen.NUI
24 {
25     /// <summary>
26     /// The window class is used internally for drawing.<br />
27     /// The window has an orientation and indicator properties.<br />
28     /// </summary>
29     /// <since_tizen> 3 </since_tizen>
30     public class Window : BaseHandle
31     {
32         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
33         private global::System.Runtime.InteropServices.HandleRef stageCPtr;
34         private Layer _rootLayer;
35         private string _windowTitle;
36
37         private List<Layer> _childLayers = new List<Layer>();
38         internal List<Layer> LayersChildren
39         {
40             get
41             {
42                 return _childLayers;
43             }
44         }
45
46         internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Window_SWIGUpcast(cPtr), cMemoryOwn)
47         {
48             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
49             if (NDalicPINVOKE.Stage_IsInstalled())
50             {
51                 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, NDalicPINVOKE.Stage_GetCurrent());
52             }
53         }
54
55         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
56         {
57             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
58         }
59
60         /// <summary>
61         /// To make the window instance be disposed.
62         /// </summary>
63         /// Please DO NOT use! This will be deprecated!
64         /// Dispose() method in Singletone classes (ex: FocusManager, StyleManager, VisualFactory, IMFManager, TtsPlayer, Window) is not required.
65         /// Because it is Sigletone, so it is alive for one thread until the NUI is terminated, so it never be disposed.
66         /// <since_tizen> 3 </since_tizen>
67         [Obsolete("Please do not use! This will be deprecated!")]
68         [EditorBrowsable(EditorBrowsableState.Never)]
69         protected override void Dispose(DisposeTypes type)
70         {
71             if (disposed)
72             {
73                 return;
74             }
75
76             if (type == DisposeTypes.Explicit)
77             {
78                 //Called by User
79                 //Release your own managed resources here.
80                 //You should release all of your own disposable objects here.
81             }
82
83             //Release your own unmanaged resources here.
84             //You should not access any managed member here except static instance.
85             //because the execution order of Finalizes is non-deterministic.
86
87             if (_windowFocusChangedEventCallback != null)
88             {
89                 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
90             }
91
92             if (_stageTouchCallbackDelegate != null)
93             {
94                 TouchSignal().Disconnect(_stageTouchCallbackDelegate);
95             }
96
97             if (_stageWheelCallbackDelegate != null)
98             {
99                 WheelEventSignal().Disconnect(_stageWheelCallbackDelegate);
100             }
101
102             if (_stageKeyCallbackDelegate != null)
103             {
104                 KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
105             }
106
107             if (_stageEventProcessingFinishedEventCallbackDelegate != null)
108             {
109                 EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
110             }
111
112             if (_stageContextLostEventCallbackDelegate != null)
113             {
114                 ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
115             }
116
117             if (_stageContextRegainedEventCallbackDelegate != null)
118             {
119                 this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
120             }
121
122             if (_stageSceneCreatedEventCallbackDelegate != null)
123             {
124                 SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
125             }
126
127             if (_windowResizedEventCallback != null)
128             {
129                 ResizedSignal().Disconnect(_windowResizedEventCallback);
130             }
131
132             if (_windowFocusChangedEventCallback2 != null)
133             {
134                 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
135             }
136
137             if (swigCPtr.Handle != global::System.IntPtr.Zero)
138             {
139                 if (swigCMemOwn)
140                 {
141                     swigCMemOwn = false;
142                     NDalicPINVOKE.delete_Window(swigCPtr);
143                     NDalicPINVOKE.delete_Stage(stageCPtr);
144                 }
145                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
146             }
147
148             base.Dispose(type);
149         }
150
151         internal static Window GetCurrent()
152         {
153             Window ret = new Window(NDalicPINVOKE.Stage_GetCurrent(), true);
154             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
155             return ret;
156         }
157
158         internal static bool IsInstalled()
159         {
160             bool ret = NDalicPINVOKE.Stage_IsInstalled();
161             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162             return ret;
163         }
164
165         /// <summary>
166         /// Sets whether the window accepts a focus or not.
167         /// </summary>
168         /// <param name="accept">If a focus is accepted or not. The default is true.</param>
169         /// <since_tizen> 3 </since_tizen>
170         public void SetAcceptFocus(bool accept)
171         {
172             NDalicPINVOKE.SetAcceptFocus(swigCPtr, accept);
173             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
174         }
175
176         /// <summary>
177         /// Returns whether the window accepts a focus or not.
178         /// </summary>
179         /// <returns>True if the window accepts a focus, false otherwise.</returns>
180         /// <since_tizen> 3 </since_tizen>
181         public bool IsFocusAcceptable()
182         {
183             bool ret = NDalicPINVOKE.IsFocusAcceptable(swigCPtr);
184             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
185
186             return ret;
187         }
188
189         /// <summary>
190         /// Shows the window if it is hidden.
191         /// </summary>
192         /// <since_tizen> 3 </since_tizen>
193         public void Show()
194         {
195             NDalicPINVOKE.Show(swigCPtr);
196             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
197         }
198
199         /// <summary>
200         /// Hides the window if it is showing.
201         /// </summary>
202         /// <since_tizen> 3 </since_tizen>
203         public void Hide()
204         {
205             NDalicPINVOKE.Hide(swigCPtr);
206             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
207         }
208
209         /// <summary>
210         /// Retrieves whether the window is visible or not.
211         /// </summary>
212         /// <returns>True if the window is visible.</returns>
213         /// <since_tizen> 3 </since_tizen>
214         public bool IsVisible()
215         {
216             bool temp = NDalicPINVOKE.IsVisible(swigCPtr);
217             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
218             return temp;
219         }
220
221         /// <summary>
222         /// Gets the count of supported auxiliary hints of the window.
223         /// </summary>
224         /// <returns>The number of supported auxiliary hints.</returns>
225         /// <since_tizen> 3 </since_tizen>
226         public uint GetSupportedAuxiliaryHintCount()
227         {
228             uint ret = NDalicPINVOKE.GetSupportedAuxiliaryHintCount(swigCPtr);
229             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
230             return ret;
231         }
232
233         /// <summary>
234         /// Gets the supported auxiliary hint string of the window.
235         /// </summary>
236         /// <param name="index">The index of the supported auxiliary hint lists.</param>
237         /// <returns>The auxiliary hint string of the index.</returns>
238         /// <since_tizen> 3 </since_tizen>
239         public string GetSupportedAuxiliaryHint(uint index)
240         {
241             string ret = NDalicPINVOKE.GetSupportedAuxiliaryHint(swigCPtr, index);
242             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
243             return ret;
244         }
245
246         /// <summary>
247         /// Creates an auxiliary hint of the window.
248         /// </summary>
249         /// <param name="hint">The auxiliary hint string.</param>
250         /// <param name="value">The value string.</param>
251         /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
252         /// <since_tizen> 3 </since_tizen>
253         public uint AddAuxiliaryHint(string hint, string value)
254         {
255             uint ret = NDalicPINVOKE.AddAuxiliaryHint(swigCPtr, hint, value);
256             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
257             return ret;
258         }
259
260         /// <summary>
261         /// Removes an auxiliary hint of the window.
262         /// </summary>
263         /// <param name="id">The ID of the auxiliary hint.</param>
264         /// <returns>True if no error occurred, false otherwise.</returns>
265         /// <since_tizen> 3 </since_tizen>
266         public bool RemoveAuxiliaryHint(uint id)
267         {
268             bool ret = NDalicPINVOKE.RemoveAuxiliaryHint(swigCPtr, id);
269             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
270             return ret;
271         }
272
273         /// <summary>
274         /// Changes a value of the auxiliary hint.
275         /// </summary>
276         /// <param name="id">The auxiliary hint ID.</param>
277         /// <param name="value">The value string to be set.</param>
278         /// <returns>True if no error occurred, false otherwise.</returns>
279         /// <since_tizen> 3 </since_tizen>
280         public bool SetAuxiliaryHintValue(uint id, string value)
281         {
282             bool ret = NDalicPINVOKE.SetAuxiliaryHintValue(swigCPtr, id, value);
283             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
284             return ret;
285         }
286
287         /// <summary>
288         /// Gets a value of the auxiliary hint.
289         /// </summary>
290         /// <param name="id">The auxiliary hint ID.</param>
291         /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
292         /// <since_tizen> 3 </since_tizen>
293         public string GetAuxiliaryHintValue(uint id)
294         {
295             string ret = NDalicPINVOKE.GetAuxiliaryHintValue(swigCPtr, id);
296             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297             return ret;
298         }
299
300         /// <summary>
301         /// Gets an ID of the auxiliary hint string.
302         /// </summary>
303         /// <param name="hint">The auxiliary hint string.</param>
304         /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
305         /// <since_tizen> 3 </since_tizen>
306         public uint GetAuxiliaryHintId(string hint)
307         {
308             uint ret = NDalicPINVOKE.GetAuxiliaryHintId(swigCPtr, hint);
309             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
310             return ret;
311         }
312
313         /// <summary>
314         /// Sets a region to accept input events.
315         /// </summary>
316         /// <param name="inputRegion">The region to accept input events.</param>
317         /// <since_tizen> 3 </since_tizen>
318         public void SetInputRegion(Rectangle inputRegion)
319         {
320             NDalicPINVOKE.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
321             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
322         }
323
324         /// <summary>
325         /// Gets or sets a window type.
326         /// </summary>
327         /// <since_tizen> 3 </since_tizen>
328         public WindowType Type
329         {
330             get
331             {
332                 WindowType ret = (WindowType)NDalicPINVOKE.GetType(swigCPtr);
333                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
334                 return ret;
335             }
336             set
337             {
338                 NDalicPINVOKE.SetType(swigCPtr, (int)value);
339                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
340             }
341         }
342
343         /// <summary>
344         /// Sets a priority level for the specified notification window.
345         /// </summary>
346         /// <param name="level">The notification window level.</param>
347         /// <returns>True if no error occurred, false otherwise.</returns>
348         /// <since_tizen> 3 </since_tizen>
349         public bool SetNotificationLevel(NotificationLevel level)
350         {
351             bool ret = NDalicPINVOKE.SetNotificationLevel(swigCPtr, (int)level);
352             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
353             return ret;
354         }
355
356         /// <summary>
357         /// Gets a priority level for the specified notification window.
358         /// </summary>
359         /// <returns>The notification window level.</returns>
360         /// <since_tizen> 3 </since_tizen>
361         public NotificationLevel GetNotificationLevel()
362         {
363             NotificationLevel ret = (NotificationLevel)NDalicPINVOKE.GetNotificationLevel(swigCPtr);
364             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
365             return ret;
366         }
367
368         /// <summary>
369         /// Sets a transparent window's visual state to opaque. <br />
370         /// If a visual state of a transparent window is opaque, <br />
371         /// then the window manager could handle it as an opaque window when calculating visibility.
372         /// </summary>
373         /// <param name="opaque">Whether the window's visual state is opaque.</param>
374         /// <remarks>This will have no effect on an opaque window. <br />
375         /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
376         /// </remarks>
377         /// <since_tizen> 3 </since_tizen>
378         public void SetOpaqueState(bool opaque)
379         {
380             NDalicPINVOKE.SetOpaqueState(swigCPtr, opaque);
381             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
382         }
383
384         /// <summary>
385         /// Returns whether a transparent window's visual state is opaque or not.
386         /// </summary>
387         /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
388         /// <remarks> The return value has no meaning on an opaque window. </remarks>
389         /// <since_tizen> 3 </since_tizen>
390         public bool IsOpaqueState()
391         {
392             bool ret = NDalicPINVOKE.IsOpaqueState(swigCPtr);
393             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
394             return ret;
395         }
396
397         /// <summary>
398         /// Sets a window's screen off mode.
399         /// </summary>
400         /// <param name="screenOffMode">The screen mode.</param>
401         /// <returns>True if no error occurred, false otherwise.</returns>
402         /// <since_tizen> 4 </since_tizen>
403         public bool SetScreenOffMode(ScreenOffMode screenOffMode)
404         {
405             bool ret = NDalicPINVOKE.SetScreenOffMode(swigCPtr, (int)screenOffMode);
406             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
407             return ret;
408         }
409
410         /// <summary>
411         /// Gets the screen mode of the window.
412         /// </summary>
413         /// <returns>The screen off mode.</returns>
414         /// <since_tizen> 4 </since_tizen>
415         public ScreenOffMode GetScreenOffMode()
416         {
417             ScreenOffMode ret = (ScreenOffMode)NDalicPINVOKE.GetScreenOffMode(swigCPtr);
418             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
419             return ret;
420         }
421
422         /// <summary>
423         /// Sets preferred brightness of the window.
424         /// </summary>
425         /// <param name="brightness">The preferred brightness (0 to 100).</param>
426         /// <returns>True if no error occurred, false otherwise.</returns>
427         /// <since_tizen> 3 </since_tizen>
428         public bool SetBrightness(int brightness)
429         {
430             bool ret = NDalicPINVOKE.SetBrightness(swigCPtr, brightness);
431             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
432             return ret;
433         }
434
435         /// <summary>
436         /// Gets the preferred brightness of the window.
437         /// </summary>
438         /// <returns>The preferred brightness.</returns>
439         /// <since_tizen> 3 </since_tizen>
440         public int GetBrightness()
441         {
442             int ret = NDalicPINVOKE.GetBrightness(swigCPtr);
443             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
444             return ret;
445         }
446
447         /// <summary>
448         /// The focus changed event argument.
449         /// </summary>
450         /// <since_tizen> 3 </since_tizen>
451         public class FocusChangedEventArgs : EventArgs
452         {
453             /// <summary>
454             /// FocusGained flag.
455             /// </summary>
456             /// <since_tizen> 3 </since_tizen>
457             public bool FocusGained
458             {
459                 get;
460                 set;
461             }
462         }
463
464         private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback;
465         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
466         private delegate void WindowFocusChangedEventCallbackType(bool focusGained);
467         private event EventHandler<FocusChangedEventArgs> _windowFocusChangedEventHandler;
468
469         /// <summary>
470         /// FocusChanged event.
471         /// </summary>
472         /// <since_tizen> 3 </since_tizen>
473         public event EventHandler<FocusChangedEventArgs> FocusChanged
474         {
475             add
476             {
477                 if (_windowFocusChangedEventHandler == null)
478                 {
479                     _windowFocusChangedEventCallback = OnWindowFocusedChanged;
480                     WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback);
481                 }
482
483                 _windowFocusChangedEventHandler += value;
484             }
485             remove
486             {
487                 _windowFocusChangedEventHandler -= value;
488
489                 if (_windowFocusChangedEventHandler == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback != null)
490                 {
491                     WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
492                 }
493             }
494         }
495
496         private void OnWindowFocusedChanged(bool focusGained)
497         {
498             FocusChangedEventArgs e = new FocusChangedEventArgs();
499
500             e.FocusGained = focusGained;
501
502             if (_windowFocusChangedEventHandler != null)
503             {
504                 _windowFocusChangedEventHandler(this, e);
505             }
506         }
507
508         /// <summary>
509         /// Gets/Sets a window title.
510         /// </summary>
511         /// <since_tizen> 4 </since_tizen>
512         public string Title
513         {
514             get
515             {
516                 return _windowTitle;
517             }
518             set
519             {
520                 _windowTitle = value;
521                 SetClass(_windowTitle, "");
522             }
523         }
524
525         internal WindowFocusSignalType WindowFocusChangedSignal()
526         {
527             WindowFocusSignalType ret = new WindowFocusSignalType(NDalicPINVOKE.FocusChangedSignal(swigCPtr), false);
528             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
529             return ret;
530         }
531
532         internal Window(Rectangle windowPosition, string name, bool isTransparent) : this(NDalicPINVOKE.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), name, isTransparent), true)
533         {
534             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
535         }
536
537         internal Window(Rectangle windowPosition, string name) : this(NDalicPINVOKE.Window_New__SWIG_1(Rectangle.getCPtr(windowPosition), name), true)
538         {
539             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
540         }
541
542         internal Window(Rectangle windowPosition, string name, string className, bool isTransparent) : this(NDalicPINVOKE.Window_New__SWIG_2(Rectangle.getCPtr(windowPosition), name, className, isTransparent), true)
543         {
544             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
545         }
546
547         internal Window(Rectangle windowPosition, string name, string className) : this(NDalicPINVOKE.Window_New__SWIG_3(Rectangle.getCPtr(windowPosition), name, className), true)
548         {
549             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
550         }
551
552         internal void ShowIndicator(Window.IndicatorVisibleMode visibleMode)
553         {
554             NDalicPINVOKE.Window_ShowIndicator(swigCPtr, (int)visibleMode);
555             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
556         }
557
558         internal void SetIndicatorBackgroundOpacity(Window.IndicatorBackgroundOpacity opacity)
559         {
560             NDalicPINVOKE.Window_SetIndicatorBgOpacity(swigCPtr, (int)opacity);
561             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
562         }
563
564         internal void RotateIndicator(Window.WindowOrientation orientation)
565         {
566             NDalicPINVOKE.Window_RotateIndicator(swigCPtr, (int)orientation);
567             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
568         }
569
570         /// <summary>
571         /// Sets the window name and the class string.
572         /// </summary>
573         /// <param name="name">The name of the window.</param>
574         /// <param name="klass">The class of the window.</param>
575         /// <since_tizen> 4 </since_tizen>
576         public void SetClass(string name, string klass)
577         {
578             NDalicPINVOKE.Window_SetClass(swigCPtr, name, klass);
579             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
580         }
581
582         /// <summary>
583         /// Raises the window to the top of the window stack.
584         /// </summary>
585         /// <since_tizen> 3 </since_tizen>
586         public void Raise()
587         {
588             NDalicPINVOKE.Window_Raise(swigCPtr);
589             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
590         }
591
592         /// <summary>
593         /// Lowers the window to the bottom of the window stack.
594         /// </summary>
595         /// <since_tizen> 3 </since_tizen>
596         public void Lower()
597         {
598             NDalicPINVOKE.Window_Lower(swigCPtr);
599             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
600         }
601
602         /// <summary>
603         /// Activates the window to the top of the window stack even it is iconified.
604         /// </summary>
605         /// <since_tizen> 3 </since_tizen>
606         public void Activate()
607         {
608             NDalicPINVOKE.Window_Activate(swigCPtr);
609             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
610         }
611
612         internal void AddAvailableOrientation(Window.WindowOrientation orientation)
613         {
614             NDalicPINVOKE.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
615             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
616         }
617
618         internal void RemoveAvailableOrientation(Window.WindowOrientation orientation)
619         {
620             NDalicPINVOKE.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
621             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
622         }
623
624         internal void SetPreferredOrientation(Window.WindowOrientation orientation)
625         {
626             NDalicPINVOKE.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
627             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
628         }
629
630         internal Window.WindowOrientation GetPreferredOrientation()
631         {
632             Window.WindowOrientation ret = (Window.WindowOrientation)NDalicPINVOKE.Window_GetPreferredOrientation(swigCPtr);
633             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
634             return ret;
635         }
636
637         internal DragAndDropDetector GetDragAndDropDetector()
638         {
639             DragAndDropDetector ret = new DragAndDropDetector(NDalicPINVOKE.Window_GetDragAndDropDetector(swigCPtr), true);
640             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
641             return ret;
642         }
643
644         internal Any GetNativeHandle()
645         {
646             Any ret = new Any(NDalicPINVOKE.Window_GetNativeHandle(swigCPtr), true);
647             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
648             return ret;
649         }
650
651         internal WindowFocusSignalType FocusChangedSignal()
652         {
653             WindowFocusSignalType ret = new WindowFocusSignalType(NDalicPINVOKE.FocusChangedSignal(swigCPtr), false);
654             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
655             return ret;
656         }
657
658         /// <summary>
659         /// Gets the default ( root ) layer.
660         /// </summary>
661         /// <returns>The root layer.</returns>
662         /// <since_tizen> 3 </since_tizen>
663         public Layer GetDefaultLayer()
664         {
665             return this.GetRootLayer();
666         }
667
668         internal void Add(Layer layer)
669         {
670             NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
671             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
672
673             LayersChildren.Add(layer);
674         }
675
676         internal void Remove(Layer layer)
677         {
678             NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
679             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
680
681             LayersChildren.Remove(layer);
682         }
683
684         /// <summary>
685         /// Add a child view to window.
686         /// </summary>
687         /// <param name="view">the child should be added to the window.</param>
688         /// <since_tizen> 3 </since_tizen>
689         public void Add(View view)
690         {
691             GetRootLayer()?.Add(view);
692         }
693
694         /// <summary>
695         /// Remove a child view from window.
696         /// </summary>
697         /// <param name="view">the child to be removed.</param>
698         /// <since_tizen> 3 </since_tizen>
699         public void Remove(View view)
700         {
701             GetRootLayer()?.Remove(view);
702         }
703
704         internal Vector2 GetSize()
705         {
706             Vector2 ret = new Vector2(NDalicPINVOKE.Stage_GetSize(stageCPtr), true);
707             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
708             return ret;
709         }
710
711         internal RenderTaskList GetRenderTaskList()
712         {
713             RenderTaskList ret = new RenderTaskList(NDalicPINVOKE.Stage_GetRenderTaskList(stageCPtr), true);
714             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
715             return ret;
716         }
717
718         /// <summary>
719         /// Queries the number of on-window layers.
720         /// </summary>
721         /// <returns>The number of layers.</returns>
722         /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
723         internal uint GetLayerCount()
724         {
725             if (LayersChildren == null || LayersChildren.Count < 0)
726                 return 0;
727
728             return (uint) LayersChildren.Count;
729         }
730
731         /// <summary>
732         /// Retrieves the layer at a specified depth.
733         /// </summary>
734         /// <param name="depth">The layer's depth index.</param>
735         /// <returns>The layer found at the given depth.</returns>
736         /// <since_tizen> 3 </since_tizen>
737         public Layer GetLayer(uint depth)
738         {
739             if (depth < LayersChildren.Count)
740             {
741                 Layer ret = LayersChildren[Convert.ToInt32(depth)];
742                 return ret;
743             }
744             else
745             {
746                 return null;
747             }
748         }
749
750         internal Layer GetRootLayer()
751         {
752             // Window.IsInstalled() is actually true only when called from event thread and
753             // Core has been initialized, not when Stage is ready.
754             if (_rootLayer == null && Window.IsInstalled())
755             {
756                 _rootLayer = new Layer(NDalicPINVOKE.Stage_GetRootLayer(stageCPtr), true);
757                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
758                 LayersChildren.Add(_rootLayer);
759             }
760             return _rootLayer;
761         }
762
763         internal void SetBackgroundColor(Vector4 color)
764         {
765             NDalicPINVOKE.Stage_SetBackgroundColor(stageCPtr, Vector4.getCPtr(color));
766             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
767         }
768
769         internal Vector4 GetBackgroundColor()
770         {
771             Vector4 ret = new Vector4(NDalicPINVOKE.Stage_GetBackgroundColor(stageCPtr), true);
772             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
773             return ret;
774         }
775
776         internal Vector2 GetDpi()
777         {
778             Vector2 ret = new Vector2(NDalicPINVOKE.Stage_GetDpi(stageCPtr), true);
779             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
780             return ret;
781         }
782
783         internal ObjectRegistry GetObjectRegistry()
784         {
785             ObjectRegistry ret = new ObjectRegistry(NDalicPINVOKE.Stage_GetObjectRegistry(stageCPtr), true);
786             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
787             return ret;
788         }
789
790         /// <summary>
791         /// Keep rendering for at least the given amount of time.
792         /// </summary>
793         /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
794         /// <since_tizen> 3 </since_tizen>
795         public void KeepRendering(float durationSeconds)
796         {
797             NDalicPINVOKE.Stage_KeepRendering(stageCPtr, durationSeconds);
798             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
799         }
800
801         internal KeyEventSignal KeyEventSignal()
802         {
803             KeyEventSignal ret = new KeyEventSignal(NDalicPINVOKE.Stage_KeyEventSignal(stageCPtr), false);
804             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
805             return ret;
806         }
807
808         internal VoidSignal EventProcessingFinishedSignal()
809         {
810             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_EventProcessingFinishedSignal(stageCPtr), false);
811             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
812             return ret;
813         }
814
815         internal TouchSignal TouchSignal()
816         {
817             TouchSignal ret = new TouchSignal(NDalicPINVOKE.Stage_TouchSignal(stageCPtr), false);
818             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
819             return ret;
820         }
821
822         private StageWheelSignal WheelEventSignal()
823         {
824             StageWheelSignal ret = new StageWheelSignal(NDalicPINVOKE.Stage_WheelEventSignal(stageCPtr), false);
825             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
826             return ret;
827         }
828
829         internal VoidSignal ContextLostSignal()
830         {
831             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextLostSignal(stageCPtr), false);
832             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
833             return ret;
834         }
835
836         internal VoidSignal ContextRegainedSignal()
837         {
838             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextRegainedSignal(stageCPtr), false);
839             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
840             return ret;
841         }
842
843         internal VoidSignal SceneCreatedSignal()
844         {
845             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_SceneCreatedSignal(stageCPtr), false);
846             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
847             return ret;
848         }
849
850         internal ResizedSignal ResizedSignal()
851         {
852             ResizedSignal ret = new ResizedSignal(NDalicManualPINVOKE.Window_ResizedSignal(swigCPtr), false);
853             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
854             return ret;
855         }
856
857         internal static Vector4 DEFAULT_BACKGROUND_COLOR
858         {
859             get
860             {
861                 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEFAULT_BACKGROUND_COLOR_get();
862                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
863                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
864                 return ret;
865             }
866         }
867
868         internal static Vector4 DEBUG_BACKGROUND_COLOR
869         {
870             get
871             {
872                 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEBUG_BACKGROUND_COLOR_get();
873                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
874                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
875                 return ret;
876             }
877         }
878
879         private static readonly Window instance = Application.Instance.GetWindow();
880
881         /// <summary>
882         /// The stage instance property (read-only).<br />
883         /// Gets the current window.<br />
884         /// </summary>
885         /// <since_tizen> 3 </since_tizen>
886         public static Window Instance
887         {
888             get
889             {
890                 return instance;
891             }
892         }
893
894         /// <summary>
895         /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
896         /// This function can be used for following example scenarios: <br />
897         /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
898         /// </summary>
899         /// <param name="DaliKey">The key code to grab.</param>
900         /// <returns>True if the grab succeeds.</returns>
901         /// <since_tizen> 3 </since_tizen>
902         public bool GrabKeyTopmost(int DaliKey)
903         {
904             bool ret = NDalicManualPINVOKE.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
905             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
906             return ret;
907         }
908
909         /// <summary>
910         /// Ungrabs the key specified by a key for the window.<br />
911         /// 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 />
912         /// </summary>
913         /// <param name="DaliKey">The key code to ungrab.</param>
914         /// <returns>True if the ungrab succeeds.</returns>
915         /// <since_tizen> 3 </since_tizen>
916         public bool UngrabKeyTopmost(int DaliKey)
917         {
918             bool ret = NDalicManualPINVOKE.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
919             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
920             return ret;
921         }
922
923         /// <summary>
924         ///  Grabs the key specified by a key for a window in a GrabMode. <br />
925         ///  Details: This function can be used for following example scenarios: <br />
926         ///  - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
927         ///  - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
928         ///  - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
929         /// </summary>
930         /// <param name="DaliKey">The key code to grab.</param>
931         /// <param name="GrabMode">The grab mode for the key.</param>
932         /// <returns>True if the grab succeeds.</returns>
933         /// <since_tizen> 3 </since_tizen>
934         public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
935         {
936             bool ret = NDalicManualPINVOKE.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
937             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
938             return ret;
939         }
940
941         /// <summary>
942         /// Ungrabs the key specified by a key for a window.<br />
943         /// 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 />
944         /// </summary>
945         /// <param name="DaliKey">The key code to ungrab.</param>
946         /// <returns>True if the ungrab succeeds.</returns>
947         /// <since_tizen> 3 </since_tizen>
948         public bool UngrabKey(int DaliKey)
949         {
950             bool ret = NDalicManualPINVOKE.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
951             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
952             return ret;
953         }
954
955         internal System.IntPtr GetNativeWindowHandler()
956         {
957             System.IntPtr ret = NDalicManualPINVOKE.GetNativeWindowHandler(HandleRef.ToIntPtr(this.swigCPtr));
958             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
959             return ret;
960         }
961
962         /// <summary>
963         /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
964         /// </summary>
965         /// <since_tizen> 3 </since_tizen>
966         public enum WindowOrientation
967         {
968             /// <summary>
969             /// Portrait orientation. The height of the display area is greater than the width.
970             /// </summary>
971             /// <since_tizen> 3 </since_tizen>
972             Portrait = 0,
973             /// <summary>
974             /// Landscape orientation. A wide view area is needed.
975             /// </summary>
976             /// <since_tizen> 3 </since_tizen>
977             Landscape = 90,
978             /// <summary>
979             /// Portrait inverse orientation.
980             /// </summary>
981             /// <since_tizen> 3 </since_tizen>
982             PortraitInverse = 180,
983             /// <summary>
984             /// Landscape inverse orientation.
985             /// </summary>
986             /// <since_tizen> 3 </since_tizen>
987             LandscapeInverse = 270
988         }
989
990         /// <summary>
991         /// Enumeration for the key grab mode for platform-level APIs.
992         /// </summary>
993         /// <since_tizen> 3 </since_tizen>
994         public enum KeyGrabMode
995         {
996             /// <summary>
997             /// Grabs a key only when on the top of the grabbing-window stack mode.
998             /// </summary>
999             Topmost = 0,
1000             /// <summary>
1001             /// Grabs a key together with the other client window(s) mode.
1002             /// </summary>
1003             Shared,
1004             /// <summary>
1005             /// 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.
1006             /// </summary>
1007             OverrideExclusive,
1008             /// <summary>
1009             /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
1010             /// </summary>
1011             Exclusive
1012         };
1013
1014         /// <summary>
1015         /// Enumeration for opacity of the indicator.
1016         /// </summary>
1017         internal enum IndicatorBackgroundOpacity
1018         {
1019             Opaque = 100,
1020             Translucent = 50,
1021             Transparent = 0
1022         }
1023
1024         /// <summary>
1025         /// Enumeration for visible mode of the indicator.
1026         /// </summary>
1027         internal enum IndicatorVisibleMode
1028         {
1029             Invisible = 0,
1030             Visible = 1,
1031             Auto = 2
1032         }
1033
1034         /// <summary>
1035         /// The touch event argument.
1036         /// </summary>
1037         /// <since_tizen> 3 </since_tizen>
1038         public class TouchEventArgs : EventArgs
1039         {
1040             private Touch _touch;
1041
1042             /// <summary>
1043             /// Touch.
1044             /// </summary>
1045             /// <since_tizen> 3 </since_tizen>
1046             public Touch Touch
1047             {
1048                 get
1049                 {
1050                     return _touch;
1051                 }
1052                 set
1053                 {
1054                     _touch = value;
1055                 }
1056             }
1057         }
1058
1059         private event EventHandler<TouchEventArgs> _stageTouchHandler;
1060         private EventCallbackDelegateType1 _stageTouchCallbackDelegate;
1061
1062         /// <summary>
1063         /// This event is emitted when the screen is touched and when the touch ends.<br />
1064         /// If there are multiple touch points, then this will be emitted when the first touch occurs and
1065         /// then when the last finger is lifted.<br />
1066         /// An interrupted event will also be emitted (if it occurs).<br />
1067         /// </summary>
1068         /// <since_tizen> 3 </since_tizen>
1069         public event EventHandler<TouchEventArgs> TouchEvent
1070         {
1071             add
1072             {
1073                 lock (this)
1074                 {
1075                     _stageTouchHandler += value;
1076                     _stageTouchCallbackDelegate = OnStageTouch;
1077                     this.TouchSignal().Connect(_stageTouchCallbackDelegate);
1078                 }
1079             }
1080             remove
1081             {
1082                 lock (this)
1083                 {
1084                     if (_stageTouchHandler != null)
1085                     {
1086                         this.TouchSignal().Disconnect(_stageTouchCallbackDelegate);
1087                     }
1088                     _stageTouchHandler -= value;
1089                 }
1090             }
1091         }
1092
1093         private void OnStageTouch(IntPtr data)
1094         {
1095             TouchEventArgs e = new TouchEventArgs();
1096
1097             if (data != null)
1098             {
1099                 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(data);
1100             }
1101
1102             if (_stageTouchHandler != null)
1103             {
1104                 _stageTouchHandler(this, e);
1105             }
1106         }
1107
1108         /// <summary>
1109         /// Wheel event arguments.
1110         /// </summary>
1111         /// <since_tizen> 3 </since_tizen>
1112         public class WheelEventArgs : EventArgs
1113         {
1114             private Wheel _wheel;
1115
1116             /// <summary>
1117             /// Wheel.
1118             /// </summary>
1119             /// <since_tizen> 3 </since_tizen>
1120             public Wheel Wheel
1121             {
1122                 get
1123                 {
1124                     return _wheel;
1125                 }
1126                 set
1127                 {
1128                     _wheel = value;
1129                 }
1130             }
1131         }
1132
1133         private event EventHandler<WheelEventArgs> _stageWheelHandler;
1134         private EventCallbackDelegateType1 _stageWheelCallbackDelegate;
1135
1136         /// <summary>
1137         /// This event is emitted when the wheel event is received.
1138         /// </summary>
1139         /// <since_tizen> 3 </since_tizen>
1140         public event EventHandler<WheelEventArgs> WheelEvent
1141         {
1142             add
1143             {
1144                 if (_stageWheelHandler == null)
1145                 {
1146                     _stageWheelCallbackDelegate = OnStageWheel;
1147                     WheelEventSignal().Connect(_stageWheelCallbackDelegate);
1148                 }
1149                 _stageWheelHandler += value;
1150             }
1151             remove
1152             {
1153                 _stageWheelHandler -= value;
1154                 if (_stageWheelHandler == null && WheelEventSignal().Empty() == false)
1155                 {
1156                     WheelEventSignal().Disconnect(_stageWheelCallbackDelegate);
1157                 }
1158             }
1159         }
1160
1161         private void OnStageWheel(IntPtr data)
1162         {
1163             WheelEventArgs e = new WheelEventArgs();
1164
1165             if (data != null)
1166             {
1167                 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(data);
1168             }
1169
1170             if (_stageWheelHandler != null)
1171             {
1172                 _stageWheelHandler(this, e);
1173             }
1174         }
1175
1176         /// <summary>
1177         /// Key event arguments.
1178         /// </summary>
1179         /// <since_tizen> 3 </since_tizen>
1180         public class KeyEventArgs : EventArgs
1181         {
1182             private Key _key;
1183
1184             /// <summary>
1185             /// Key.
1186             /// </summary>
1187             /// <since_tizen> 3 </since_tizen>
1188             public Key Key
1189             {
1190                 get
1191                 {
1192                     return _key;
1193                 }
1194                 set
1195                 {
1196                     _key = value;
1197                 }
1198             }
1199         }
1200
1201         private event EventHandler<KeyEventArgs> _stageKeyHandler;
1202         private EventCallbackDelegateType1 _stageKeyCallbackDelegate;
1203
1204         /// <summary>
1205         /// This event is emitted when the key event is received.
1206         /// </summary>
1207         /// <since_tizen> 3 </since_tizen>
1208         public event EventHandler<KeyEventArgs> KeyEvent
1209         {
1210             add
1211             {
1212                 if (_stageKeyHandler == null)
1213                 {
1214                     _stageKeyCallbackDelegate = OnStageKey;
1215                     KeyEventSignal().Connect(_stageKeyCallbackDelegate);
1216                 }
1217                 _stageKeyHandler += value;
1218             }
1219             remove
1220             {
1221                 _stageKeyHandler -= value;
1222                 if (_stageKeyHandler == null && KeyEventSignal().Empty() == false)
1223                 {
1224                     KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
1225                 }
1226             }
1227         }
1228
1229         // Callback for Stage KeyEventsignal
1230         private void OnStageKey(IntPtr data)
1231         {
1232             KeyEventArgs e = new KeyEventArgs();
1233
1234             if (data != null)
1235             {
1236                 e.Key = Tizen.NUI.Key.GetKeyFromPtr(data);
1237             }
1238
1239             if (_stageKeyHandler != null)
1240             {
1241                 //here we send all data to user event handlers
1242                 _stageKeyHandler(this, e);
1243             }
1244         }
1245
1246
1247         private event EventHandler _stageEventProcessingFinishedEventHandler;
1248         private EventCallbackDelegateType0 _stageEventProcessingFinishedEventCallbackDelegate;
1249
1250         internal event EventHandler EventProcessingFinished
1251         {
1252             add
1253             {
1254                 if (_stageEventProcessingFinishedEventHandler == null)
1255                 {
1256                     _stageEventProcessingFinishedEventCallbackDelegate = OnEventProcessingFinished;
1257                     EventProcessingFinishedSignal().Connect(_stageEventProcessingFinishedEventCallbackDelegate);
1258                 }
1259                 _stageEventProcessingFinishedEventHandler += value;
1260
1261             }
1262             remove
1263             {
1264                 _stageEventProcessingFinishedEventHandler -= value;
1265                 if (_stageEventProcessingFinishedEventHandler == null && EventProcessingFinishedSignal().Empty() == false)
1266                 {
1267                     EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
1268                 }
1269             }
1270         }
1271
1272         // Callback for Stage EventProcessingFinishedSignal
1273         private void OnEventProcessingFinished()
1274         {
1275             if (_stageEventProcessingFinishedEventHandler != null)
1276             {
1277                 _stageEventProcessingFinishedEventHandler(this, null);
1278             }
1279         }
1280
1281
1282         private EventHandler _stageContextLostEventHandler;
1283         private EventCallbackDelegateType0 _stageContextLostEventCallbackDelegate;
1284
1285         internal event EventHandler ContextLost
1286         {
1287             add
1288             {
1289                 if (_stageContextLostEventHandler == null)
1290                 {
1291                     _stageContextLostEventCallbackDelegate = OnContextLost;
1292                     ContextLostSignal().Connect(_stageContextLostEventCallbackDelegate);
1293                 }
1294                 _stageContextLostEventHandler += value;
1295             }
1296             remove
1297             {
1298                 _stageContextLostEventHandler -= value;
1299                 if (_stageContextLostEventHandler == null && ContextLostSignal().Empty() == false)
1300                 {
1301                     ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
1302                 }
1303             }
1304         }
1305
1306         // Callback for Stage ContextLostSignal
1307         private void OnContextLost()
1308         {
1309             if (_stageContextLostEventHandler != null)
1310             {
1311                 _stageContextLostEventHandler(this, null);
1312             }
1313         }
1314
1315
1316         private EventHandler _stageContextRegainedEventHandler;
1317         private EventCallbackDelegateType0 _stageContextRegainedEventCallbackDelegate;
1318
1319         internal event EventHandler ContextRegained
1320         {
1321             add
1322             {
1323                 if (_stageContextRegainedEventHandler == null)
1324                 {
1325                     _stageContextRegainedEventCallbackDelegate = OnContextRegained;
1326                     ContextRegainedSignal().Connect(_stageContextRegainedEventCallbackDelegate);
1327                 }
1328                 _stageContextRegainedEventHandler += value;
1329             }
1330             remove
1331             {
1332                 _stageContextRegainedEventHandler -= value;
1333                 if (_stageContextRegainedEventHandler == null && ContextRegainedSignal().Empty() == false)
1334                 {
1335                     this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
1336                 }
1337             }
1338         }
1339
1340         // Callback for Stage ContextRegainedSignal
1341         private void OnContextRegained()
1342         {
1343             if (_stageContextRegainedEventHandler != null)
1344             {
1345                 _stageContextRegainedEventHandler(this, null);
1346             }
1347         }
1348
1349
1350         private EventHandler _stageSceneCreatedEventHandler;
1351         private EventCallbackDelegateType0 _stageSceneCreatedEventCallbackDelegate;
1352
1353         internal event EventHandler SceneCreated
1354         {
1355             add
1356             {
1357                 if (_stageSceneCreatedEventHandler == null)
1358                 {
1359                     _stageSceneCreatedEventCallbackDelegate = OnSceneCreated;
1360                     SceneCreatedSignal().Connect(_stageSceneCreatedEventCallbackDelegate);
1361                 }
1362                 _stageSceneCreatedEventHandler += value;
1363             }
1364             remove
1365             {
1366                 _stageSceneCreatedEventHandler -= value;
1367                 if (_stageSceneCreatedEventHandler == null && SceneCreatedSignal().Empty() == false)
1368                 {
1369                     SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
1370                 }
1371             }
1372         }
1373
1374         // Callback for Stage SceneCreatedSignal
1375         private void OnSceneCreated()
1376         {
1377             if (_stageSceneCreatedEventHandler != null)
1378             {
1379                 _stageSceneCreatedEventHandler(this, null);
1380             }
1381         }
1382
1383         /// <summary>
1384         /// This resized event arguments.
1385         /// </summary>
1386         /// <since_tizen> 3 </since_tizen>
1387         public class ResizedEventArgs : EventArgs
1388         {
1389             Size2D _windowSize;
1390
1391             /// <summary>
1392             /// This window size.
1393             /// </summary>
1394             /// <since_tizen> 4 </since_tizen>
1395             public Size2D WindowSize
1396             {
1397                 get
1398                 {
1399                     return _windowSize;
1400                 }
1401                 set
1402                 {
1403                     _windowSize = value;
1404                 }
1405             }
1406         }
1407
1408         private WindowResizedEventCallbackType _windowResizedEventCallback;
1409         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1410         private delegate void WindowResizedEventCallbackType(IntPtr windowSize);
1411         private event EventHandler<ResizedEventArgs> _windowResizedEventHandler;
1412
1413         /// <summary>
1414         /// This event is emitted when the window resized.
1415         /// </summary>
1416         /// <since_tizen> 3 </since_tizen>
1417         public event EventHandler<ResizedEventArgs> Resized
1418         {
1419             add
1420             {
1421                 if (_windowResizedEventHandler == null)
1422                 {
1423                     _windowResizedEventCallback = OnResized;
1424                     ResizedSignal().Connect(_windowResizedEventCallback);
1425                 }
1426
1427                 _windowResizedEventHandler += value;
1428             }
1429             remove
1430             {
1431                 _windowResizedEventHandler -= value;
1432
1433                 if (_windowResizedEventHandler == null && ResizedSignal().Empty() == false && _windowResizedEventCallback != null)
1434                 {
1435                     ResizedSignal().Disconnect(_windowResizedEventCallback);
1436                 }
1437             }
1438         }
1439
1440         private void OnResized(IntPtr windowSize)
1441         {
1442             ResizedEventArgs e = new ResizedEventArgs();
1443             var val = new Uint16Pair(windowSize, false);
1444             e.WindowSize = new Size2D(val.GetWidth(), val.GetHeight());
1445             val.Dispose();
1446
1447             if (_windowResizedEventHandler != null)
1448             {
1449                 _windowResizedEventHandler(this, e);
1450             }
1451         }
1452
1453         internal void SetWindowSize(Size2D size)
1454         {
1455             var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1456             NDalicManualPINVOKE.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1457
1458             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1459         }
1460
1461         internal Size2D GetWindowSize()
1462         {
1463             var val = new Uint16Pair(NDalicManualPINVOKE.GetSize(swigCPtr), false);
1464             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1465
1466             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1467             return ret;
1468         }
1469
1470         internal void SetPosition(Position2D position)
1471         {
1472             var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1473             NDalicManualPINVOKE.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1474
1475             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1476         }
1477
1478         internal Position2D GetPosition()
1479         {
1480             var val = new Uint16Pair(NDalicManualPINVOKE.GetPosition(swigCPtr), true);
1481             Position2D ret = new Position2D(val.GetX(), val.GetY());
1482
1483             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1484             return ret;
1485         }
1486
1487         /// <summary>
1488         /// Sets whether the window is transparent or not.
1489         /// </summary>
1490         /// <param name="transparent">Whether the window is transparent.</param>
1491         /// <since_tizen> 5 </since_tizen>
1492         /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
1493         [EditorBrowsable(EditorBrowsableState.Never)]
1494         public void SetTransparency(bool transparent)
1495         {
1496             NDalicManualPINVOKE.SetTransparency(swigCPtr, transparent);
1497             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1498         }
1499
1500         /// <summary>
1501         /// The window size property (read-only).
1502         /// </summary>
1503         /// <since_tizen> 3 </since_tizen>
1504         public Size2D Size
1505         {
1506             get
1507             {
1508                 Size2D ret = GetSize();
1509                 return ret;
1510             }
1511         }
1512
1513         /// <summary>
1514         /// The background color property.
1515         /// </summary>
1516         /// <since_tizen> 3 </since_tizen>
1517         public Color BackgroundColor
1518         {
1519             set
1520             {
1521                 SetBackgroundColor(value);
1522             }
1523             get
1524             {
1525                 Color ret = GetBackgroundColor();
1526                 return ret;
1527             }
1528         }
1529
1530         /// <summary>
1531         /// The DPI property (read-only).<br />
1532         /// Retrieves the DPI of the display device to which the Window is connected.<br />
1533         /// </summary>
1534         /// <since_tizen> 3 </since_tizen>
1535         public Vector2 Dpi
1536         {
1537             get
1538             {
1539                 return GetDpi();
1540             }
1541         }
1542
1543         /// <summary>
1544         /// The layer count property (read-only).<br />
1545         /// Queries the number of on-Window layers.<br />
1546         /// </summary>
1547         /// <since_tizen> 3 </since_tizen>
1548         public uint LayerCount
1549         {
1550             get
1551             {
1552                 return GetLayerCount();
1553             }
1554         }
1555
1556
1557         /// <summary>
1558         /// Adds a layer to the stage.
1559         /// </summary>
1560         /// <param name="layer">Layer to add.</param>
1561         /// <since_tizen> 3 </since_tizen>
1562         public void AddLayer(Layer layer)
1563         {
1564             NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
1565             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1566
1567             LayersChildren.Add(layer);
1568         }
1569
1570         /// <summary>
1571         /// Removes a layer from the stage.
1572         /// </summary>
1573         /// <param name="layer">Layer to remove.</param>
1574         /// <since_tizen> 3 </since_tizen>
1575         public void RemoveLayer(Layer layer)
1576         {
1577             NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
1578             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1579
1580             LayersChildren.Remove(layer);
1581         }
1582
1583         /// <summary>
1584         /// Please do not use! this will be deprecated
1585         /// </summary>
1586         /// <since_tizen> 3 </since_tizen>
1587         [Obsolete("Please do not use! This will be deprecated! Please use FocusChangedEventArgs instead! " +
1588             "Like: " +
1589             "Window.Instance.FocusChanged = OnFocusChanged; " +
1590             "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
1591         [EditorBrowsable(EditorBrowsableState.Never)]
1592         public class WindowFocusChangedEventArgs : EventArgs
1593         {
1594             /// <summary>
1595             /// Please do not use! this will be deprecated
1596             /// </summary>
1597             /// <since_tizen> 3 </since_tizen>
1598             public bool FocusGained
1599             {
1600                 get;
1601                 set;
1602             }
1603         }
1604
1605         private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback2;
1606         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1607         private delegate void WindowFocusChangedEventCallbackType2(bool focusGained);
1608         private event EventHandler<WindowFocusChangedEventArgs> _windowFocusChangedEventHandler2;
1609
1610         /// <summary>
1611         /// Please do not use! this will be deprecated. Please use 'FocusChanged' event instead.
1612         /// </summary>
1613         /// <since_tizen> 3 </since_tizen>
1614         /// Please do not use! this will be deprecated!
1615         /// Instead please use FocusChanged.
1616         [Obsolete("Please do not use! This will be deprecated! Please use FocusChanged instead! " +
1617             "Like: " +
1618             "Window.Instance.FocusChanged = OnFocusChanged; " +
1619             "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
1620         [EditorBrowsable(EditorBrowsableState.Never)]
1621         public event EventHandler<WindowFocusChangedEventArgs> WindowFocusChanged
1622         {
1623             add
1624             {
1625                 if (_windowFocusChangedEventHandler2 == null)
1626                 {
1627                     _windowFocusChangedEventCallback2 = OnWindowFocusedChanged2;
1628                     WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback2);
1629                 }
1630
1631                 _windowFocusChangedEventHandler2 += value;
1632             }
1633             remove
1634             {
1635                 _windowFocusChangedEventHandler2 -= value;
1636
1637                 if (_windowFocusChangedEventHandler2 == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback2 != null)
1638                 {
1639                     WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
1640                 }
1641             }
1642         }
1643
1644         private void OnWindowFocusedChanged2(bool focusGained)
1645         {
1646             WindowFocusChangedEventArgs e = new WindowFocusChangedEventArgs();
1647
1648             e.FocusGained = focusGained;
1649
1650             if (_windowFocusChangedEventHandler2 != null)
1651             {
1652                 _windowFocusChangedEventHandler2(this, e);
1653             }
1654         }
1655
1656         /// <summary>
1657         /// Gets or sets a size of the window.
1658         /// </summary>
1659         /// <since_tizen> 4 </since_tizen>
1660         public Size2D WindowSize
1661         {
1662             get
1663             {
1664                 return GetWindowSize();
1665             }
1666             set
1667             {
1668                 SetWindowSize(value);
1669             }
1670         }
1671
1672         /// <summary>
1673         /// Gets or sets a position of the window.
1674         /// </summary>
1675         /// <since_tizen> 4 </since_tizen>
1676         public Position2D WindowPosition
1677         {
1678             get
1679             {
1680                 return GetPosition();
1681             }
1682             set
1683             {
1684                 SetPosition(value);
1685             }
1686         }
1687
1688         /// <summary>
1689         /// Feed a key-event into the window.
1690         /// </summary>
1691         /// <param name="keyEvent">The key event to feed.</param>
1692         /// <since_tizen> 5 </since_tizen>
1693         [EditorBrowsable(EditorBrowsableState.Never)]
1694         public void FeedKey(Key keyEvent)
1695         {
1696             NDalicManualPINVOKE.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
1697             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1698         }
1699
1700         /// <summary>
1701         /// Feed a key-event into the window.
1702         /// </summary>
1703         /// <param name="keyEvent">The key event to feed.</param>
1704         /// <since_tizen> 4 </since_tizen>
1705         [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
1706         public static void FeedKeyEvent(Key keyEvent)
1707         {
1708             NDalicManualPINVOKE.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
1709             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1710         }
1711
1712         /// <summary>
1713         /// Allows at least one more render, even when paused.
1714         /// The window should be shown, not minimised.
1715         /// </summary>
1716         /// <since_tizen> 4 </since_tizen>
1717         public void RenderOnce()
1718         {
1719             NDalicManualPINVOKE.Window_RenderOnce(swigCPtr);
1720             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1721         }
1722
1723         /// <summary>
1724         /// Contains and encapsulates Native Window handle.
1725         /// </summary>
1726         /// <since_tizen> 4 </since_tizen>
1727         public class SafeNativeWindowHandle : SafeHandle
1728         {
1729             /// <summary>
1730             /// Contructor, Native window handle is set to handle.
1731             /// </summary>
1732             /// <since_tizen> 4 </since_tizen>
1733             public SafeNativeWindowHandle() : base(IntPtr.Zero, false)
1734             {
1735                 SetHandle(Tizen.NUI.Window.Instance.GetNativeWindowHandler());
1736             }
1737             /// <summary>
1738             /// Null check if the handle is valid or not.
1739             /// </summary>
1740             /// <since_tizen> 4 </since_tizen>
1741             public override bool IsInvalid
1742             {
1743                 get
1744                 {
1745                     return this.handle == IntPtr.Zero;
1746                 }
1747             }
1748             /// <summary>
1749             /// Release handle itself.
1750             /// </summary>
1751             /// <returns>true when released successfully.</returns>
1752             /// <since_tizen> 4 </since_tizen>
1753             protected override bool ReleaseHandle()
1754             {
1755                 return true;
1756             }
1757         }
1758
1759     }
1760 }