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