[NUI] Append window move event
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Window / WindowEvent.cs
1 /*
2  * Copyright(c) 2021 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
18 using System;
19 using System.ComponentModel;
20 using System.Runtime.InteropServices;
21 using Tizen.NUI.BaseComponents;
22 using System.Collections.Generic;
23
24 namespace Tizen.NUI
25 {
26     /// <summary>
27     /// The window class is used internally for drawing.<br />
28     /// The window has an orientation and indicator properties.<br />
29     /// </summary>
30     /// <since_tizen> 3 </since_tizen>
31     public partial class Window
32     {
33         private WindowFocusChangedEventCallbackType windowFocusChangedEventCallback;
34         private RootLayerTouchDataCallbackType rootLayerTouchDataCallback;
35         private RootLayerTouchDataCallbackType rootLayerInterceptTouchDataCallback;
36         private WheelEventCallbackType wheelEventCallback;
37         private EventCallbackDelegateType1 stageKeyCallbackDelegate;
38         private InterceptKeyEventDelegateType stageInterceptKeyCallbackDelegate;
39         private EventCallbackDelegateType0 stageEventProcessingFinishedEventCallbackDelegate;
40         private EventHandler stageContextLostEventHandler;
41         private EventCallbackDelegateType0 stageContextLostEventCallbackDelegate;
42         private EventHandler stageContextRegainedEventHandler;
43         private EventCallbackDelegateType0 stageContextRegainedEventCallbackDelegate;
44         private EventHandler stageSceneCreatedEventHandler;
45         private EventCallbackDelegateType0 stageSceneCreatedEventCallbackDelegate;
46         private WindowResizeEventCallbackType windowResizeEventCallback;
47         private WindowFocusChangedEventCallbackType windowFocusChangedEventCallback2;
48         private TransitionEffectEventCallbackType transitionEffectEventCallback;
49         private WindowTransitionEffectSignal transitionEffectSignal;
50         private MovedEventCallbackType movedEventCallback;
51         private WindowMovedSignal movedSignal;
52         private KeyboardRepeatSettingsChangedEventCallbackType keyboardRepeatSettingsChangedEventCallback;
53         private KeyboardRepeatSettingsChangedSignal keyboardRepeatSettingsChangedSignal;
54         private WindowFocusSignalType windowFocusChangedSignal;
55         private WindowFocusSignalType windowFocusChangedSignal2;
56         private TouchDataSignal touchDataSignal;
57         private TouchSignal touchSignal;
58         private WheelSignal wheelSignal;
59         private StageWheelSignal stageWheelSignal;
60         private KeyEventSignal keyEventSignal;
61         private KeyEventSignal interceptKeyEventSignal;
62         private VoidSignal sceneCreatedSignal;
63         private ResizeSignal resizeSignal;
64         private VoidSignal eventProcessingFinishedSignal;
65         private VoidSignal contextLostSignal;
66         private VoidSignal contextRegainedSignal;
67         private AuxiliaryMessageEventCallbackType auxiliaryMessageEventCallback;
68         private TouchDataSignal interceptTouchDataSignal;
69         private TouchSignal interceptTouchSignal;
70
71         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
72         private delegate void WindowFocusChangedEventCallbackType(IntPtr window, bool focusGained);
73         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
74         private delegate bool RootLayerTouchDataCallbackType(IntPtr view, IntPtr touchData);
75         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
76         private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
77         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
78         private delegate void WindowResizeEventCallbackType(IntPtr window, IntPtr windowSize);
79         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
80         private delegate void WindowFocusChangedEventCallbackType2(IntPtr window, bool focusGained);
81         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
82         private delegate void TransitionEffectEventCallbackType(IntPtr window, int state, int type);
83         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
84         private delegate void MovedEventCallbackType(IntPtr window, IntPtr position);
85         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
86         private delegate void KeyboardRepeatSettingsChangedEventCallbackType();
87         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
88         private delegate void AuxiliaryMessageEventCallbackType(IntPtr kData, IntPtr vData, IntPtr optionsArray);
89         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
90         private delegate bool InterceptKeyEventDelegateType(IntPtr arg1);
91
92         /// <summary>
93         /// FocusChanged event.
94         /// </summary>
95         /// <since_tizen> 3 </since_tizen>
96         public event EventHandler<FocusChangedEventArgs> FocusChanged
97         {
98             add
99             {
100                 if (windowFocusChangedEventHandler == null)
101                 {
102                     windowFocusChangedEventCallback = OnWindowFocusedChanged;
103                     windowFocusChangedSignal = WindowFocusChangedSignal();
104                     windowFocusChangedSignal?.Connect(windowFocusChangedEventCallback);
105                 }
106
107                 windowFocusChangedEventHandler += value;
108             }
109             remove
110             {
111                 windowFocusChangedEventHandler -= value;
112
113                 if (windowFocusChangedEventHandler == null && windowFocusChangedSignal?.Empty() == false && windowFocusChangedEventCallback != null)
114                 {
115                     windowFocusChangedSignal?.Disconnect(windowFocusChangedEventCallback);
116                     if (windowFocusChangedSignal?.Empty() == true)
117                     {
118                         windowFocusChangedEventCallback = null;
119                     }
120                 }
121             }
122         }
123
124         /// <summary>
125         /// Emits the event when the screen is touched and when the touch ends.<br />
126         /// If there are multiple touch points then it is emitted when the first touch occurs and
127         /// when the last finger is lifted too.<br />
128         /// Even though incoming events are interrupted, the event occurs.<br />
129         /// </summary>
130         /// <since_tizen> 3 </since_tizen>
131         public event EventHandler<TouchEventArgs> TouchEvent
132         {
133             add
134             {
135                 if (rootLayerTouchDataEventHandler == null)
136                 {
137                     rootLayerTouchDataCallback = OnWindowTouch;
138                     touchDataSignal = this.TouchDataSignal();
139                     touchDataSignal?.Connect(rootLayerTouchDataCallback);
140                 }
141                 rootLayerTouchDataEventHandler += value;
142             }
143             remove
144             {
145                 rootLayerTouchDataEventHandler -= value;
146                 touchSignal = TouchSignal();
147                 if (rootLayerTouchDataEventHandler == null && touchSignal?.Empty() == false && rootLayerTouchDataCallback != null)
148                 {
149                     touchDataSignal?.Disconnect(rootLayerTouchDataCallback);
150                     if (touchDataSignal?.Empty() == true)
151                     {
152                         rootLayerTouchDataCallback = null;
153                     }
154                 }
155             }
156         }
157
158         /// <summary>
159         /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
160         /// The touched signal is emitted when the touch input is received.<br />
161         /// This can receive touch events before child. <br />
162         /// If it returns false, the child can receive the touch event. If it returns true, the touch event is intercepted. So child cannot receive touch event.<br />
163         /// </summary>
164         [EditorBrowsable(EditorBrowsableState.Never)]
165         public event ReturnTypeEventHandler<object, TouchEventArgs, bool> InterceptTouchEvent
166         {
167             add
168             {
169                 if (rootLayerInterceptTouchDataEventHandler == null)
170                 {
171                     rootLayerInterceptTouchDataCallback = OnWindowInterceptTouch;
172                     interceptTouchDataSignal = this.InterceptTouchDataSignal();
173                     interceptTouchDataSignal?.Connect(rootLayerInterceptTouchDataCallback);
174                 }
175                 rootLayerInterceptTouchDataEventHandler += value;
176             }
177             remove
178             {
179                 rootLayerInterceptTouchDataEventHandler -= value;
180                 interceptTouchSignal = TouchSignal();
181                 if (rootLayerInterceptTouchDataEventHandler == null && interceptTouchSignal?.Empty() == false && rootLayerInterceptTouchDataCallback != null)
182                 {
183                     interceptTouchDataSignal?.Disconnect(rootLayerInterceptTouchDataCallback);
184                     if (interceptTouchDataSignal?.Empty() == true)
185                     {
186                         rootLayerInterceptTouchDataCallback = null;
187                     }
188                 }
189             }
190         }
191
192         /// <summary>
193         /// Emits the event when the wheel event is received.
194         /// </summary>
195         /// <since_tizen> 3 </since_tizen>
196         public event EventHandler<WheelEventArgs> WheelEvent
197         {
198             add
199             {
200                 if (stageWheelHandler == null)
201                 {
202                     wheelEventCallback = OnStageWheel;
203                     wheelSignal = WheelEventSignal();
204                     wheelSignal?.Connect(wheelEventCallback);
205                 }
206                 stageWheelHandler += value;
207
208                 if (DetentEventHandler == null)
209                 {
210                     DetentEventCallback = OnDetentEvent;
211                     stageWheelSignal = StageWheelEventSignal();
212                     stageWheelSignal?.Connect(DetentEventCallback);
213                 }
214                 DetentEventHandler += value;
215             }
216             remove
217             {
218                 stageWheelHandler -= value;
219                 if (stageWheelHandler == null && wheelSignal?.Empty() == false)
220                 {
221                     wheelSignal?.Disconnect(wheelEventCallback);
222                     if (wheelSignal?.Empty() == true)
223                     {
224                         wheelEventCallback = null;
225                     }
226                 }
227
228                 DetentEventHandler -= value;
229                 if (DetentEventHandler == null && stageWheelSignal?.Empty() == false)
230                 {
231                     stageWheelSignal?.Disconnect(DetentEventCallback);
232                     if (stageWheelSignal?.Empty() == true)
233                     {
234                         DetentEventCallback = null;
235                     }
236                 }
237             }
238         }
239
240         /// <summary>
241         /// Emits the event when the key event is received.
242         /// </summary>
243         /// <since_tizen> 3 </since_tizen>
244         public event EventHandler<KeyEventArgs> KeyEvent
245         {
246             add
247             {
248                 if (stageKeyHandler == null)
249                 {
250                     stageKeyCallbackDelegate = OnStageKey;
251                     keyEventSignal = KeyEventSignal();
252                     keyEventSignal?.Connect(stageKeyCallbackDelegate);
253                 }
254                 stageKeyHandler += value;
255             }
256             remove
257             {
258                 stageKeyHandler -= value;
259                 if (stageKeyHandler == null && keyEventSignal?.Empty() == false)
260                 {
261                     keyEventSignal?.Disconnect(stageKeyCallbackDelegate);
262                     if (keyEventSignal?.Empty() == true)
263                     {
264                         stageKeyCallbackDelegate = null;
265                     }
266                 }
267             }
268         }
269
270         /// <summary>
271         /// Intercepts KeyEvents in the window before dispatching KeyEvents to the child.<br />
272         /// If it returns true(consumed), no KeyEvent is delivered to the child.
273         /// </summary>
274         [EditorBrowsable(EditorBrowsableState.Never)]
275         public event ReturnTypeEventHandler<object, KeyEventArgs, bool> InterceptKeyEvent
276         {
277             add
278             {
279                 if (stageInterceptKeyHandler == null)
280                 {
281                     stageInterceptKeyCallbackDelegate = OnStageInterceptKey;
282                     interceptKeyEventSignal = InterceptKeyEventSignal();
283                     interceptKeyEventSignal?.Connect(stageInterceptKeyCallbackDelegate);
284                 }
285                 stageInterceptKeyHandler += value;
286             }
287             remove
288             {
289                 stageInterceptKeyHandler -= value;
290                 if (stageInterceptKeyHandler == null && interceptKeyEventSignal?.Empty() == false)
291                 {
292                     interceptKeyEventSignal?.Disconnect(stageInterceptKeyCallbackDelegate);
293                     if (interceptKeyEventSignal?.Empty() == true)
294                     {
295                         stageInterceptKeyCallbackDelegate = null;
296                     }
297                 }
298             }
299         }
300
301
302         /// <summary>
303         /// Emits the event when the window resized.
304         /// </summary>
305         /// <since_tizen> 3 </since_tizen>
306         public event EventHandler<ResizedEventArgs> Resized
307         {
308             add
309             {
310                 if (windowResizeEventHandler == null)
311                 {
312                     windowResizeEventCallback = OnResized;
313                     resizeSignal = ResizeSignal();
314                     resizeSignal?.Connect(windowResizeEventCallback);
315                 }
316
317                 windowResizeEventHandler += value;
318             }
319             remove
320             {
321                 windowResizeEventHandler -= value;
322
323                 if (windowResizeEventHandler == null && resizeSignal?.Empty() == false && windowResizeEventCallback != null)
324                 {
325                     resizeSignal?.Disconnect(windowResizeEventCallback);
326                     if (resizeSignal?.Empty() == true)
327                     {
328                         windowResizeEventCallback = null;
329                     }
330                 }
331             }
332         }
333
334         /// <summary>
335         /// Do not use this, that will be deprecated. Use 'FocusChanged' event instead.
336         /// </summary>
337         /// <since_tizen> 3 </since_tizen>
338         /// Do not use this, that will be deprecated.
339         /// Instead Use FocusChanged.
340         [Obsolete("Do not use this, that will be deprecated. Use FocusChanged instead. " +
341             "Like: " +
342             "NUIApplication.GetDefaultWindow().FocusChanged = OnFocusChanged; " +
343             "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
344         [EditorBrowsable(EditorBrowsableState.Never)]
345         public event EventHandler<FocusChangedEventArgs> WindowFocusChanged
346         {
347             add
348             {
349                 if (windowFocusChangedEventHandler2 == null)
350                 {
351                     windowFocusChangedEventCallback2 = OnWindowFocusedChanged2;
352                     windowFocusChangedSignal2 = WindowFocusChangedSignal();
353                     windowFocusChangedSignal2?.Connect(windowFocusChangedEventCallback2);
354                 }
355
356                 windowFocusChangedEventHandler2 += value;
357             }
358             remove
359             {
360                 windowFocusChangedEventHandler2 -= value;
361
362                 if (windowFocusChangedEventHandler2 == null && windowFocusChangedSignal2?.Empty() == false && windowFocusChangedEventCallback2 != null)
363                 {
364                     windowFocusChangedSignal2?.Disconnect(windowFocusChangedEventCallback2);
365                     if (windowFocusChangedSignal2?.Empty() == true)
366                     {
367                         windowFocusChangedEventCallback2 = null;
368                     }
369                 }
370             }
371         }
372
373         /// <summary>
374         /// EffectStart
375         /// </summary>
376         [EditorBrowsable(EditorBrowsableState.Never)]
377         public event EventHandler<TransitionEffectEventArgs> TransitionEffect
378         {
379             add
380             {
381                 if (transitionEffectHandler == null)
382                 {
383                     transitionEffectEventCallback = OnTransitionEffect;
384                     TransitionEffectEventSignal().Connect(transitionEffectEventCallback);
385                 }
386                 transitionEffectHandler += value;
387             }
388             remove
389             {
390                 transitionEffectHandler -= value;
391                 if (transitionEffectHandler == null && TransitionEffectEventSignal().Empty() == false)
392                 {
393                     TransitionEffectEventSignal().Disconnect(transitionEffectEventCallback);
394                     if (TransitionEffectEventSignal().Empty() == true)
395                     {
396                         transitionEffectEventCallback = null;
397                     }
398                 }
399             }
400         }
401
402         /// <summary>
403         /// MovedEvent
404         /// </summary>
405         [EditorBrowsable(EditorBrowsableState.Never)]
406         public event EventHandler<WindowMovedEventArgs> Moved
407         {
408             add
409             {
410                 if (movedHandler == null)
411                 {
412                     movedEventCallback = OnMoved;
413                     MovedEventSignal().Connect(movedEventCallback);
414                 }
415                 movedHandler += value;
416             }
417             remove
418             {
419                 movedHandler -= value;
420                 if (movedHandler == null && MovedEventSignal().Empty() == false)
421                 {
422                     MovedEventSignal().Disconnect(movedEventCallback);
423                     if (MovedEventSignal().Empty() == true)
424                     {
425                         movedEventCallback = null;
426                     }
427                 }
428             }
429         }
430
431         /// <summary>
432         /// Keyboard Repeat Settings Changed
433         /// </summary>
434         [EditorBrowsable(EditorBrowsableState.Never)]
435         public event EventHandler KeyboardRepeatSettingsChanged
436         {
437             add
438             {
439                 if (keyboardRepeatSettingsChangedHandler == null)
440                 {
441                     keyboardRepeatSettingsChangedEventCallback = OnKeyboardRepeatSettingsChanged;
442                     KeyboardRepeatSettingsChangedEventSignal().Connect(keyboardRepeatSettingsChangedEventCallback);
443                 }
444                 keyboardRepeatSettingsChangedHandler += value;
445             }
446             remove
447             {
448                 keyboardRepeatSettingsChangedHandler -= value;
449                 if (keyboardRepeatSettingsChangedHandler == null && KeyboardRepeatSettingsChangedEventSignal().Empty() == false)
450                 {
451                     KeyboardRepeatSettingsChangedEventSignal().Disconnect(keyboardRepeatSettingsChangedEventCallback);
452                     if (KeyboardRepeatSettingsChangedEventSignal().Empty() == true)
453                     {
454                         keyboardRepeatSettingsChangedEventCallback = null;
455                     }
456                 }
457             }
458         }
459
460         /// <summary>
461         /// ViewAdded will be triggered when the view added on Window
462         /// </summary>
463         /// <since_tizen> 6 </since_tizen>
464         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
465         [EditorBrowsable(EditorBrowsableState.Never)]
466         public event EventHandler ViewAdded;
467         private event EventHandler<FocusChangedEventArgs> windowFocusChangedEventHandler;
468         private event EventHandler<TouchEventArgs> rootLayerTouchDataEventHandler;
469         private ReturnTypeEventHandler<object, TouchEventArgs, bool> rootLayerInterceptTouchDataEventHandler;
470         private event EventHandler<WheelEventArgs> stageWheelHandler;
471         private event EventHandler<KeyEventArgs> stageKeyHandler;
472         private ReturnTypeEventHandler<object, KeyEventArgs, bool> stageInterceptKeyHandler;
473         private event EventHandler stageEventProcessingFinishedEventHandler;
474         private event EventHandler<ResizedEventArgs> windowResizeEventHandler;
475         private event EventHandler<FocusChangedEventArgs> windowFocusChangedEventHandler2;
476         private event EventHandler<TransitionEffectEventArgs> transitionEffectHandler;
477         private event EventHandler<WindowMovedEventArgs> movedHandler;
478         private event EventHandler keyboardRepeatSettingsChangedHandler;
479         private event EventHandler<AuxiliaryMessageEventArgs> auxiliaryMessageEventHandler;
480
481         internal void SendViewAdded(View view)
482         {
483             ViewAdded?.Invoke(view, EventArgs.Empty);
484         }
485
486         internal event EventHandler EventProcessingFinished
487         {
488             add
489             {
490                 if (stageEventProcessingFinishedEventHandler == null)
491                 {
492                     stageEventProcessingFinishedEventCallbackDelegate = OnEventProcessingFinished;
493                     eventProcessingFinishedSignal = EventProcessingFinishedSignal();
494                     eventProcessingFinishedSignal?.Connect(stageEventProcessingFinishedEventCallbackDelegate);
495                 }
496                 stageEventProcessingFinishedEventHandler += value;
497
498             }
499             remove
500             {
501                 stageEventProcessingFinishedEventHandler -= value;
502                 if (stageEventProcessingFinishedEventHandler == null && eventProcessingFinishedSignal?.Empty() == false)
503                 {
504                     eventProcessingFinishedSignal?.Disconnect(stageEventProcessingFinishedEventCallbackDelegate);
505                 }
506             }
507         }
508
509         internal event EventHandler ContextLost
510         {
511             add
512             {
513                 if (stageContextLostEventHandler == null)
514                 {
515                     stageContextLostEventCallbackDelegate = OnContextLost;
516                     contextLostSignal = ContextLostSignal();
517                     contextLostSignal?.Connect(stageContextLostEventCallbackDelegate);
518                 }
519                 stageContextLostEventHandler += value;
520             }
521             remove
522             {
523                 stageContextLostEventHandler -= value;
524                 if (stageContextLostEventHandler == null && contextLostSignal?.Empty() == false)
525                 {
526                     contextLostSignal?.Disconnect(stageContextLostEventCallbackDelegate);
527                     if (contextLostSignal?.Empty() == true)
528                     {
529                         stageContextLostEventCallbackDelegate = null;
530                     }
531                 }
532             }
533         }
534
535         internal event EventHandler ContextRegained
536         {
537             add
538             {
539                 if (stageContextRegainedEventHandler == null)
540                 {
541                     stageContextRegainedEventCallbackDelegate = OnContextRegained;
542                     contextRegainedSignal = ContextRegainedSignal();
543                     contextRegainedSignal?.Connect(stageContextRegainedEventCallbackDelegate);
544                 }
545                 stageContextRegainedEventHandler += value;
546             }
547             remove
548             {
549                 stageContextRegainedEventHandler -= value;
550                 if (stageContextRegainedEventHandler == null && contextRegainedSignal?.Empty() == false)
551                 {
552                     contextRegainedSignal?.Disconnect(stageContextRegainedEventCallbackDelegate);
553                     if (contextRegainedSignal?.Empty() == true)
554                     {
555                         stageContextRegainedEventCallbackDelegate = null;
556                     }
557                 }
558             }
559         }
560
561         internal event EventHandler SceneCreated
562         {
563             add
564             {
565                 if (stageSceneCreatedEventHandler == null)
566                 {
567                     stageSceneCreatedEventCallbackDelegate = OnSceneCreated;
568                     sceneCreatedSignal = SceneCreatedSignal();
569                     sceneCreatedSignal?.Connect(stageSceneCreatedEventCallbackDelegate);
570                 }
571                 stageSceneCreatedEventHandler += value;
572             }
573             remove
574             {
575                 stageSceneCreatedEventHandler -= value;
576                 if (stageSceneCreatedEventHandler == null && sceneCreatedSignal?.Empty() == false)
577                 {
578                     sceneCreatedSignal?.Disconnect(stageSceneCreatedEventCallbackDelegate);
579                     if (sceneCreatedSignal?.Empty() == true)
580                     {
581                         stageSceneCreatedEventCallbackDelegate = null;
582                     }
583                 }
584             }
585         }
586
587         internal WindowFocusSignalType WindowFocusChangedSignal()
588         {
589             WindowFocusSignalType ret = new WindowFocusSignalType(Interop.Window.FocusChangedSignal(SwigCPtr), false);
590             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
591             return ret;
592         }
593
594         internal WindowFocusSignalType FocusChangedSignal()
595         {
596             WindowFocusSignalType ret = new WindowFocusSignalType(Interop.Window.FocusChangedSignal(SwigCPtr), false);
597             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
598             return ret;
599         }
600
601         internal KeyEventSignal KeyEventSignal()
602         {
603             KeyEventSignal ret = new KeyEventSignal(Interop.Window.KeyEventSignal(SwigCPtr), false);
604             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
605             return ret;
606         }
607
608         internal KeyEventSignal InterceptKeyEventSignal()
609         {
610             KeyEventSignal ret = new KeyEventSignal(Interop.Window.InterceptKeyEventSignal(SwigCPtr), false);
611             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
612             return ret;
613         }
614
615         internal VoidSignal EventProcessingFinishedSignal()
616         {
617             VoidSignal ret = new VoidSignal(Interop.StageSignal.EventProcessingFinishedSignal(stageCPtr), false);
618             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
619             return ret;
620         }
621
622         internal TouchSignal TouchSignal()
623         {
624             TouchSignal ret = new TouchSignal(Interop.Window.TouchSignal(SwigCPtr), false);
625             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
626             return ret;
627         }
628
629         internal TouchDataSignal TouchDataSignal()
630         {
631             TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(Layer.getCPtr(GetRootLayer())), false);
632             if (NDalicPINVOKE.SWIGPendingException.Pending)
633                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
634             return ret;
635         }
636
637         internal TouchDataSignal InterceptTouchDataSignal()
638         {
639             TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(Layer.getCPtr(GetRootLayer())), false);
640             if (NDalicPINVOKE.SWIGPendingException.Pending)
641                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
642             return ret;
643         }
644
645
646         internal VoidSignal ContextLostSignal()
647         {
648             VoidSignal ret = new VoidSignal(Interop.StageSignal.ContextLostSignal(stageCPtr), false);
649             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
650             return ret;
651         }
652
653         internal VoidSignal ContextRegainedSignal()
654         {
655             VoidSignal ret = new VoidSignal(Interop.StageSignal.ContextRegainedSignal(stageCPtr), false);
656             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
657             return ret;
658         }
659
660         internal VoidSignal SceneCreatedSignal()
661         {
662             VoidSignal ret = new VoidSignal(Interop.StageSignal.SceneCreatedSignal(stageCPtr), false);
663             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
664             return ret;
665         }
666
667         internal ResizeSignal ResizeSignal()
668         {
669             ResizeSignal ret = new ResizeSignal(Interop.Window.ResizeSignal(SwigCPtr), false);
670             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
671             return ret;
672         }
673
674         internal System.IntPtr GetNativeWindowHandler()
675         {
676             System.IntPtr ret = Interop.Window.GetNativeWindowHandler(HandleRef.ToIntPtr(this.SwigCPtr));
677             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
678             return ret;
679         }
680
681         /// <summary>
682         /// Disconnect all native signals
683         /// </summary>
684         /// <since_tizen> 5 </since_tizen>
685         internal void DisconnectNativeSignals()
686         {
687             if (windowFocusChangedEventCallback != null)
688             {
689                 windowFocusChangedSignal?.Disconnect(windowFocusChangedEventCallback);
690                 windowFocusChangedEventCallback = null;
691             }
692
693             if (rootLayerTouchDataCallback != null)
694             {
695                 touchDataSignal?.Disconnect(rootLayerTouchDataCallback);
696                 rootLayerTouchDataCallback = null;
697             }
698
699             if (rootLayerInterceptTouchDataCallback != null)
700             {
701                 interceptTouchDataSignal?.Disconnect(rootLayerInterceptTouchDataCallback);
702                 rootLayerInterceptTouchDataCallback = null;
703             }
704
705             if (wheelEventCallback != null)
706             {
707                 wheelSignal?.Disconnect(wheelEventCallback);
708                 wheelEventCallback = null;
709             }
710
711             if (DetentEventCallback != null)
712             {
713                 stageWheelSignal?.Disconnect(DetentEventCallback);
714                 DetentEventCallback = null;
715             }
716
717             if (stageKeyCallbackDelegate != null)
718             {
719                 keyEventSignal?.Disconnect(stageKeyCallbackDelegate);
720                 stageKeyCallbackDelegate = null;
721             }
722
723             if (stageInterceptKeyCallbackDelegate != null)
724             {
725                 interceptKeyEventSignal?.Disconnect(stageInterceptKeyCallbackDelegate);
726                 stageInterceptKeyCallbackDelegate = null;
727             }
728
729             if (stageEventProcessingFinishedEventCallbackDelegate != null)
730             {
731                 eventProcessingFinishedSignal?.Disconnect(stageEventProcessingFinishedEventCallbackDelegate);
732                 stageEventProcessingFinishedEventCallbackDelegate = null;
733             }
734
735             if (stageContextLostEventCallbackDelegate != null)
736             {
737                 contextLostSignal?.Disconnect(stageContextLostEventCallbackDelegate);
738                 stageContextLostEventCallbackDelegate = null;
739             }
740
741             if (stageContextRegainedEventCallbackDelegate != null)
742             {
743                 contextRegainedSignal?.Disconnect(stageContextRegainedEventCallbackDelegate);
744                 stageContextRegainedEventCallbackDelegate = null;
745             }
746
747             if (stageSceneCreatedEventCallbackDelegate != null)
748             {
749                 sceneCreatedSignal?.Disconnect(stageSceneCreatedEventCallbackDelegate);
750                 stageSceneCreatedEventCallbackDelegate = null;
751             }
752
753             if (windowResizeEventCallback != null)
754             {
755                 resizeSignal?.Disconnect(windowResizeEventCallback);
756                 windowResizeEventCallback = null;
757             }
758
759             if (windowFocusChangedEventCallback2 != null)
760             {
761                 windowFocusChangedSignal2?.Disconnect(windowFocusChangedEventCallback2);
762                 windowFocusChangedEventCallback2 = null;
763             }
764
765             if (transitionEffectSignal != null)
766             {
767                 TransitionEffectEventSignal().Disconnect(transitionEffectEventCallback);
768                 transitionEffectEventCallback = null;
769             }
770
771             if (movedSignal != null)
772             {
773                 MovedEventSignal().Disconnect(movedEventCallback);
774                 movedEventCallback = null;
775             }
776
777             if (keyboardRepeatSettingsChangedSignal != null)
778             {
779                 KeyboardRepeatSettingsChangedEventSignal().Disconnect(keyboardRepeatSettingsChangedEventCallback);
780                 keyboardRepeatSettingsChangedEventCallback = null;
781             }
782
783             if (auxiliaryMessageEventCallback != null)
784             {
785                 using var signal = new WindowAuxiliaryMessageSignal(this);
786                 signal.Disconnect(auxiliaryMessageEventCallback);
787                 auxiliaryMessageEventHandler = null;
788                 auxiliaryMessageEventCallback = null;
789             }
790
791             if (AccessibilityHighlightEventCallback != null)
792             {
793                 AccessibilityHighlightEventSignal?.Disconnect(AccessibilityHighlightEventCallback);
794                 AccessibilityHighlightEventCallback = null;
795             }
796         }
797
798         private StageWheelSignal StageWheelEventSignal()
799         {
800             StageWheelSignal ret = new StageWheelSignal(Interop.StageSignal.WheelEventSignal(stageCPtr), false);
801             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
802             return ret;
803         }
804
805         private WheelSignal WheelEventSignal()
806         {
807             WheelSignal ret = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(Layer.getCPtr(this.GetRootLayer())), false);
808             if (NDalicPINVOKE.SWIGPendingException.Pending)
809                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
810             return ret;
811         }
812
813         private WindowTransitionEffectSignal TransitionEffectEventSignal()
814         {
815             if (transitionEffectSignal == null)
816             {
817                 transitionEffectSignal = new WindowTransitionEffectSignal(this);
818                 if (NDalicPINVOKE.SWIGPendingException.Pending)
819                     throw NDalicPINVOKE.SWIGPendingException.Retrieve();
820             }
821             return transitionEffectSignal;
822         }
823
824         private WindowMovedSignal MovedEventSignal()
825         {
826             if (movedSignal == null)
827             {
828                 movedSignal = new WindowMovedSignal(this);
829                 if (NDalicPINVOKE.SWIGPendingException.Pending)
830                     throw NDalicPINVOKE.SWIGPendingException.Retrieve();
831             }
832             return movedSignal;
833         }
834
835         private KeyboardRepeatSettingsChangedSignal KeyboardRepeatSettingsChangedEventSignal()
836         {
837             if (keyboardRepeatSettingsChangedSignal == null)
838             {
839                 keyboardRepeatSettingsChangedSignal = new KeyboardRepeatSettingsChangedSignal(this);
840                 if (NDalicPINVOKE.SWIGPendingException.Pending)
841                     throw NDalicPINVOKE.SWIGPendingException.Retrieve();
842             }
843             return keyboardRepeatSettingsChangedSignal;
844         }
845
846         private void OnWindowFocusedChanged(IntPtr window, bool focusGained)
847         {
848             if (window == IntPtr.Zero)
849             {
850                 NUILog.Error("OnWindowFocusedChanged() Window is null! Do nothing!");
851                 return;
852             }
853
854             if (windowFocusChangedEventHandler != null)
855             {
856                 FocusChangedEventArgs e = new FocusChangedEventArgs();
857                 e.FocusGained = focusGained;
858                 windowFocusChangedEventHandler(this, e);
859             }
860         }
861
862         private bool OnWindowTouch(IntPtr view, IntPtr touchData)
863         {
864             if (touchData == global::System.IntPtr.Zero)
865             {
866                 NUILog.Error("touchData should not be null!");
867                 return false;
868             }
869
870             if (rootLayerTouchDataEventHandler != null)
871             {
872                 TouchEventArgs e = new TouchEventArgs();
873                 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
874                 rootLayerTouchDataEventHandler(this, e);
875             }
876             return false;
877         }
878
879         private bool OnWindowInterceptTouch(IntPtr view, IntPtr touchData)
880         {
881             if (touchData == global::System.IntPtr.Zero)
882             {
883                 NUILog.Error("touchData should not be null!");
884                 return true;
885             }
886
887             bool consumed = false;
888             if (rootLayerInterceptTouchDataEventHandler != null)
889             {
890                 TouchEventArgs e = new TouchEventArgs();
891                 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
892                 consumed = rootLayerInterceptTouchDataEventHandler(this, e);
893             }
894             return consumed;
895         }
896
897         private bool OnStageWheel(IntPtr rootLayer, IntPtr wheelEvent)
898         {
899             if (wheelEvent == global::System.IntPtr.Zero)
900             {
901                 NUILog.Error("wheelEvent should not be null!");
902                 return true;
903             }
904
905             if (stageWheelHandler != null)
906             {
907                 WheelEventArgs e = new WheelEventArgs();
908                 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
909                 stageWheelHandler(this, e);
910             }
911             return true;
912         }
913
914         // Callback for Stage KeyEventsignal
915         private void OnStageKey(IntPtr data)
916         {
917             if (stageKeyHandler != null)
918             {
919                 KeyEventArgs e = new KeyEventArgs();
920                 e.Key = Tizen.NUI.Key.GetKeyFromPtr(data);
921                 //here we send all data to user event handlers
922                 stageKeyHandler(this, e);
923             }
924         }
925
926         // Callback for Stage InterceptKeyEventsignal
927         private bool OnStageInterceptKey(IntPtr data)
928         {
929             bool consumed = false;
930             if (stageInterceptKeyHandler != null)
931             {
932                 KeyEventArgs e = new KeyEventArgs();
933                 e.Key = Tizen.NUI.Key.GetKeyFromPtr(data);
934                 //here we send all data to user event handlers
935                 consumed = stageInterceptKeyHandler(this, e);
936             }
937             return consumed;
938         }
939
940         // Callback for Stage EventProcessingFinishedSignal
941         private void OnEventProcessingFinished()
942         {
943             stageEventProcessingFinishedEventHandler?.Invoke(this, null);
944         }
945
946         // Callback for Stage ContextLostSignal
947         private void OnContextLost()
948         {
949             stageContextLostEventHandler?.Invoke(this, null);
950         }
951
952         // Callback for Stage ContextRegainedSignal
953         private void OnContextRegained()
954         {
955             stageContextRegainedEventHandler?.Invoke(this, null);
956         }
957
958         // Callback for Stage SceneCreatedSignal
959         private void OnSceneCreated()
960         {
961             stageSceneCreatedEventHandler?.Invoke(this, null);
962         }
963
964         private void OnResized(IntPtr window, IntPtr windowSize)
965         {
966             if (window == IntPtr.Zero)
967             {
968                 NUILog.Error("OnResized() Window is null! Do nothing!");
969                 return;
970             }
971
972             if (windowResizeEventHandler != null)
973             {
974                 ResizedEventArgs e = new ResizedEventArgs();
975                 // var val = new Uint16Pair(windowSize, false);
976                 // e.WindowSize = new Size2D(val.GetWidth(), val.GetHeight());
977                 // val.Dispose();
978
979                 // Workaround : windowSize should be valid pointer from dali,
980                 // but currently it is fixed and is not Uint16Pair class.
981                 // will be fixed later.
982                 e.WindowSize = this.WindowSize;
983                 windowResizeEventHandler(this, e);
984             }
985         }
986
987         private void OnWindowFocusedChanged2(IntPtr window, bool focusGained)
988         {
989             if (window == IntPtr.Zero)
990             {
991                 NUILog.Error("OnWindowFocusedChanged() Window is null! Do nothing!");
992                 return;
993             }
994
995             if (windowFocusChangedEventHandler2 != null)
996             {
997                 FocusChangedEventArgs e = new FocusChangedEventArgs();
998                 e.FocusGained = focusGained;
999                 windowFocusChangedEventHandler2(this, e);
1000             }
1001         }
1002
1003         private void OnTransitionEffect(IntPtr window, int state, int type)
1004         {
1005             if (window == global::System.IntPtr.Zero)
1006             {
1007                 return;
1008             }
1009
1010             if (transitionEffectHandler != null)
1011             {
1012                 TransitionEffectEventArgs e = new TransitionEffectEventArgs();
1013                 e.State = (EffectState)state;
1014                 e.Type = (EffectType)type;
1015                 transitionEffectHandler(this, e);
1016             }
1017             return;
1018         }
1019
1020         private void OnMoved(IntPtr window, IntPtr position)
1021         {
1022             if (window == global::System.IntPtr.Zero)
1023             {
1024                 return;
1025             }
1026
1027             if (movedHandler != null)
1028             {
1029                 WindowMovedEventArgs e = new WindowMovedEventArgs();
1030                 e.WindowPosition = this.WindowPosition;
1031                 movedHandler(this, e);
1032             }
1033             return;
1034         }
1035
1036         private void OnKeyboardRepeatSettingsChanged()
1037         {
1038             keyboardRepeatSettingsChangedHandler?.Invoke(this, null);
1039             return;
1040         }
1041
1042         /// <summary>
1043         /// The focus changed event argument.
1044         /// </summary>
1045         /// <since_tizen> 3 </since_tizen>
1046         public class FocusChangedEventArgs : EventArgs
1047         {
1048             /// <summary>
1049             /// FocusGained flag.
1050             /// </summary>
1051             /// <since_tizen> 3 </since_tizen>
1052             public bool FocusGained
1053             {
1054                 get;
1055                 set;
1056             }
1057         }
1058
1059         /// <summary>
1060         /// The touch event argument.
1061         /// </summary>
1062         /// <since_tizen> 3 </since_tizen>
1063         public class TouchEventArgs : EventArgs
1064         {
1065             private Touch touch;
1066
1067             /// <summary>
1068             /// Touch.
1069             /// </summary>
1070             /// <since_tizen> 3 </since_tizen>
1071             public Touch Touch
1072             {
1073                 get
1074                 {
1075                     return touch;
1076                 }
1077                 set
1078                 {
1079                     touch = value;
1080                 }
1081             }
1082         }
1083
1084         /// <summary>
1085         /// Wheel event arguments.
1086         /// </summary>
1087         /// <since_tizen> 3 </since_tizen>
1088         public class WheelEventArgs : EventArgs
1089         {
1090             private Wheel wheel;
1091
1092             /// <summary>
1093             /// Wheel.
1094             /// </summary>
1095             /// <since_tizen> 3 </since_tizen>
1096             public Wheel Wheel
1097             {
1098                 get
1099                 {
1100                     return wheel;
1101                 }
1102                 set
1103                 {
1104                     wheel = value;
1105                 }
1106             }
1107         }
1108
1109         /// <summary>
1110         /// Key event arguments.
1111         /// </summary>
1112         /// <since_tizen> 3 </since_tizen>
1113         public class KeyEventArgs : EventArgs
1114         {
1115             private Key key;
1116
1117             /// <summary>
1118             /// Key.
1119             /// </summary>
1120             /// <since_tizen> 3 </since_tizen>
1121             public Key Key
1122             {
1123                 get
1124                 {
1125                     return key;
1126                 }
1127                 set
1128                 {
1129                     key = value;
1130                 }
1131             }
1132         }
1133
1134         /// <summary>
1135         /// Feeds a key event into the window.
1136         /// This resized event arguments.
1137         /// </summary>
1138         /// <since_tizen> 3 </since_tizen>
1139         public class ResizedEventArgs : EventArgs
1140         {
1141             Size2D windowSize;
1142
1143             /// <summary>
1144             /// This window size.
1145             /// </summary>
1146             /// <since_tizen> 4 </since_tizen>
1147             public Size2D WindowSize
1148             {
1149                 get
1150                 {
1151                     return windowSize;
1152                 }
1153                 set
1154                 {
1155                     windowSize = value;
1156                 }
1157             }
1158         }
1159
1160         /// <summary>
1161         /// Do not use this, that will be deprecated.
1162         /// </summary>
1163         /// <since_tizen> 3 </since_tizen>
1164         [Obsolete("Do not use this, that will be deprecated. Use FocusChangedEventArgs instead. " +
1165             "Like: " +
1166             "NUIApplication.GetDefaultWindow().FocusChanged = OnFocusChanged; " +
1167             "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
1168         [EditorBrowsable(EditorBrowsableState.Never)]
1169         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
1170         public class WindowFocusChangedEventArgs : EventArgs
1171         {
1172             /// <summary>
1173             /// Do not use this, that will be deprecated.
1174             /// </summary>
1175             /// <since_tizen> 3 </since_tizen>
1176             public bool FocusGained
1177             {
1178                 get;
1179                 set;
1180             }
1181         }
1182
1183         /// <summary>
1184         /// Contains and encapsulates Native Window handle.
1185         /// </summary>
1186         /// <since_tizen> 4 </since_tizen>
1187         [Obsolete("This has been deprecated in API9 and will be removed in API11. Use Window.NativeHandle instead.")]
1188         public class SafeNativeWindowHandle : SafeHandle
1189         {
1190             /// <summary>
1191             ///Constructor, Native window handle is set to handle.
1192             /// </summary>
1193             /// <since_tizen> 4 </since_tizen>
1194             public SafeNativeWindowHandle() : base(IntPtr.Zero, false)
1195             {
1196                 SetHandle(NUIApplication.GetDefaultWindow().GetNativeWindowHandler());
1197             }
1198             /// <summary>
1199             /// Null check if the handle is valid or not.
1200             /// </summary>
1201             /// <since_tizen> 4 </since_tizen>
1202             public override bool IsInvalid
1203             {
1204                 get
1205                 {
1206                     return this.handle == IntPtr.Zero;
1207                 }
1208             }
1209             /// <summary>
1210             /// Release handle itself.
1211             /// </summary>
1212             /// <returns>true when released successfully.</returns>
1213             /// <since_tizen> 4 </since_tizen>
1214             protected override bool ReleaseHandle()
1215             {
1216                 return true;
1217             }
1218         }
1219
1220         /// <summary>
1221         /// TransitionEffectArgs
1222         /// </summary>
1223         [EditorBrowsable(EditorBrowsableState.Never)]
1224         public class TransitionEffectEventArgs : EventArgs
1225         {
1226             private EffectState state;
1227             private EffectType type;
1228
1229             /// <summary>
1230             /// State
1231             /// </summary>
1232             [EditorBrowsable(EditorBrowsableState.Never)]
1233             public EffectState State
1234             {
1235                 get
1236                 {
1237                     return state;
1238                 }
1239                 set
1240                 {
1241                     state = value;
1242                 }
1243             }
1244             /// <summary>
1245             /// Type
1246             /// </summary>
1247             [EditorBrowsable(EditorBrowsableState.Never)]
1248             public EffectType Type
1249             {
1250                 get
1251                 {
1252                     return type;
1253                 }
1254                 set
1255                 {
1256                     type = value;
1257                 }
1258             }
1259         }
1260
1261         private EventHandler<WheelEventArgs> DetentEventHandler;
1262
1263         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1264         private delegate void DetentEventCallbackType(IntPtr arg1);
1265
1266         private DetentEventCallbackType DetentEventCallback;
1267
1268         private void OnDetentEvent(IntPtr wheelEvent)
1269         {
1270             WheelEventArgs e = new WheelEventArgs();
1271
1272             if (wheelEvent != global::System.IntPtr.Zero)
1273             {
1274                 e.Wheel = Wheel.GetWheelFromPtr(wheelEvent);
1275             }
1276
1277             DetentEventHandler?.Invoke(this, e);
1278         }
1279
1280         /// <summary>
1281         /// VisibilityChangedArgs
1282         /// </summary>
1283         [EditorBrowsable(EditorBrowsableState.Never)]
1284         public class VisibilityChangedEventArgs : EventArgs
1285         {
1286             private bool visibility;
1287             /// <summary>
1288             /// Visibility
1289             /// </summary>
1290             [EditorBrowsable(EditorBrowsableState.Never)]
1291             public bool Visibility
1292             {
1293                 get => visibility;
1294                 set
1295                 {
1296                     visibility = value;
1297                 }
1298             }
1299         }
1300
1301         private void OnVisibilityChanged(IntPtr window, bool visibility)
1302         {
1303             if (window == global::System.IntPtr.Zero)
1304             {
1305                 NUILog.Error("[ERR] OnVisibilityChanged() window is null");
1306                 return;
1307             }
1308
1309             VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
1310             e.Visibility = visibility;
1311             if (VisibilityChangedEventHandler != null)
1312             {
1313                 VisibilityChangedEventHandler.Invoke(this, e);
1314             }
1315         }
1316
1317         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1318         private delegate void VisibilityChangedEventCallbackType(IntPtr window, bool visibility);
1319         private VisibilityChangedEventCallbackType VisibilityChangedEventCallback;
1320         private event EventHandler<VisibilityChangedEventArgs> VisibilityChangedEventHandler;
1321         private WindowVisibilityChangedEvent VisibilityChangedEventSignal;
1322
1323         /// <summary>
1324         /// EffectStart
1325         /// </summary>
1326         [EditorBrowsable(EditorBrowsableState.Never)]
1327         public event EventHandler<VisibilityChangedEventArgs> VisibilityChanged
1328         {
1329             add
1330             {
1331                 if (VisibilityChangedEventHandler == null)
1332                 {
1333                     VisibilityChangedEventCallback = OnVisibilityChanged;
1334                     VisibilityChangedEventSignal = new WindowVisibilityChangedEvent(this);
1335                     VisibilityChangedEventSignal.Connect(VisibilityChangedEventCallback);
1336                 }
1337                 VisibilityChangedEventHandler += value;
1338             }
1339             remove
1340             {
1341                 VisibilityChangedEventHandler -= value;
1342                 if (VisibilityChangedEventHandler == null)
1343                 {
1344                     if (VisibilityChangedEventSignal != null)
1345                     {
1346                         if (VisibilityChangedEventSignal.Empty() == false)
1347                         {
1348                             VisibilityChangedEventSignal.Disconnect(VisibilityChangedEventCallback);
1349                         }
1350                     }
1351                 }
1352             }
1353         }
1354
1355         /// <summary>
1356         /// VisibiltyChangedSignalEmit
1357         /// </summary>
1358         [EditorBrowsable(EditorBrowsableState.Never)]
1359         public void VisibiltyChangedSignalEmit(bool visibility)
1360         {
1361             if (VisibilityChangedEventSignal == null)
1362             {
1363                 VisibilityChangedEventSignal = new WindowVisibilityChangedEvent(this);
1364             }
1365             VisibilityChangedEventSignal.Emit(this, visibility);
1366         }
1367
1368         private void OnAuxiliaryMessage(IntPtr kData, IntPtr vData, IntPtr optionsArray)
1369         {
1370             if(kData == IntPtr.Zero || vData == IntPtr.Zero)
1371             {
1372                 return;
1373             }
1374
1375             using var tmp = new PropertyArray(optionsArray, false);
1376             var size = tmp.Size();
1377
1378             List<string> tmpList = new List<string>();
1379
1380             for (int i = 0; i < size; i++)
1381             {
1382                 string option = "none";
1383                 tmp.GetElementAt((uint)i).Get(out option);
1384                 tmpList.Add(option);
1385             }
1386
1387             tmp.Dispose();
1388
1389             AuxiliaryMessageEventArgs e = new AuxiliaryMessageEventArgs();
1390             e.Key = StringToVoidSignal.GetResult(kData);
1391             e.Value = StringToVoidSignal.GetResult(vData);;
1392             e.Options = tmpList;
1393
1394             auxiliaryMessageEventHandler?.Invoke(this, e);
1395         }
1396
1397         /// <summary>
1398         /// Auxiliary message is sent by displayer server when window's auxiliary was changed then display server sent the message.
1399         /// When client application added the window's auxiliary hint and if the auxiliary is changed,
1400         /// display server send the auxiliary message.
1401         /// Auxiliary message has the key, value and options.
1402         /// </summary>
1403         [EditorBrowsable(EditorBrowsableState.Never)]
1404         public event EventHandler<AuxiliaryMessageEventArgs> AuxiliaryMessage
1405         {
1406             add
1407             {
1408                 if (auxiliaryMessageEventHandler == null)
1409                 {
1410                     auxiliaryMessageEventCallback = OnAuxiliaryMessage;
1411                     using var signal = new WindowAuxiliaryMessageSignal(this);
1412                     signal.Connect(auxiliaryMessageEventCallback);
1413                 }
1414                 auxiliaryMessageEventHandler += value;
1415             }
1416             remove
1417             {
1418                 auxiliaryMessageEventHandler -= value;
1419                 if (auxiliaryMessageEventHandler == null)
1420                 {
1421                     if (auxiliaryMessageEventCallback != null)
1422                     {
1423                         using var signal = new WindowAuxiliaryMessageSignal(this);
1424                         signal.Disconnect(auxiliaryMessageEventCallback);
1425
1426                         if (signal.Empty())
1427                         {
1428                             auxiliaryMessageEventCallback = null;
1429                         }
1430                     }
1431                 }
1432             }
1433         }
1434
1435         /// <summary>
1436         /// AccessibilityHighlightArgs
1437         /// </summary>
1438         [EditorBrowsable(EditorBrowsableState.Never)]
1439         public class AccessibilityHighlightEventArgs : EventArgs
1440         {
1441             private bool accessibilityHighlight;
1442             /// <summary>
1443             /// accessibilityHighlight
1444             /// </summary>
1445             [EditorBrowsable(EditorBrowsableState.Never)]
1446             public bool AccessibilityHighlight
1447             {
1448                 get => accessibilityHighlight;
1449                 set
1450                 {
1451                     accessibilityHighlight = value;
1452                 }
1453             }
1454         }
1455
1456         private void OnAccessibilityHighlight(IntPtr window, bool highlight)
1457         {
1458             if (window == global::System.IntPtr.Zero)
1459             {
1460                 NUILog.Error("[ERR] OnAccessibilityHighlight() window is null");
1461                 return;
1462             }
1463
1464             AccessibilityHighlightEventArgs e = new AccessibilityHighlightEventArgs();
1465             e.AccessibilityHighlight = highlight;
1466             if (AccessibilityHighlightEventHandler != null)
1467             {
1468                 AccessibilityHighlightEventHandler.Invoke(this, e);
1469             }
1470         }
1471
1472         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1473         private delegate void AccessibilityHighlightEventCallbackType(IntPtr window, bool highlight);
1474         private AccessibilityHighlightEventCallbackType AccessibilityHighlightEventCallback;
1475         private event EventHandler<AccessibilityHighlightEventArgs> AccessibilityHighlightEventHandler;
1476         private WindowAccessibilityHighlightEvent AccessibilityHighlightEventSignal;
1477
1478         /// <summary>
1479         /// Emits the event when the window needs to grab or clear highlight.
1480         /// </summary>
1481         [EditorBrowsable(EditorBrowsableState.Never)]
1482         public event EventHandler<AccessibilityHighlightEventArgs> AccessibilityHighlight
1483         {
1484             add
1485             {
1486                 if (AccessibilityHighlightEventHandler == null)
1487                 {
1488                     AccessibilityHighlightEventCallback = OnAccessibilityHighlight;
1489                     AccessibilityHighlightEventSignal = new WindowAccessibilityHighlightEvent(this);
1490                     AccessibilityHighlightEventSignal.Connect(AccessibilityHighlightEventCallback);
1491                 }
1492                 AccessibilityHighlightEventHandler += value;
1493             }
1494             remove
1495             {
1496                 AccessibilityHighlightEventHandler -= value;
1497                 if (AccessibilityHighlightEventHandler == null)
1498                 {
1499                     if (AccessibilityHighlightEventSignal != null)
1500                     {
1501                         if (AccessibilityHighlightEventSignal.Empty() == false)
1502                         {
1503                             AccessibilityHighlightEventSignal.Disconnect(AccessibilityHighlightEventCallback);
1504                             if (AccessibilityHighlightEventSignal.Empty() == true)
1505                             {
1506                                 AccessibilityHighlightEventCallback = null;
1507                             }
1508                         }
1509                     }
1510                 }
1511             }
1512         }
1513     }
1514
1515     /// <summary>
1516     /// MovedArgs
1517     /// </summary>
1518     [EditorBrowsable(EditorBrowsableState.Never)]
1519     public class WindowMovedEventArgs : EventArgs
1520     {
1521         private Position2D position;
1522
1523         [EditorBrowsable(EditorBrowsableState.Never)]
1524         public Position2D WindowPosition
1525         {
1526             get
1527             {
1528                 return position;
1529             }
1530             set
1531             {
1532                 position = value;
1533             }
1534         }
1535     }
1536 }