Merge "[NUI] add Timer debugging log temporarily, will be removed later" into rel...
[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.
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             if (depth < LayersChildren.Count)
734             {
735                 Layer ret = LayersChildren[Convert.ToInt32(depth)];
736                 return ret;
737             }
738             else
739             {
740                 return null;
741             }
742         }
743
744         internal Layer GetRootLayer()
745         {
746             // Window.IsInstalled() is actually true only when called from event thread and
747             // Core has been initialized, not when Stage is ready.
748             if (_rootLayer == null && Window.IsInstalled())
749             {
750                 _rootLayer = new Layer(NDalicPINVOKE.Stage_GetRootLayer(stageCPtr), true);
751                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
752                 LayersChildren.Add(_rootLayer);
753             }
754             return _rootLayer;
755         }
756
757         internal void SetBackgroundColor(Vector4 color)
758         {
759             NDalicPINVOKE.Stage_SetBackgroundColor(stageCPtr, Vector4.getCPtr(color));
760             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
761         }
762
763         internal Vector4 GetBackgroundColor()
764         {
765             Vector4 ret = new Vector4(NDalicPINVOKE.Stage_GetBackgroundColor(stageCPtr), true);
766             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
767             return ret;
768         }
769
770         internal Vector2 GetDpi()
771         {
772             Vector2 ret = new Vector2(NDalicPINVOKE.Stage_GetDpi(stageCPtr), true);
773             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
774             return ret;
775         }
776
777         internal ObjectRegistry GetObjectRegistry()
778         {
779             ObjectRegistry ret = new ObjectRegistry(NDalicPINVOKE.Stage_GetObjectRegistry(stageCPtr), true);
780             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
781             return ret;
782         }
783
784         /// <summary>
785         /// Keep rendering for at least the given amount of time.
786         /// </summary>
787         /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
788         /// <since_tizen> 3 </since_tizen>
789         public void KeepRendering(float durationSeconds)
790         {
791             NDalicPINVOKE.Stage_KeepRendering(stageCPtr, durationSeconds);
792             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
793         }
794
795         internal KeyEventSignal KeyEventSignal()
796         {
797             KeyEventSignal ret = new KeyEventSignal(NDalicPINVOKE.Stage_KeyEventSignal(stageCPtr), false);
798             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
799             return ret;
800         }
801
802         internal VoidSignal EventProcessingFinishedSignal()
803         {
804             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_EventProcessingFinishedSignal(stageCPtr), false);
805             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
806             return ret;
807         }
808
809         internal TouchSignal TouchSignal()
810         {
811             TouchSignal ret = new TouchSignal(NDalicPINVOKE.Stage_TouchSignal(stageCPtr), false);
812             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
813             return ret;
814         }
815
816         private StageWheelSignal WheelEventSignal()
817         {
818             StageWheelSignal ret = new StageWheelSignal(NDalicPINVOKE.Stage_WheelEventSignal(stageCPtr), false);
819             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
820             return ret;
821         }
822
823         internal VoidSignal ContextLostSignal()
824         {
825             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextLostSignal(stageCPtr), false);
826             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
827             return ret;
828         }
829
830         internal VoidSignal ContextRegainedSignal()
831         {
832             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextRegainedSignal(stageCPtr), false);
833             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
834             return ret;
835         }
836
837         internal VoidSignal SceneCreatedSignal()
838         {
839             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_SceneCreatedSignal(stageCPtr), false);
840             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
841             return ret;
842         }
843
844         internal ResizedSignal ResizedSignal()
845         {
846             ResizedSignal ret = new ResizedSignal(NDalicManualPINVOKE.Window_ResizedSignal(swigCPtr), false);
847             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
848             return ret;
849         }
850
851         internal static Vector4 DEFAULT_BACKGROUND_COLOR
852         {
853             get
854             {
855                 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEFAULT_BACKGROUND_COLOR_get();
856                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
857                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
858                 return ret;
859             }
860         }
861
862         internal static Vector4 DEBUG_BACKGROUND_COLOR
863         {
864             get
865             {
866                 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEBUG_BACKGROUND_COLOR_get();
867                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
868                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
869                 return ret;
870             }
871         }
872
873         private static readonly Window instance = Application.Instance.GetWindow();
874
875         /// <summary>
876         /// The stage instance property (read-only).<br />
877         /// Gets the current window.<br />
878         /// </summary>
879         /// <since_tizen> 3 </since_tizen>
880         public static Window Instance
881         {
882             get
883             {
884                 return instance;
885             }
886         }
887
888         /// <summary>
889         /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
890         /// This function can be used for following example scenarios: <br />
891         /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
892         /// </summary>
893         /// <param name="DaliKey">The key code to grab.</param>
894         /// <returns>True if the grab succeeds.</returns>
895         /// <since_tizen> 3 </since_tizen>
896         public bool GrabKeyTopmost(int DaliKey)
897         {
898             bool ret = NDalicManualPINVOKE.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
899             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
900             return ret;
901         }
902
903         /// <summary>
904         /// Ungrabs the key specified by a key for the window.<br />
905         /// 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 />
906         /// </summary>
907         /// <param name="DaliKey">The key code to ungrab.</param>
908         /// <returns>True if the ungrab succeeds.</returns>
909         /// <since_tizen> 3 </since_tizen>
910         public bool UngrabKeyTopmost(int DaliKey)
911         {
912             bool ret = NDalicManualPINVOKE.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
913             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
914             return ret;
915         }
916
917         /// <summary>
918         ///  Grabs the key specified by a key for a window in a GrabMode. <br />
919         ///  Details: This function can be used for following example scenarios: <br />
920         ///  - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
921         ///  - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
922         ///  - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
923         /// </summary>
924         /// <param name="DaliKey">The key code to grab.</param>
925         /// <param name="GrabMode">The grab mode for the key.</param>
926         /// <returns>True if the grab succeeds.</returns>
927         /// <since_tizen> 3 </since_tizen>
928         public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
929         {
930             bool ret = NDalicManualPINVOKE.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
931             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
932             return ret;
933         }
934
935         /// <summary>
936         /// Ungrabs the key specified by a key for a window.<br />
937         /// 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 />
938         /// </summary>
939         /// <param name="DaliKey">The key code to ungrab.</param>
940         /// <returns>True if the ungrab succeeds.</returns>
941         /// <since_tizen> 3 </since_tizen>
942         public bool UngrabKey(int DaliKey)
943         {
944             bool ret = NDalicManualPINVOKE.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
945             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
946             return ret;
947         }
948
949         internal System.IntPtr GetNativeWindowHandler()
950         {
951             System.IntPtr ret = NDalicManualPINVOKE.GetNativeWindowHandler(HandleRef.ToIntPtr(this.swigCPtr));
952             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
953             return ret;
954         }
955
956         /// <summary>
957         /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
958         /// </summary>
959         /// <since_tizen> 3 </since_tizen>
960         public enum WindowOrientation
961         {
962             /// <summary>
963             /// Portrait orientation. The height of the display area is greater than the width.
964             /// </summary>
965             /// <since_tizen> 3 </since_tizen>
966             Portrait = 0,
967             /// <summary>
968             /// Landscape orientation. A wide view area is needed.
969             /// </summary>
970             /// <since_tizen> 3 </since_tizen>
971             Landscape = 90,
972             /// <summary>
973             /// Portrait inverse orientation.
974             /// </summary>
975             /// <since_tizen> 3 </since_tizen>
976             PortraitInverse = 180,
977             /// <summary>
978             /// Landscape inverse orientation.
979             /// </summary>
980             /// <since_tizen> 3 </since_tizen>
981             LandscapeInverse = 270
982         }
983
984         /// <summary>
985         /// Enumeration for the key grab mode for platform-level APIs.
986         /// </summary>
987         /// <since_tizen> 3 </since_tizen>
988         public enum KeyGrabMode
989         {
990             /// <summary>
991             /// Grabs a key only when on the top of the grabbing-window stack mode.
992             /// </summary>
993             Topmost = 0,
994             /// <summary>
995             /// Grabs a key together with the other client window(s) mode.
996             /// </summary>
997             Shared,
998             /// <summary>
999             /// 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.
1000             /// </summary>
1001             OverrideExclusive,
1002             /// <summary>
1003             /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
1004             /// </summary>
1005             Exclusive
1006         };
1007
1008         /// <summary>
1009         /// Enumeration for opacity of the indicator.
1010         /// </summary>
1011         internal enum IndicatorBackgroundOpacity
1012         {
1013             Opaque = 100,
1014             Translucent = 50,
1015             Transparent = 0
1016         }
1017
1018         /// <summary>
1019         /// Enumeration for visible mode of the indicator.
1020         /// </summary>
1021         internal enum IndicatorVisibleMode
1022         {
1023             Invisible = 0,
1024             Visible = 1,
1025             Auto = 2
1026         }
1027
1028         /// <summary>
1029         /// The touch event argument.
1030         /// </summary>
1031         /// <since_tizen> 3 </since_tizen>
1032         public class TouchEventArgs : EventArgs
1033         {
1034             private Touch _touch;
1035
1036             /// <summary>
1037             /// Touch.
1038             /// </summary>
1039             /// <since_tizen> 3 </since_tizen>
1040             public Touch Touch
1041             {
1042                 get
1043                 {
1044                     return _touch;
1045                 }
1046                 set
1047                 {
1048                     _touch = value;
1049                 }
1050             }
1051         }
1052
1053         private event EventHandler<TouchEventArgs> _stageTouchHandler;
1054         private EventCallbackDelegateType1 _stageTouchCallbackDelegate;
1055
1056         /// <summary>
1057         /// This event is emitted when the screen is touched and when the touch ends.<br />
1058         /// If there are multiple touch points, then this will be emitted when the first touch occurs and
1059         /// then when the last finger is lifted.<br />
1060         /// An interrupted event will also be emitted (if it occurs).<br />
1061         /// </summary>
1062         /// <since_tizen> 3 </since_tizen>
1063         public event EventHandler<TouchEventArgs> TouchEvent
1064         {
1065             add
1066             {
1067                 lock (this)
1068                 {
1069                     _stageTouchHandler += value;
1070                     _stageTouchCallbackDelegate = OnStageTouch;
1071                     this.TouchSignal().Connect(_stageTouchCallbackDelegate);
1072                 }
1073             }
1074             remove
1075             {
1076                 lock (this)
1077                 {
1078                     if (_stageTouchHandler != null)
1079                     {
1080                         this.TouchSignal().Disconnect(_stageTouchCallbackDelegate);
1081                     }
1082                     _stageTouchHandler -= value;
1083                 }
1084             }
1085         }
1086
1087         private void OnStageTouch(IntPtr data)
1088         {
1089             TouchEventArgs e = new TouchEventArgs();
1090
1091             if (data != null)
1092             {
1093                 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(data);
1094             }
1095
1096             if (_stageTouchHandler != null)
1097             {
1098                 _stageTouchHandler(this, e);
1099             }
1100         }
1101
1102         /// <summary>
1103         /// Wheel event arguments.
1104         /// </summary>
1105         /// <since_tizen> 3 </since_tizen>
1106         public class WheelEventArgs : EventArgs
1107         {
1108             private Wheel _wheel;
1109
1110             /// <summary>
1111             /// Wheel.
1112             /// </summary>
1113             /// <since_tizen> 3 </since_tizen>
1114             public Wheel Wheel
1115             {
1116                 get
1117                 {
1118                     return _wheel;
1119                 }
1120                 set
1121                 {
1122                     _wheel = value;
1123                 }
1124             }
1125         }
1126
1127         private event EventHandler<WheelEventArgs> _stageWheelHandler;
1128         private EventCallbackDelegateType1 _stageWheelCallbackDelegate;
1129
1130         /// <summary>
1131         /// This event is emitted when the wheel event is received.
1132         /// </summary>
1133         /// <since_tizen> 3 </since_tizen>
1134         public event EventHandler<WheelEventArgs> WheelEvent
1135         {
1136             add
1137             {
1138                 if (_stageWheelHandler == null)
1139                 {
1140                     _stageWheelCallbackDelegate = OnStageWheel;
1141                     WheelEventSignal().Connect(_stageWheelCallbackDelegate);
1142                 }
1143                 _stageWheelHandler += value;
1144             }
1145             remove
1146             {
1147                 _stageWheelHandler -= value;
1148                 if (_stageWheelHandler == null && WheelEventSignal().Empty() == false)
1149                 {
1150                     WheelEventSignal().Disconnect(_stageWheelCallbackDelegate);
1151                 }
1152             }
1153         }
1154
1155         private void OnStageWheel(IntPtr data)
1156         {
1157             WheelEventArgs e = new WheelEventArgs();
1158
1159             if (data != null)
1160             {
1161                 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(data);
1162             }
1163
1164             if (_stageWheelHandler != null)
1165             {
1166                 _stageWheelHandler(this, e);
1167             }
1168         }
1169
1170         /// <summary>
1171         /// Key event arguments.
1172         /// </summary>
1173         /// <since_tizen> 3 </since_tizen>
1174         public class KeyEventArgs : EventArgs
1175         {
1176             private Key _key;
1177
1178             /// <summary>
1179             /// Key.
1180             /// </summary>
1181             /// <since_tizen> 3 </since_tizen>
1182             public Key Key
1183             {
1184                 get
1185                 {
1186                     return _key;
1187                 }
1188                 set
1189                 {
1190                     _key = value;
1191                 }
1192             }
1193         }
1194
1195         private event EventHandler<KeyEventArgs> _stageKeyHandler;
1196         private EventCallbackDelegateType1 _stageKeyCallbackDelegate;
1197
1198         /// <summary>
1199         /// This event is emitted when the key event is received.
1200         /// </summary>
1201         /// <since_tizen> 3 </since_tizen>
1202         public event EventHandler<KeyEventArgs> KeyEvent
1203         {
1204             add
1205             {
1206                 if (_stageKeyHandler == null)
1207                 {
1208                     _stageKeyCallbackDelegate = OnStageKey;
1209                     KeyEventSignal().Connect(_stageKeyCallbackDelegate);
1210                 }
1211                 _stageKeyHandler += value;
1212             }
1213             remove
1214             {
1215                 _stageKeyHandler -= value;
1216                 if (_stageKeyHandler == null && KeyEventSignal().Empty() == false)
1217                 {
1218                     KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
1219                 }
1220             }
1221         }
1222
1223         // Callback for Stage KeyEventsignal
1224         private void OnStageKey(IntPtr data)
1225         {
1226             KeyEventArgs e = new KeyEventArgs();
1227
1228             if (data != null)
1229             {
1230                 e.Key = Tizen.NUI.Key.GetKeyFromPtr(data);
1231             }
1232
1233             if (_stageKeyHandler != null)
1234             {
1235                 //here we send all data to user event handlers
1236                 _stageKeyHandler(this, e);
1237             }
1238         }
1239
1240
1241         private event EventHandler _stageEventProcessingFinishedEventHandler;
1242         private EventCallbackDelegateType0 _stageEventProcessingFinishedEventCallbackDelegate;
1243
1244         internal event EventHandler EventProcessingFinished
1245         {
1246             add
1247             {
1248                 if (_stageEventProcessingFinishedEventHandler == null)
1249                 {
1250                     _stageEventProcessingFinishedEventCallbackDelegate = OnEventProcessingFinished;
1251                     EventProcessingFinishedSignal().Connect(_stageEventProcessingFinishedEventCallbackDelegate);
1252                 }
1253                 _stageEventProcessingFinishedEventHandler += value;
1254
1255             }
1256             remove
1257             {
1258                 _stageEventProcessingFinishedEventHandler -= value;
1259                 if (_stageEventProcessingFinishedEventHandler == null && EventProcessingFinishedSignal().Empty() == false)
1260                 {
1261                     EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
1262                 }
1263             }
1264         }
1265
1266         // Callback for Stage EventProcessingFinishedSignal
1267         private void OnEventProcessingFinished()
1268         {
1269             if (_stageEventProcessingFinishedEventHandler != null)
1270             {
1271                 _stageEventProcessingFinishedEventHandler(this, null);
1272             }
1273         }
1274
1275
1276         private EventHandler _stageContextLostEventHandler;
1277         private EventCallbackDelegateType0 _stageContextLostEventCallbackDelegate;
1278
1279         internal event EventHandler ContextLost
1280         {
1281             add
1282             {
1283                 if (_stageContextLostEventHandler == null)
1284                 {
1285                     _stageContextLostEventCallbackDelegate = OnContextLost;
1286                     ContextLostSignal().Connect(_stageContextLostEventCallbackDelegate);
1287                 }
1288                 _stageContextLostEventHandler += value;
1289             }
1290             remove
1291             {
1292                 _stageContextLostEventHandler -= value;
1293                 if (_stageContextLostEventHandler == null && ContextLostSignal().Empty() == false)
1294                 {
1295                     ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
1296                 }
1297             }
1298         }
1299
1300         // Callback for Stage ContextLostSignal
1301         private void OnContextLost()
1302         {
1303             if (_stageContextLostEventHandler != null)
1304             {
1305                 _stageContextLostEventHandler(this, null);
1306             }
1307         }
1308
1309
1310         private EventHandler _stageContextRegainedEventHandler;
1311         private EventCallbackDelegateType0 _stageContextRegainedEventCallbackDelegate;
1312
1313         internal event EventHandler ContextRegained
1314         {
1315             add
1316             {
1317                 if (_stageContextRegainedEventHandler == null)
1318                 {
1319                     _stageContextRegainedEventCallbackDelegate = OnContextRegained;
1320                     ContextRegainedSignal().Connect(_stageContextRegainedEventCallbackDelegate);
1321                 }
1322                 _stageContextRegainedEventHandler += value;
1323             }
1324             remove
1325             {
1326                 _stageContextRegainedEventHandler -= value;
1327                 if (_stageContextRegainedEventHandler == null && ContextRegainedSignal().Empty() == false)
1328                 {
1329                     this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
1330                 }
1331             }
1332         }
1333
1334         // Callback for Stage ContextRegainedSignal
1335         private void OnContextRegained()
1336         {
1337             if (_stageContextRegainedEventHandler != null)
1338             {
1339                 _stageContextRegainedEventHandler(this, null);
1340             }
1341         }
1342
1343
1344         private EventHandler _stageSceneCreatedEventHandler;
1345         private EventCallbackDelegateType0 _stageSceneCreatedEventCallbackDelegate;
1346
1347         internal event EventHandler SceneCreated
1348         {
1349             add
1350             {
1351                 if (_stageSceneCreatedEventHandler == null)
1352                 {
1353                     _stageSceneCreatedEventCallbackDelegate = OnSceneCreated;
1354                     SceneCreatedSignal().Connect(_stageSceneCreatedEventCallbackDelegate);
1355                 }
1356                 _stageSceneCreatedEventHandler += value;
1357             }
1358             remove
1359             {
1360                 _stageSceneCreatedEventHandler -= value;
1361                 if (_stageSceneCreatedEventHandler == null && SceneCreatedSignal().Empty() == false)
1362                 {
1363                     SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
1364                 }
1365             }
1366         }
1367
1368         // Callback for Stage SceneCreatedSignal
1369         private void OnSceneCreated()
1370         {
1371             if (_stageSceneCreatedEventHandler != null)
1372             {
1373                 _stageSceneCreatedEventHandler(this, null);
1374             }
1375         }
1376
1377         /// <summary>
1378         /// This resized event arguments.
1379         /// </summary>
1380         /// <since_tizen> 3 </since_tizen>
1381         public class ResizedEventArgs : EventArgs
1382         {
1383             Size2D _windowSize;
1384
1385             /// <summary>
1386             /// This window size.
1387             /// </summary>
1388             /// <since_tizen> 4 </since_tizen>
1389             public Size2D WindowSize
1390             {
1391                 get
1392                 {
1393                     return _windowSize;
1394                 }
1395                 set
1396                 {
1397                     _windowSize = value;
1398                 }
1399             }
1400         }
1401
1402         private WindowResizedEventCallbackType _windowResizedEventCallback;
1403         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1404         private delegate void WindowResizedEventCallbackType(IntPtr windowSize);
1405         private event EventHandler<ResizedEventArgs> _windowResizedEventHandler;
1406
1407         /// <summary>
1408         /// This event is emitted when the window resized.
1409         /// </summary>
1410         /// <since_tizen> 3 </since_tizen>
1411         public event EventHandler<ResizedEventArgs> Resized
1412         {
1413             add
1414             {
1415                 if (_windowResizedEventHandler == null)
1416                 {
1417                     _windowResizedEventCallback = OnResized;
1418                     ResizedSignal().Connect(_windowResizedEventCallback);
1419                 }
1420
1421                 _windowResizedEventHandler += value;
1422             }
1423             remove
1424             {
1425                 _windowResizedEventHandler -= value;
1426
1427                 if (_windowResizedEventHandler == null && ResizedSignal().Empty() == false && _windowResizedEventCallback != null)
1428                 {
1429                     ResizedSignal().Disconnect(_windowResizedEventCallback);
1430                 }
1431             }
1432         }
1433
1434         private void OnResized(IntPtr windowSize)
1435         {
1436             ResizedEventArgs e = new ResizedEventArgs();
1437             var val = new Uint16Pair(windowSize, false);
1438             e.WindowSize = new Size2D(val.GetWidth(), val.GetHeight());
1439             val.Dispose();
1440
1441             if (_windowResizedEventHandler != null)
1442             {
1443                 _windowResizedEventHandler(this, e);
1444             }
1445         }
1446
1447         internal void SetWindowSize(Size2D size)
1448         {
1449             var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1450             NDalicManualPINVOKE.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1451
1452             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1453         }
1454
1455         internal Size2D GetWindowSize()
1456         {
1457             var val = new Uint16Pair(NDalicManualPINVOKE.GetSize(swigCPtr), false);
1458             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1459
1460             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1461             return ret;
1462         }
1463
1464         internal void SetPosition(Position2D position)
1465         {
1466             var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1467             NDalicManualPINVOKE.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1468
1469             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1470         }
1471
1472         internal Position2D GetPosition()
1473         {
1474             var val = new Uint16Pair(NDalicManualPINVOKE.GetPosition(swigCPtr), true);
1475             Position2D ret = new Position2D(val.GetX(), val.GetY());
1476
1477             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1478             return ret;
1479         }
1480
1481         /// <summary>
1482         /// Sets whether the window is transparent or not.
1483         /// </summary>
1484         /// <param name="transparent">Whether the window is transparent.</param>
1485         /// <since_tizen> 5 </since_tizen>
1486         /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
1487         [EditorBrowsable(EditorBrowsableState.Never)]
1488         public void SetTransparency(bool transparent) {
1489             NDalicManualPINVOKE.SetTransparency(swigCPtr, transparent);
1490             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1491         }
1492
1493         /// <summary>
1494         /// The window size property (read-only).
1495         /// </summary>
1496         /// <since_tizen> 3 </since_tizen>
1497         public Size2D Size
1498         {
1499             get
1500             {
1501                 Size2D ret = GetSize();
1502                 return ret;
1503             }
1504         }
1505
1506         /// <summary>
1507         /// The background color property.
1508         /// </summary>
1509         /// <since_tizen> 3 </since_tizen>
1510         public Color BackgroundColor
1511         {
1512             set
1513             {
1514                 SetBackgroundColor(value);
1515             }
1516             get
1517             {
1518                 Color ret = GetBackgroundColor();
1519                 return ret;
1520             }
1521         }
1522
1523         /// <summary>
1524         /// The DPI property (read-only).<br />
1525         /// Retrieves the DPI of the display device to which the Window is connected.<br />
1526         /// </summary>
1527         /// <since_tizen> 3 </since_tizen>
1528         public Vector2 Dpi
1529         {
1530             get
1531             {
1532                 return GetDpi();
1533             }
1534         }
1535
1536         /// <summary>
1537         /// The layer count property (read-only).<br />
1538         /// Queries the number of on-Window layers.<br />
1539         /// </summary>
1540         /// <since_tizen> 3 </since_tizen>
1541         public uint LayerCount
1542         {
1543             get
1544             {
1545                 return GetLayerCount();
1546             }
1547         }
1548
1549
1550         /// <summary>
1551         /// Adds a layer to the stage.
1552         /// </summary>
1553         /// <param name="layer">Layer to add.</param>
1554         /// <since_tizen> 3 </since_tizen>
1555         public void AddLayer(Layer layer)
1556         {
1557             NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
1558             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1559
1560             LayersChildren.Add(layer);
1561         }
1562
1563         /// <summary>
1564         /// Removes a layer from the stage.
1565         /// </summary>
1566         /// <param name="layer">Layer to remove.</param>
1567         /// <since_tizen> 3 </since_tizen>
1568         public void RemoveLayer(Layer layer)
1569         {
1570             NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
1571             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1572
1573             LayersChildren.Remove(layer);
1574         }
1575
1576         /// <summary>
1577         /// Please do not use! this will be deprecated
1578         /// </summary>
1579         /// <since_tizen> 3 </since_tizen>
1580         [Obsolete("Please do not use! This will be deprecated! Please use FocusChangedEventArgs instead! " +
1581             "Like: " +
1582             "Window.Instance.FocusChanged = OnFocusChanged; " +
1583             "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
1584         [EditorBrowsable(EditorBrowsableState.Never)]
1585         public class WindowFocusChangedEventArgs : EventArgs
1586         {
1587             /// <summary>
1588             /// Please do not use! this will be deprecated
1589             /// </summary>
1590             /// <since_tizen> 3 </since_tizen>
1591             public bool FocusGained
1592             {
1593                 get;
1594                 set;
1595             }
1596         }
1597
1598         private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback2;
1599         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1600         private delegate void WindowFocusChangedEventCallbackType2(bool focusGained);
1601         private event EventHandler<WindowFocusChangedEventArgs> _windowFocusChangedEventHandler2;
1602
1603         /// <summary>
1604         /// Please do not use! this will be deprecated. Please use 'FocusChanged' event instead.
1605         /// </summary>
1606         /// <since_tizen> 3 </since_tizen>
1607         /// Please do not use! this will be deprecated!
1608         /// Instead please use FocusChanged.
1609         [Obsolete("Please do not use! This will be deprecated! Please use FocusChanged instead! " +
1610             "Like: " +
1611             "Window.Instance.FocusChanged = OnFocusChanged; " +
1612             "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
1613         [EditorBrowsable(EditorBrowsableState.Never)]
1614         public event EventHandler<WindowFocusChangedEventArgs> WindowFocusChanged
1615         {
1616             add
1617             {
1618                 if (_windowFocusChangedEventHandler2 == null)
1619                 {
1620                     _windowFocusChangedEventCallback2 = OnWindowFocusedChanged2;
1621                     WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback2);
1622                 }
1623
1624                 _windowFocusChangedEventHandler2 += value;
1625             }
1626             remove
1627             {
1628                 _windowFocusChangedEventHandler2 -= value;
1629
1630                 if (_windowFocusChangedEventHandler2 == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback2 != null)
1631                 {
1632                     WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
1633                 }
1634             }
1635         }
1636
1637         private void OnWindowFocusedChanged2(bool focusGained)
1638         {
1639             WindowFocusChangedEventArgs e = new WindowFocusChangedEventArgs();
1640
1641             e.FocusGained = focusGained;
1642
1643             if (_windowFocusChangedEventHandler2 != null)
1644             {
1645                 _windowFocusChangedEventHandler2(this, e);
1646             }
1647         }
1648
1649         /// <summary>
1650         /// Gets or sets a size of the window.
1651         /// </summary>
1652         /// <since_tizen> 4 </since_tizen>
1653         public Size2D WindowSize
1654         {
1655             get
1656             {
1657                 return GetWindowSize();
1658             }
1659             set
1660             {
1661                 SetWindowSize(value);
1662             }
1663         }
1664
1665         /// <summary>
1666         /// Gets or sets a position of the window.
1667         /// </summary>
1668         /// <since_tizen> 4 </since_tizen>
1669         public Position2D WindowPosition
1670         {
1671             get
1672             {
1673                 return GetPosition();
1674             }
1675             set
1676             {
1677                 SetPosition(value);
1678             }
1679         }
1680
1681         /// <summary>
1682         /// Feed a key-event into the window.
1683         /// </summary>
1684         /// <param name="keyEvent">The key event to feed.</param>
1685         /// <since_tizen> 5 </since_tizen>
1686         [EditorBrowsable(EditorBrowsableState.Never)]
1687         public void FeedKey(Key keyEvent)
1688         {
1689             NDalicManualPINVOKE.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
1690             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1691         }
1692
1693         /// <summary>
1694         /// Feed a key-event into the window.
1695         /// </summary>
1696         /// <param name="keyEvent">The key event to feed.</param>
1697         /// <since_tizen> 4 </since_tizen>
1698         [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
1699         public static void FeedKeyEvent(Key keyEvent)
1700         {
1701             NDalicManualPINVOKE.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
1702             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1703         }
1704
1705         /// <summary>
1706         /// Allows at least one more render, even when paused.
1707         /// The window should be shown, not minimised.
1708         /// </summary>
1709         /// <since_tizen> 4 </since_tizen>
1710         public void RenderOnce()
1711         {
1712             NDalicManualPINVOKE.Window_RenderOnce(swigCPtr);
1713             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1714         }
1715
1716         /// <summary>
1717         /// Contains and encapsulates Native Window handle.
1718         /// </summary>
1719         /// <since_tizen> 4 </since_tizen>
1720         public class SafeNativeWindowHandle : SafeHandle
1721         {
1722             /// <summary>
1723             /// Contructor, Native window handle is set to handle.
1724             /// </summary>
1725             /// <since_tizen> 4 </since_tizen>
1726             public SafeNativeWindowHandle() : base(IntPtr.Zero, false)
1727             {
1728                 SetHandle(Tizen.NUI.Window.Instance.GetNativeWindowHandler());
1729             }
1730             /// <summary>
1731             /// Null check if the handle is valid or not.
1732             /// </summary>
1733             /// <since_tizen> 4 </since_tizen>
1734             public override bool IsInvalid
1735             {
1736                 get
1737                 {
1738                     return this.handle == IntPtr.Zero;
1739                 }
1740             }
1741             /// <summary>
1742             /// Release handle itself.
1743             /// </summary>
1744             /// <returns>true when released successfully.</returns>
1745             /// <since_tizen> 4 </since_tizen>
1746             protected override bool ReleaseHandle()
1747             {
1748                 return true;
1749             }
1750         }
1751
1752     }
1753 }