[NUI] Add Obsolete attributes for EditorBrowsable apis
[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         private 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.
370         /// </summary>
371         /// <param name="opaque">Whether the window's visual state is opaque.</param>
372         /// <since_tizen> 3 </since_tizen>
373         public void SetOpaqueState(bool opaque)
374         {
375             NDalicPINVOKE.SetOpaqueState(swigCPtr, opaque);
376             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
377         }
378
379         /// <summary>
380         /// Returns whether a transparent window's visual state is opaque or not.
381         /// </summary>
382         /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
383         /// <since_tizen> 3 </since_tizen>
384         public bool IsOpaqueState()
385         {
386             bool ret = NDalicPINVOKE.IsOpaqueState(swigCPtr);
387             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
388             return ret;
389         }
390
391         /// <summary>
392         /// Sets a window's screen off mode.
393         /// </summary>
394         /// <param name="screenOffMode">The screen mode.</param>
395         /// <returns>True if no error occurred, false otherwise.</returns>
396         /// <since_tizen> 4 </since_tizen>
397         public bool SetScreenOffMode(ScreenOffMode screenOffMode)
398         {
399             bool ret = NDalicPINVOKE.SetScreenOffMode(swigCPtr, (int)screenOffMode);
400             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
401             return ret;
402         }
403
404         /// <summary>
405         /// Gets the screen mode of the window.
406         /// </summary>
407         /// <returns>The screen off mode.</returns>
408         /// <since_tizen> 4 </since_tizen>
409         public ScreenOffMode GetScreenOffMode()
410         {
411             ScreenOffMode ret = (ScreenOffMode)NDalicPINVOKE.GetScreenOffMode(swigCPtr);
412             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
413             return ret;
414         }
415
416         /// <summary>
417         /// Sets preferred brightness of the window.
418         /// </summary>
419         /// <param name="brightness">The preferred brightness (0 to 100).</param>
420         /// <returns>True if no error occurred, false otherwise.</returns>
421         /// <since_tizen> 3 </since_tizen>
422         public bool SetBrightness(int brightness)
423         {
424             bool ret = NDalicPINVOKE.SetBrightness(swigCPtr, brightness);
425             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
426             return ret;
427         }
428
429         /// <summary>
430         /// Gets the preferred brightness of the window.
431         /// </summary>
432         /// <returns>The preferred brightness.</returns>
433         /// <since_tizen> 3 </since_tizen>
434         public int GetBrightness()
435         {
436             int ret = NDalicPINVOKE.GetBrightness(swigCPtr);
437             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
438             return ret;
439         }
440
441         /// <summary>
442         /// The focus changed event argument.
443         /// </summary>
444         /// <since_tizen> 3 </since_tizen>
445         public class FocusChangedEventArgs : EventArgs
446         {
447             /// <summary>
448             /// FocusGained flag.
449             /// </summary>
450             /// <since_tizen> 3 </since_tizen>
451             public bool FocusGained
452             {
453                 get;
454                 set;
455             }
456         }
457
458         private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback;
459         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
460         private delegate void WindowFocusChangedEventCallbackType(bool focusGained);
461         private event EventHandler<FocusChangedEventArgs> _windowFocusChangedEventHandler;
462
463         /// <summary>
464         /// FocusChanged event.
465         /// </summary>
466         /// <since_tizen> 3 </since_tizen>
467         public event EventHandler<FocusChangedEventArgs> FocusChanged
468         {
469             add
470             {
471                 if (_windowFocusChangedEventHandler == null)
472                 {
473                     _windowFocusChangedEventCallback = OnWindowFocusedChanged;
474                     WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback);
475                 }
476
477                 _windowFocusChangedEventHandler += value;
478             }
479             remove
480             {
481                 _windowFocusChangedEventHandler -= value;
482
483                 if (_windowFocusChangedEventHandler == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback != null)
484                 {
485                     WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
486                 }
487             }
488         }
489
490         private void OnWindowFocusedChanged(bool focusGained)
491         {
492             FocusChangedEventArgs e = new FocusChangedEventArgs();
493
494             e.FocusGained = focusGained;
495
496             if (_windowFocusChangedEventHandler != null)
497             {
498                 _windowFocusChangedEventHandler(this, e);
499             }
500         }
501
502         /// <summary>
503         /// Gets/Sets a window title.
504         /// </summary>
505         /// <since_tizen> 4 </since_tizen>
506         public string Title
507         {
508             get
509             {
510                 return _windowTitle;
511             }
512             set
513             {
514                 _windowTitle = value;
515                 SetClass(_windowTitle, "");
516             }
517         }
518
519         internal WindowFocusSignalType WindowFocusChangedSignal()
520         {
521             WindowFocusSignalType ret = new WindowFocusSignalType(NDalicPINVOKE.FocusChangedSignal(swigCPtr), false);
522             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
523             return ret;
524         }
525
526         internal Window(Rectangle windowPosition, string name, bool isTransparent) : this(NDalicPINVOKE.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), name, isTransparent), true)
527         {
528             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
529         }
530
531         internal Window(Rectangle windowPosition, string name) : this(NDalicPINVOKE.Window_New__SWIG_1(Rectangle.getCPtr(windowPosition), name), true)
532         {
533             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
534         }
535
536         internal Window(Rectangle windowPosition, string name, string className, bool isTransparent) : this(NDalicPINVOKE.Window_New__SWIG_2(Rectangle.getCPtr(windowPosition), name, className, isTransparent), true)
537         {
538             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
539         }
540
541         internal Window(Rectangle windowPosition, string name, string className) : this(NDalicPINVOKE.Window_New__SWIG_3(Rectangle.getCPtr(windowPosition), name, className), true)
542         {
543             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
544         }
545
546         internal void ShowIndicator(Window.IndicatorVisibleMode visibleMode)
547         {
548             NDalicPINVOKE.Window_ShowIndicator(swigCPtr, (int)visibleMode);
549             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
550         }
551
552         internal void SetIndicatorBackgroundOpacity(Window.IndicatorBackgroundOpacity opacity)
553         {
554             NDalicPINVOKE.Window_SetIndicatorBgOpacity(swigCPtr, (int)opacity);
555             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
556         }
557
558         internal void RotateIndicator(Window.WindowOrientation orientation)
559         {
560             NDalicPINVOKE.Window_RotateIndicator(swigCPtr, (int)orientation);
561             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
562         }
563
564         /// <summary>
565         /// Sets the window name and the class string.
566         /// </summary>
567         /// <param name="name">The name of the window.</param>
568         /// <param name="klass">The class of the window.</param>
569         /// <since_tizen> 4 </since_tizen>
570         public void SetClass(string name, string klass)
571         {
572             NDalicPINVOKE.Window_SetClass(swigCPtr, name, klass);
573             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
574         }
575
576         /// <summary>
577         /// Raises the window to the top of the window stack.
578         /// </summary>
579         /// <since_tizen> 3 </since_tizen>
580         public void Raise()
581         {
582             NDalicPINVOKE.Window_Raise(swigCPtr);
583             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
584         }
585
586         /// <summary>
587         /// Lowers the window to the bottom of the window stack.
588         /// </summary>
589         /// <since_tizen> 3 </since_tizen>
590         public void Lower()
591         {
592             NDalicPINVOKE.Window_Lower(swigCPtr);
593             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
594         }
595
596         /// <summary>
597         /// Activates the window to the top of the window stack even it is iconified.
598         /// </summary>
599         /// <since_tizen> 3 </since_tizen>
600         public void Activate()
601         {
602             NDalicPINVOKE.Window_Activate(swigCPtr);
603             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
604         }
605
606         internal void AddAvailableOrientation(Window.WindowOrientation orientation)
607         {
608             NDalicPINVOKE.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
609             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
610         }
611
612         internal void RemoveAvailableOrientation(Window.WindowOrientation orientation)
613         {
614             NDalicPINVOKE.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
615             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
616         }
617
618         internal void SetPreferredOrientation(Window.WindowOrientation orientation)
619         {
620             NDalicPINVOKE.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
621             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
622         }
623
624         internal Window.WindowOrientation GetPreferredOrientation()
625         {
626             Window.WindowOrientation ret = (Window.WindowOrientation)NDalicPINVOKE.Window_GetPreferredOrientation(swigCPtr);
627             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
628             return ret;
629         }
630
631         internal DragAndDropDetector GetDragAndDropDetector()
632         {
633             DragAndDropDetector ret = new DragAndDropDetector(NDalicPINVOKE.Window_GetDragAndDropDetector(swigCPtr), true);
634             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
635             return ret;
636         }
637
638         internal Any GetNativeHandle()
639         {
640             Any ret = new Any(NDalicPINVOKE.Window_GetNativeHandle(swigCPtr), true);
641             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
642             return ret;
643         }
644
645         internal WindowFocusSignalType FocusChangedSignal()
646         {
647             WindowFocusSignalType ret = new WindowFocusSignalType(NDalicPINVOKE.FocusChangedSignal(swigCPtr), false);
648             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
649             return ret;
650         }
651
652         /// <summary>
653         /// Gets the default ( root ) layer.
654         /// </summary>
655         /// <returns>The root layer.</returns>
656         /// <since_tizen> 3 </since_tizen>
657         public Layer GetDefaultLayer()
658         {
659             return this.GetRootLayer();
660         }
661
662         internal void Add(Layer layer)
663         {
664             NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
665             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
666
667             LayersChildren.Add(layer);
668         }
669
670         internal void Remove(Layer layer)
671         {
672             NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
673             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
674
675             LayersChildren.Remove(layer);
676         }
677
678         /// <summary>
679         /// Add a child view to window.
680         /// </summary>
681         /// <param name="view">the child should be added to the window.</param>
682         /// <since_tizen> 3 </since_tizen>
683         public void Add(View view)
684         {
685             GetRootLayer()?.Add(view);
686         }
687
688         /// <summary>
689         /// Remove a child view from window.
690         /// </summary>
691         /// <param name="view">the child to be removed.</param>
692         /// <since_tizen> 3 </since_tizen>
693         public void Remove(View view)
694         {
695             GetRootLayer()?.Remove(view);
696         }
697
698         internal Vector2 GetSize()
699         {
700             Vector2 ret = new Vector2(NDalicPINVOKE.Stage_GetSize(stageCPtr), true);
701             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
702             return ret;
703         }
704
705         internal RenderTaskList GetRenderTaskList()
706         {
707             RenderTaskList ret = new RenderTaskList(NDalicPINVOKE.Stage_GetRenderTaskList(stageCPtr), true);
708             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
709             return ret;
710         }
711
712         /// <summary>
713         /// Queries the number of on-window layers.
714         /// </summary>
715         /// <returns>The number of layers.</returns>
716         /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
717         internal uint GetLayerCount()
718         {
719             if (LayersChildren == null || LayersChildren.Count < 0)
720                 return 0;
721
722             return (uint) LayersChildren.Count;
723         }
724
725         /// <summary>
726         /// Retrieves the layer at a specified depth.
727         /// </summary>
728         /// <param name="depth">The layer's depth index.</param>
729         /// <returns>The layer found at the given depth.</returns>
730         /// <since_tizen> 3 </since_tizen>
731         public Layer GetLayer(uint depth)
732         {
733             IntPtr cPtr = NDalicPINVOKE.Stage_GetLayer(stageCPtr, depth);
734             Layer ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Layer;
735
736             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
737             return ret;
738         }
739
740         internal Layer GetRootLayer()
741         {
742             // Window.IsInstalled() is actually true only when called from event thread and
743             // Core has been initialized, not when Stage is ready.
744             if (_rootLayer == null && Window.IsInstalled())
745             {
746                 _rootLayer = new Layer(NDalicPINVOKE.Stage_GetRootLayer(stageCPtr), true);
747                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
748                 LayersChildren.Add(_rootLayer);
749             }
750             return _rootLayer;
751         }
752
753         internal void SetBackgroundColor(Vector4 color)
754         {
755             NDalicPINVOKE.Stage_SetBackgroundColor(stageCPtr, Vector4.getCPtr(color));
756             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
757         }
758
759         internal Vector4 GetBackgroundColor()
760         {
761             Vector4 ret = new Vector4(NDalicPINVOKE.Stage_GetBackgroundColor(stageCPtr), true);
762             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
763             return ret;
764         }
765
766         internal Vector2 GetDpi()
767         {
768             Vector2 ret = new Vector2(NDalicPINVOKE.Stage_GetDpi(stageCPtr), true);
769             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
770             return ret;
771         }
772
773         internal ObjectRegistry GetObjectRegistry()
774         {
775             ObjectRegistry ret = new ObjectRegistry(NDalicPINVOKE.Stage_GetObjectRegistry(stageCPtr), true);
776             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
777             return ret;
778         }
779
780         /// <summary>
781         /// Keep rendering for at least the given amount of time.
782         /// </summary>
783         /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
784         /// <since_tizen> 3 </since_tizen>
785         public void KeepRendering(float durationSeconds)
786         {
787             NDalicPINVOKE.Stage_KeepRendering(stageCPtr, durationSeconds);
788             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
789         }
790
791         internal KeyEventSignal KeyEventSignal()
792         {
793             KeyEventSignal ret = new KeyEventSignal(NDalicPINVOKE.Stage_KeyEventSignal(stageCPtr), false);
794             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
795             return ret;
796         }
797
798         internal VoidSignal EventProcessingFinishedSignal()
799         {
800             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_EventProcessingFinishedSignal(stageCPtr), false);
801             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
802             return ret;
803         }
804
805         internal TouchSignal TouchSignal()
806         {
807             TouchSignal ret = new TouchSignal(NDalicPINVOKE.Stage_TouchSignal(stageCPtr), false);
808             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
809             return ret;
810         }
811
812         private StageWheelSignal WheelEventSignal()
813         {
814             StageWheelSignal ret = new StageWheelSignal(NDalicPINVOKE.Stage_WheelEventSignal(stageCPtr), false);
815             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
816             return ret;
817         }
818
819         internal VoidSignal ContextLostSignal()
820         {
821             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextLostSignal(stageCPtr), false);
822             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
823             return ret;
824         }
825
826         internal VoidSignal ContextRegainedSignal()
827         {
828             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextRegainedSignal(stageCPtr), false);
829             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
830             return ret;
831         }
832
833         internal VoidSignal SceneCreatedSignal()
834         {
835             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_SceneCreatedSignal(stageCPtr), false);
836             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
837             return ret;
838         }
839
840         internal ResizedSignal ResizedSignal()
841         {
842             ResizedSignal ret = new ResizedSignal(NDalicManualPINVOKE.Window_ResizedSignal(swigCPtr), false);
843             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
844             return ret;
845         }
846
847         internal static Vector4 DEFAULT_BACKGROUND_COLOR
848         {
849             get
850             {
851                 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEFAULT_BACKGROUND_COLOR_get();
852                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
853                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
854                 return ret;
855             }
856         }
857
858         internal static Vector4 DEBUG_BACKGROUND_COLOR
859         {
860             get
861             {
862                 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEBUG_BACKGROUND_COLOR_get();
863                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
864                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
865                 return ret;
866             }
867         }
868
869         private static readonly Window instance = Application.Instance.GetWindow();
870
871         /// <summary>
872         /// The stage instance property (read-only).<br />
873         /// Gets the current window.<br />
874         /// </summary>
875         /// <since_tizen> 3 </since_tizen>
876         public static Window Instance
877         {
878             get
879             {
880                 return instance;
881             }
882         }
883
884         /// <summary>
885         /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
886         /// This function can be used for following example scenarios: <br />
887         /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
888         /// </summary>
889         /// <param name="DaliKey">The key code to grab.</param>
890         /// <returns>True if the grab succeeds.</returns>
891         /// <since_tizen> 3 </since_tizen>
892         public bool GrabKeyTopmost(int DaliKey)
893         {
894             bool ret = NDalicManualPINVOKE.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
895             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
896             return ret;
897         }
898
899         /// <summary>
900         /// Ungrabs the key specified by a key for the window.<br />
901         /// 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 />
902         /// </summary>
903         /// <param name="DaliKey">The key code to ungrab.</param>
904         /// <returns>True if the ungrab succeeds.</returns>
905         /// <since_tizen> 3 </since_tizen>
906         public bool UngrabKeyTopmost(int DaliKey)
907         {
908             bool ret = NDalicManualPINVOKE.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
909             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
910             return ret;
911         }
912
913         /// <summary>
914         ///  Grabs the key specified by a key for a window in a GrabMode. <br />
915         ///  Details: This function can be used for following example scenarios: <br />
916         ///  - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
917         ///  - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
918         ///  - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
919         /// </summary>
920         /// <param name="DaliKey">The key code to grab.</param>
921         /// <param name="GrabMode">The grab mode for the key.</param>
922         /// <returns>True if the grab succeeds.</returns>
923         /// <since_tizen> 3 </since_tizen>
924         public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
925         {
926             bool ret = NDalicManualPINVOKE.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
927             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
928             return ret;
929         }
930
931         /// <summary>
932         /// Ungrabs the key specified by a key for a window.<br />
933         /// 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 />
934         /// </summary>
935         /// <param name="DaliKey">The key code to ungrab.</param>
936         /// <returns>True if the ungrab succeeds.</returns>
937         /// <since_tizen> 3 </since_tizen>
938         public bool UngrabKey(int DaliKey)
939         {
940             bool ret = NDalicManualPINVOKE.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
941             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
942             return ret;
943         }
944
945         internal System.IntPtr GetNativeWindowHandler()
946         {
947             System.IntPtr ret = NDalicManualPINVOKE.GetNativeWindowHandler(HandleRef.ToIntPtr(this.swigCPtr));
948             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
949             return ret;
950         }
951
952         /// <summary>
953         /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
954         /// </summary>
955         /// <since_tizen> 3 </since_tizen>
956         public enum WindowOrientation
957         {
958             /// <summary>
959             /// Portrait orientation. The height of the display area is greater than the width.
960             /// </summary>
961             /// <since_tizen> 3 </since_tizen>
962             Portrait = 0,
963             /// <summary>
964             /// Landscape orientation. A wide view area is needed.
965             /// </summary>
966             /// <since_tizen> 3 </since_tizen>
967             Landscape = 90,
968             /// <summary>
969             /// Portrait inverse orientation.
970             /// </summary>
971             /// <since_tizen> 3 </since_tizen>
972             PortraitInverse = 180,
973             /// <summary>
974             /// Landscape inverse orientation.
975             /// </summary>
976             /// <since_tizen> 3 </since_tizen>
977             LandscapeInverse = 270
978         }
979
980         /// <summary>
981         /// Enumeration for the key grab mode for platform-level APIs.
982         /// </summary>
983         /// <since_tizen> 3 </since_tizen>
984         public enum KeyGrabMode
985         {
986             /// <summary>
987             /// Grabs a key only when on the top of the grabbing-window stack mode.
988             /// </summary>
989             Topmost = 0,
990             /// <summary>
991             /// Grabs a key together with the other client window(s) mode.
992             /// </summary>
993             Shared,
994             /// <summary>
995             /// 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.
996             /// </summary>
997             OverrideExclusive,
998             /// <summary>
999             /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
1000             /// </summary>
1001             Exclusive
1002         };
1003
1004         /// <summary>
1005         /// Enumeration for opacity of the indicator.
1006         /// </summary>
1007         internal enum IndicatorBackgroundOpacity
1008         {
1009             Opaque = 100,
1010             Translucent = 50,
1011             Transparent = 0
1012         }
1013
1014         /// <summary>
1015         /// Enumeration for visible mode of the indicator.
1016         /// </summary>
1017         internal enum IndicatorVisibleMode
1018         {
1019             Invisible = 0,
1020             Visible = 1,
1021             Auto = 2
1022         }
1023
1024         /// <summary>
1025         /// The touch event argument.
1026         /// </summary>
1027         /// <since_tizen> 3 </since_tizen>
1028         public class TouchEventArgs : EventArgs
1029         {
1030             private Touch _touch;
1031
1032             /// <summary>
1033             /// Touch.
1034             /// </summary>
1035             /// <since_tizen> 3 </since_tizen>
1036             public Touch Touch
1037             {
1038                 get
1039                 {
1040                     return _touch;
1041                 }
1042                 set
1043                 {
1044                     _touch = value;
1045                 }
1046             }
1047         }
1048
1049         private event EventHandler<TouchEventArgs> _stageTouchHandler;
1050         private EventCallbackDelegateType1 _stageTouchCallbackDelegate;
1051
1052         /// <summary>
1053         /// This event is emitted when the screen is touched and when the touch ends.<br />
1054         /// If there are multiple touch points, then this will be emitted when the first touch occurs and
1055         /// then when the last finger is lifted.<br />
1056         /// An interrupted event will also be emitted (if it occurs).<br />
1057         /// </summary>
1058         /// <since_tizen> 3 </since_tizen>
1059         public event EventHandler<TouchEventArgs> TouchEvent
1060         {
1061             add
1062             {
1063                 lock (this)
1064                 {
1065                     _stageTouchHandler += value;
1066                     _stageTouchCallbackDelegate = OnStageTouch;
1067                     this.TouchSignal().Connect(_stageTouchCallbackDelegate);
1068                 }
1069             }
1070             remove
1071             {
1072                 lock (this)
1073                 {
1074                     if (_stageTouchHandler != null)
1075                     {
1076                         this.TouchSignal().Disconnect(_stageTouchCallbackDelegate);
1077                     }
1078                     _stageTouchHandler -= value;
1079                 }
1080             }
1081         }
1082
1083         private void OnStageTouch(IntPtr data)
1084         {
1085             TouchEventArgs e = new TouchEventArgs();
1086
1087             if (data != null)
1088             {
1089                 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(data);
1090             }
1091
1092             if (_stageTouchHandler != null)
1093             {
1094                 _stageTouchHandler(this, e);
1095             }
1096         }
1097
1098         /// <summary>
1099         /// Wheel event arguments.
1100         /// </summary>
1101         /// <since_tizen> 3 </since_tizen>
1102         public class WheelEventArgs : EventArgs
1103         {
1104             private Wheel _wheel;
1105
1106             /// <summary>
1107             /// Wheel.
1108             /// </summary>
1109             /// <since_tizen> 3 </since_tizen>
1110             public Wheel Wheel
1111             {
1112                 get
1113                 {
1114                     return _wheel;
1115                 }
1116                 set
1117                 {
1118                     _wheel = value;
1119                 }
1120             }
1121         }
1122
1123         private event EventHandler<WheelEventArgs> _stageWheelHandler;
1124         private EventCallbackDelegateType1 _stageWheelCallbackDelegate;
1125
1126         /// <summary>
1127         /// This event is emitted when the wheel event is received.
1128         /// </summary>
1129         /// <since_tizen> 3 </since_tizen>
1130         public event EventHandler<WheelEventArgs> WheelEvent
1131         {
1132             add
1133             {
1134                 if (_stageWheelHandler == null)
1135                 {
1136                     _stageWheelCallbackDelegate = OnStageWheel;
1137                     WheelEventSignal().Connect(_stageWheelCallbackDelegate);
1138                 }
1139                 _stageWheelHandler += value;
1140             }
1141             remove
1142             {
1143                 _stageWheelHandler -= value;
1144                 if (_stageWheelHandler == null && WheelEventSignal().Empty() == false)
1145                 {
1146                     WheelEventSignal().Disconnect(_stageWheelCallbackDelegate);
1147                 }
1148             }
1149         }
1150
1151         private void OnStageWheel(IntPtr data)
1152         {
1153             WheelEventArgs e = new WheelEventArgs();
1154
1155             if (data != null)
1156             {
1157                 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(data);
1158             }
1159
1160             if (_stageWheelHandler != null)
1161             {
1162                 _stageWheelHandler(this, e);
1163             }
1164         }
1165
1166         /// <summary>
1167         /// Key event arguments.
1168         /// </summary>
1169         /// <since_tizen> 3 </since_tizen>
1170         public class KeyEventArgs : EventArgs
1171         {
1172             private Key _key;
1173
1174             /// <summary>
1175             /// Key.
1176             /// </summary>
1177             /// <since_tizen> 3 </since_tizen>
1178             public Key Key
1179             {
1180                 get
1181                 {
1182                     return _key;
1183                 }
1184                 set
1185                 {
1186                     _key = value;
1187                 }
1188             }
1189         }
1190
1191         private event EventHandler<KeyEventArgs> _stageKeyHandler;
1192         private EventCallbackDelegateType1 _stageKeyCallbackDelegate;
1193
1194         /// <summary>
1195         /// This event is emitted when the key event is received.
1196         /// </summary>
1197         /// <since_tizen> 3 </since_tizen>
1198         public event EventHandler<KeyEventArgs> KeyEvent
1199         {
1200             add
1201             {
1202                 if (_stageKeyHandler == null)
1203                 {
1204                     _stageKeyCallbackDelegate = OnStageKey;
1205                     KeyEventSignal().Connect(_stageKeyCallbackDelegate);
1206                 }
1207                 _stageKeyHandler += value;
1208             }
1209             remove
1210             {
1211                 _stageKeyHandler -= value;
1212                 if (_stageKeyHandler == null && KeyEventSignal().Empty() == false)
1213                 {
1214                     KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
1215                 }
1216             }
1217         }
1218
1219         // Callback for Stage KeyEventsignal
1220         private void OnStageKey(IntPtr data)
1221         {
1222             KeyEventArgs e = new KeyEventArgs();
1223
1224             if (data != null)
1225             {
1226                 e.Key = Tizen.NUI.Key.GetKeyFromPtr(data);
1227             }
1228
1229             if (_stageKeyHandler != null)
1230             {
1231                 //here we send all data to user event handlers
1232                 _stageKeyHandler(this, e);
1233             }
1234         }
1235
1236
1237         private event EventHandler _stageEventProcessingFinishedEventHandler;
1238         private EventCallbackDelegateType0 _stageEventProcessingFinishedEventCallbackDelegate;
1239
1240         internal event EventHandler EventProcessingFinished
1241         {
1242             add
1243             {
1244                 if (_stageEventProcessingFinishedEventHandler == null)
1245                 {
1246                     _stageEventProcessingFinishedEventCallbackDelegate = OnEventProcessingFinished;
1247                     EventProcessingFinishedSignal().Connect(_stageEventProcessingFinishedEventCallbackDelegate);
1248                 }
1249                 _stageEventProcessingFinishedEventHandler += value;
1250
1251             }
1252             remove
1253             {
1254                 _stageEventProcessingFinishedEventHandler -= value;
1255                 if (_stageEventProcessingFinishedEventHandler == null && EventProcessingFinishedSignal().Empty() == false)
1256                 {
1257                     EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
1258                 }
1259             }
1260         }
1261
1262         // Callback for Stage EventProcessingFinishedSignal
1263         private void OnEventProcessingFinished()
1264         {
1265             if (_stageEventProcessingFinishedEventHandler != null)
1266             {
1267                 _stageEventProcessingFinishedEventHandler(this, null);
1268             }
1269         }
1270
1271
1272         private EventHandler _stageContextLostEventHandler;
1273         private EventCallbackDelegateType0 _stageContextLostEventCallbackDelegate;
1274
1275         internal event EventHandler ContextLost
1276         {
1277             add
1278             {
1279                 if (_stageContextLostEventHandler == null)
1280                 {
1281                     _stageContextLostEventCallbackDelegate = OnContextLost;
1282                     ContextLostSignal().Connect(_stageContextLostEventCallbackDelegate);
1283                 }
1284                 _stageContextLostEventHandler += value;
1285             }
1286             remove
1287             {
1288                 _stageContextLostEventHandler -= value;
1289                 if (_stageContextLostEventHandler == null && ContextLostSignal().Empty() == false)
1290                 {
1291                     ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
1292                 }
1293             }
1294         }
1295
1296         // Callback for Stage ContextLostSignal
1297         private void OnContextLost()
1298         {
1299             if (_stageContextLostEventHandler != null)
1300             {
1301                 _stageContextLostEventHandler(this, null);
1302             }
1303         }
1304
1305
1306         private EventHandler _stageContextRegainedEventHandler;
1307         private EventCallbackDelegateType0 _stageContextRegainedEventCallbackDelegate;
1308
1309         internal event EventHandler ContextRegained
1310         {
1311             add
1312             {
1313                 if (_stageContextRegainedEventHandler == null)
1314                 {
1315                     _stageContextRegainedEventCallbackDelegate = OnContextRegained;
1316                     ContextRegainedSignal().Connect(_stageContextRegainedEventCallbackDelegate);
1317                 }
1318                 _stageContextRegainedEventHandler += value;
1319             }
1320             remove
1321             {
1322                 _stageContextRegainedEventHandler -= value;
1323                 if (_stageContextRegainedEventHandler == null && ContextRegainedSignal().Empty() == false)
1324                 {
1325                     this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
1326                 }
1327             }
1328         }
1329
1330         // Callback for Stage ContextRegainedSignal
1331         private void OnContextRegained()
1332         {
1333             if (_stageContextRegainedEventHandler != null)
1334             {
1335                 _stageContextRegainedEventHandler(this, null);
1336             }
1337         }
1338
1339
1340         private EventHandler _stageSceneCreatedEventHandler;
1341         private EventCallbackDelegateType0 _stageSceneCreatedEventCallbackDelegate;
1342
1343         internal event EventHandler SceneCreated
1344         {
1345             add
1346             {
1347                 if (_stageSceneCreatedEventHandler == null)
1348                 {
1349                     _stageSceneCreatedEventCallbackDelegate = OnSceneCreated;
1350                     SceneCreatedSignal().Connect(_stageSceneCreatedEventCallbackDelegate);
1351                 }
1352                 _stageSceneCreatedEventHandler += value;
1353             }
1354             remove
1355             {
1356                 _stageSceneCreatedEventHandler -= value;
1357                 if (_stageSceneCreatedEventHandler == null && SceneCreatedSignal().Empty() == false)
1358                 {
1359                     SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
1360                 }
1361             }
1362         }
1363
1364         // Callback for Stage SceneCreatedSignal
1365         private void OnSceneCreated()
1366         {
1367             if (_stageSceneCreatedEventHandler != null)
1368             {
1369                 _stageSceneCreatedEventHandler(this, null);
1370             }
1371         }
1372
1373         /// <summary>
1374         /// This resized event arguments.
1375         /// </summary>
1376         /// <since_tizen> 3 </since_tizen>
1377         public class ResizedEventArgs : EventArgs
1378         {
1379             Size2D _windowSize;
1380
1381             /// <summary>
1382             /// This window size.
1383             /// </summary>
1384             /// <since_tizen> 4 </since_tizen>
1385             public Size2D WindowSize
1386             {
1387                 get
1388                 {
1389                     return _windowSize;
1390                 }
1391                 set
1392                 {
1393                     _windowSize = value;
1394                 }
1395             }
1396         }
1397
1398         private WindowResizedEventCallbackType _windowResizedEventCallback;
1399         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1400         private delegate void WindowResizedEventCallbackType(IntPtr windowSize);
1401         private event EventHandler<ResizedEventArgs> _windowResizedEventHandler;
1402
1403         /// <summary>
1404         /// This event is emitted when the window resized.
1405         /// </summary>
1406         /// <since_tizen> 3 </since_tizen>
1407         public event EventHandler<ResizedEventArgs> Resized
1408         {
1409             add
1410             {
1411                 if (_windowResizedEventHandler == null)
1412                 {
1413                     _windowResizedEventCallback = OnResized;
1414                     ResizedSignal().Connect(_windowResizedEventCallback);
1415                 }
1416
1417                 _windowResizedEventHandler += value;
1418             }
1419             remove
1420             {
1421                 _windowResizedEventHandler -= value;
1422
1423                 if (_windowResizedEventHandler == null && ResizedSignal().Empty() == false && _windowResizedEventCallback != null)
1424                 {
1425                     ResizedSignal().Disconnect(_windowResizedEventCallback);
1426                 }
1427             }
1428         }
1429
1430         private void OnResized(IntPtr windowSize)
1431         {
1432             ResizedEventArgs e = new ResizedEventArgs();
1433             var val = new Uint16Pair(windowSize, false);
1434             e.WindowSize = new Size2D(val.GetWidth(), val.GetHeight());
1435             val.Dispose();
1436
1437             if (_windowResizedEventHandler != null)
1438             {
1439                 _windowResizedEventHandler(this, e);
1440             }
1441         }
1442
1443         internal void SetWindowSize(Size2D size)
1444         {
1445             var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1446             NDalicManualPINVOKE.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1447
1448             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1449         }
1450
1451         internal Size2D GetWindowSize()
1452         {
1453             var val = new Uint16Pair(NDalicManualPINVOKE.GetSize(swigCPtr), false);
1454             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1455
1456             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1457             return ret;
1458         }
1459
1460         internal void SetPosition(Position2D position)
1461         {
1462             var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1463             NDalicManualPINVOKE.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1464
1465             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1466         }
1467
1468         internal Position2D GetPosition()
1469         {
1470             var val = new Uint16Pair(NDalicManualPINVOKE.GetPosition(swigCPtr), true);
1471             Position2D ret = new Position2D(val.GetX(), val.GetY());
1472
1473             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1474             return ret;
1475         }
1476
1477         /// <summary>
1478         /// Sets whether the window is transparent or not.
1479         /// </summary>
1480         /// <param name="transparent">Whether the window is transparent.</param>
1481         /// <since_tizen> 5 </since_tizen>
1482         /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
1483         [EditorBrowsable(EditorBrowsableState.Never)]
1484         public void SetTransparency(bool transparent) {
1485             NDalicManualPINVOKE.SetTransparency(swigCPtr, transparent);
1486             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1487         }
1488
1489         /// <summary>
1490         /// The window size property (read-only).
1491         /// </summary>
1492         /// <since_tizen> 3 </since_tizen>
1493         public Size2D Size
1494         {
1495             get
1496             {
1497                 Size2D ret = GetSize();
1498                 return ret;
1499             }
1500         }
1501
1502         /// <summary>
1503         /// The background color property.
1504         /// </summary>
1505         /// <since_tizen> 3 </since_tizen>
1506         public Color BackgroundColor
1507         {
1508             set
1509             {
1510                 SetBackgroundColor(value);
1511             }
1512             get
1513             {
1514                 Color ret = GetBackgroundColor();
1515                 return ret;
1516             }
1517         }
1518
1519         /// <summary>
1520         /// The DPI property (read-only).<br />
1521         /// Retrieves the DPI of the display device to which the Window is connected.<br />
1522         /// </summary>
1523         /// <since_tizen> 3 </since_tizen>
1524         public Vector2 Dpi
1525         {
1526             get
1527             {
1528                 return GetDpi();
1529             }
1530         }
1531
1532         /// <summary>
1533         /// The layer count property (read-only).<br />
1534         /// Queries the number of on-Window layers.<br />
1535         /// </summary>
1536         /// <since_tizen> 3 </since_tizen>
1537         public uint LayerCount
1538         {
1539             get
1540             {
1541                 return GetLayerCount();
1542             }
1543         }
1544
1545
1546         /// <summary>
1547         /// Adds a layer to the stage.
1548         /// </summary>
1549         /// <param name="layer">Layer to add.</param>
1550         /// <since_tizen> 3 </since_tizen>
1551         public void AddLayer(Layer layer)
1552         {
1553             NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
1554             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1555
1556             LayersChildren.Add(layer);
1557         }
1558
1559         /// <summary>
1560         /// Removes a layer from the stage.
1561         /// </summary>
1562         /// <param name="layer">Layer to remove.</param>
1563         /// <since_tizen> 3 </since_tizen>
1564         public void RemoveLayer(Layer layer)
1565         {
1566             NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
1567             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1568
1569             LayersChildren.Remove(layer);
1570         }
1571
1572         /// <summary>
1573         /// Please do not use! this will be deprecated
1574         /// </summary>
1575         /// <since_tizen> 3 </since_tizen>
1576         [Obsolete("Please do not use! This will be deprecated! Please use FocusChangedEventArgs instead! " +
1577             "Like: " +
1578             "Window.Instance.FocusChanged = OnFocusChanged; " +
1579             "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
1580         [EditorBrowsable(EditorBrowsableState.Never)]
1581         public class WindowFocusChangedEventArgs : EventArgs
1582         {
1583             /// <summary>
1584             /// Please do not use! this will be deprecated
1585             /// </summary>
1586             /// <since_tizen> 3 </since_tizen>
1587             public bool FocusGained
1588             {
1589                 get;
1590                 set;
1591             }
1592         }
1593
1594         private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback2;
1595         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1596         private delegate void WindowFocusChangedEventCallbackType2(bool focusGained);
1597         private event EventHandler<WindowFocusChangedEventArgs> _windowFocusChangedEventHandler2;
1598
1599         /// <summary>
1600         /// Please do not use! this will be deprecated. Please use 'FocusChanged' event instead.
1601         /// </summary>
1602         /// <since_tizen> 3 </since_tizen>
1603         /// Please do not use! this will be deprecated!
1604         /// Instead please use FocusChanged.
1605         [Obsolete("Please do not use! This will be deprecated! Please use FocusChanged instead! " +
1606             "Like: " +
1607             "Window.Instance.FocusChanged = OnFocusChanged; " +
1608             "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
1609         [EditorBrowsable(EditorBrowsableState.Never)]
1610         public event EventHandler<WindowFocusChangedEventArgs> WindowFocusChanged
1611         {
1612             add
1613             {
1614                 if (_windowFocusChangedEventHandler2 == null)
1615                 {
1616                     _windowFocusChangedEventCallback2 = OnWindowFocusedChanged2;
1617                     WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback2);
1618                 }
1619
1620                 _windowFocusChangedEventHandler2 += value;
1621             }
1622             remove
1623             {
1624                 _windowFocusChangedEventHandler2 -= value;
1625
1626                 if (_windowFocusChangedEventHandler2 == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback2 != null)
1627                 {
1628                     WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
1629                 }
1630             }
1631         }
1632
1633         private void OnWindowFocusedChanged2(bool focusGained)
1634         {
1635             WindowFocusChangedEventArgs e = new WindowFocusChangedEventArgs();
1636
1637             e.FocusGained = focusGained;
1638
1639             if (_windowFocusChangedEventHandler2 != null)
1640             {
1641                 _windowFocusChangedEventHandler2(this, e);
1642             }
1643         }
1644
1645         /// <summary>
1646         /// Gets or sets a size of the window.
1647         /// </summary>
1648         /// <since_tizen> 4 </since_tizen>
1649         public Size2D WindowSize
1650         {
1651             get
1652             {
1653                 return GetWindowSize();
1654             }
1655             set
1656             {
1657                 SetWindowSize(value);
1658             }
1659         }
1660
1661         /// <summary>
1662         /// Gets or sets a position of the window.
1663         /// </summary>
1664         /// <since_tizen> 4 </since_tizen>
1665         public Position2D WindowPosition
1666         {
1667             get
1668             {
1669                 return GetPosition();
1670             }
1671             set
1672             {
1673                 SetPosition(value);
1674             }
1675         }
1676
1677         /// <summary>
1678         /// Feed a key-event into the window.
1679         /// </summary>
1680         /// <since_tizen> 4 </since_tizen>
1681         public static void FeedKeyEvent(Key keyEvent)
1682         {
1683             NDalicManualPINVOKE.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
1684             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1685         }
1686
1687         /// <summary>
1688         /// Allows at least one more render, even when paused.
1689         /// The window should be shown, not minimised.
1690         /// </summary>
1691         /// <since_tizen> 4 </since_tizen>
1692         public void RenderOnce()
1693         {
1694             NDalicManualPINVOKE.Window_RenderOnce(swigCPtr);
1695             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1696         }
1697
1698         /// <summary>
1699         /// Contains and encapsulates Native Window handle.
1700         /// </summary>
1701         /// <since_tizen> 4 </since_tizen>
1702         public class SafeNativeWindowHandle : SafeHandle
1703         {
1704             /// <summary>
1705             /// Contructor, Native window handle is set to handle.
1706             /// </summary>
1707             /// <since_tizen> 4 </since_tizen>
1708             public SafeNativeWindowHandle() : base(IntPtr.Zero, false)
1709             {
1710                 SetHandle(Tizen.NUI.Window.Instance.GetNativeWindowHandler());
1711             }
1712             /// <summary>
1713             /// Null check if the handle is valid or not.
1714             /// </summary>
1715             /// <since_tizen> 4 </since_tizen>
1716             public override bool IsInvalid
1717             {
1718                 get
1719                 {
1720                     return this.handle == IntPtr.Zero;
1721                 }
1722             }
1723             /// <summary>
1724             /// Release handle itself.
1725             /// </summary>
1726             /// <returns>true when released successfully.</returns>
1727             /// <since_tizen> 4 </since_tizen>
1728             protected override bool ReleaseHandle()
1729             {
1730                 return true;
1731             }
1732         }
1733
1734     }
1735 }