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