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