[NUI] Clean shadow related properties from Control and sample (#1297)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / ViewEvent.cs
1 /*
2  * Copyright(c) 2019 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.Runtime.InteropServices;
20
21 namespace Tizen.NUI.BaseComponents
22 {
23     /// <summary>
24     /// View is the base class for all views.
25     /// </summary>
26     /// <since_tizen> 3 </since_tizen>
27     public partial class View
28     {
29         private EventHandler _offWindowEventHandler;
30         private OffWindowEventCallbackType _offWindowEventCallback;
31         private EventHandlerWithReturnType<object, WheelEventArgs, bool> _wheelEventHandler;
32         private WheelEventCallbackType _wheelEventCallback;
33         private EventHandlerWithReturnType<object, KeyEventArgs, bool> _keyEventHandler;
34         private KeyCallbackType _keyCallback;
35         private EventHandlerWithReturnType<object, TouchEventArgs, bool> _touchDataEventHandler;
36         private TouchDataCallbackType _touchDataCallback;
37         private EventHandlerWithReturnType<object, HoverEventArgs, bool> _hoverEventHandler;
38         private HoverEventCallbackType _hoverEventCallback;
39         private EventHandler<VisibilityChangedEventArgs> _visibilityChangedEventHandler;
40         private VisibilityChangedEventCallbackType _visibilityChangedEventCallback;
41         private EventHandler _keyInputFocusGainedEventHandler;
42         private KeyInputFocusGainedCallbackType _keyInputFocusGainedCallback;
43         private EventHandler _keyInputFocusLostEventHandler;
44         private KeyInputFocusLostCallbackType _keyInputFocusLostCallback;
45         private EventHandler _onRelayoutEventHandler;
46         private OnRelayoutEventCallbackType _onRelayoutEventCallback;
47         private EventHandler _onWindowEventHandler;
48         private OnWindowEventCallbackType _onWindowEventCallback;
49         private EventHandler<LayoutDirectionChangedEventArgs> _layoutDirectionChangedEventHandler;
50         private LayoutDirectionChangedEventCallbackType _layoutDirectionChangedEventCallback;
51         // Resource Ready Signal
52         private EventHandler _resourcesLoadedEventHandler;
53         private ResourcesLoadedCallbackType _ResourcesLoadedCallback;
54         private EventHandler<BackgroundResourceLoadedEventArgs> _backgroundResourceLoadedEventHandler;
55         private _backgroundResourceLoadedCallbackType _backgroundResourceLoadedCallback;
56
57         private OnWindowEventCallbackType _onWindowSendEventCallback;
58
59         private void SendViewAddedEventToWindow(IntPtr data)
60         {
61             Window.Instance?.SendViewAdded(this);
62         }
63
64         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
65         private delegate void OffWindowEventCallbackType(IntPtr control);
66         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
67         private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
68         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
69         private delegate bool KeyCallbackType(IntPtr control, IntPtr keyEvent);
70         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
71         private delegate bool TouchDataCallbackType(IntPtr view, IntPtr touchData);
72         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
73         private delegate bool HoverEventCallbackType(IntPtr view, IntPtr hoverEvent);
74         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
75         private delegate void VisibilityChangedEventCallbackType(IntPtr data, bool visibility, VisibilityChangeType type);
76         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
77         private delegate void ResourcesLoadedCallbackType(IntPtr control);
78         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
79         private delegate void _backgroundResourceLoadedCallbackType(IntPtr view);
80         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
81         private delegate void KeyInputFocusGainedCallbackType(IntPtr control);
82         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
83         private delegate void KeyInputFocusLostCallbackType(IntPtr control);
84         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
85         private delegate void OnRelayoutEventCallbackType(IntPtr control);
86         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
87         private delegate void OnWindowEventCallbackType(IntPtr control);
88         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
89         private delegate void LayoutDirectionChangedEventCallbackType(IntPtr data, ViewLayoutDirectionType type);
90
91         /// <summary>
92         /// Event when a child is removed.
93         /// </summary>
94         /// <since_tizen> 5 </since_tizen>
95         public new event EventHandler<ChildRemovedEventArgs> ChildRemoved;
96         /// <summary>
97         /// Event when a child is added.
98         /// </summary>
99         /// <since_tizen> 5 </since_tizen>
100         public new event EventHandler<ChildAddedEventArgs> ChildAdded;
101
102         /// <summary>
103         /// An event for the KeyInputFocusGained signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
104         /// The KeyInputFocusGained signal is emitted when the control gets the key input focus.<br />
105         /// </summary>
106         /// <since_tizen> 3 </since_tizen>
107         public event EventHandler FocusGained
108         {
109             add
110             {
111                 if (_keyInputFocusGainedEventHandler == null)
112                 {
113                     _keyInputFocusGainedCallback = OnKeyInputFocusGained;
114                     this.KeyInputFocusGainedSignal().Connect(_keyInputFocusGainedCallback);
115                 }
116
117                 _keyInputFocusGainedEventHandler += value;
118             }
119
120             remove
121             {
122                 _keyInputFocusGainedEventHandler -= value;
123
124                 if (_keyInputFocusGainedEventHandler == null && KeyInputFocusGainedSignal().Empty() == false)
125                 {
126                     this.KeyInputFocusGainedSignal().Disconnect(_keyInputFocusGainedCallback);
127                 }
128             }
129         }
130
131         /// <summary>
132         /// An event for the KeyInputFocusLost signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
133         /// The KeyInputFocusLost signal is emitted when the control loses the key input focus.<br />
134         /// </summary>
135         /// <since_tizen> 3 </since_tizen>
136         public event EventHandler FocusLost
137         {
138             add
139             {
140                 if (_keyInputFocusLostEventHandler == null)
141                 {
142                     _keyInputFocusLostCallback = OnKeyInputFocusLost;
143                     this.KeyInputFocusLostSignal().Connect(_keyInputFocusLostCallback);
144                 }
145
146                 _keyInputFocusLostEventHandler += value;
147             }
148
149             remove
150             {
151                 _keyInputFocusLostEventHandler -= value;
152
153                 if (_keyInputFocusLostEventHandler == null && KeyInputFocusLostSignal().Empty() == false)
154                 {
155                     this.KeyInputFocusLostSignal().Disconnect(_keyInputFocusLostCallback);
156                 }
157             }
158         }
159
160         /// <summary>
161         /// An event for the KeyPressed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
162         /// The KeyPressed signal is emitted when the key event is received.<br />
163         /// </summary>
164         /// <since_tizen> 3 </since_tizen>
165         public event EventHandlerWithReturnType<object, KeyEventArgs, bool> KeyEvent
166         {
167             add
168             {
169                 if (_keyEventHandler == null)
170                 {
171                     _keyCallback = OnKeyEvent;
172                     this.KeyEventSignal().Connect(_keyCallback);
173                 }
174
175                 _keyEventHandler += value;
176             }
177
178             remove
179             {
180                 _keyEventHandler -= value;
181
182                 if (_keyEventHandler == null && KeyEventSignal().Empty() == false)
183                 {
184                     this.KeyEventSignal().Disconnect(_keyCallback);
185                 }
186             }
187         }
188
189         /// <summary>
190         /// An event for the OnRelayout signal which can be used to subscribe or unsubscribe the event handler.<br />
191         /// The OnRelayout signal is emitted after the size has been set on the view during relayout.<br />
192         /// </summary>
193         /// <since_tizen> 3 </since_tizen>
194         public event EventHandler Relayout
195         {
196             add
197             {
198                 if (_onRelayoutEventHandler == null)
199                 {
200                     _onRelayoutEventCallback = OnRelayout;
201                     this.OnRelayoutSignal().Connect(_onRelayoutEventCallback);
202                 }
203
204                 _onRelayoutEventHandler += value;
205             }
206
207             remove
208             {
209                 _onRelayoutEventHandler -= value;
210
211                 if (_onRelayoutEventHandler == null && OnRelayoutSignal().Empty() == false)
212                 {
213                     this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback);
214                 }
215
216             }
217         }
218
219         /// <summary>
220         /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
221         /// The touched signal is emitted when the touch input is received.<br />
222         /// </summary>
223         /// <since_tizen> 3 </since_tizen>
224         public event EventHandlerWithReturnType<object, TouchEventArgs, bool> TouchEvent
225         {
226             add
227             {
228                 if (_touchDataEventHandler == null)
229                 {
230                     _touchDataCallback = OnTouch;
231                     this.TouchSignal().Connect(_touchDataCallback);
232                 }
233
234                 _touchDataEventHandler += value;
235             }
236
237             remove
238             {
239                 _touchDataEventHandler -= value;
240
241                 if (_touchDataEventHandler == null && TouchSignal().Empty() == false)
242                 {
243                     this.TouchSignal().Disconnect(_touchDataCallback);
244                 }
245
246             }
247         }
248
249         /// <summary>
250         /// An event for the hovered signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
251         /// The hovered signal is emitted when the hover input is received.<br />
252         /// </summary>
253         /// <since_tizen> 3 </since_tizen>
254         public event EventHandlerWithReturnType<object, HoverEventArgs, bool> HoverEvent
255         {
256             add
257             {
258                 if (_hoverEventHandler == null)
259                 {
260                     _hoverEventCallback = OnHoverEvent;
261                     this.HoveredSignal().Connect(_hoverEventCallback);
262                 }
263
264                 _hoverEventHandler += value;
265             }
266
267             remove
268             {
269                 _hoverEventHandler -= value;
270
271                 if (_hoverEventHandler == null && HoveredSignal().Empty() == false)
272                 {
273                     this.HoveredSignal().Disconnect(_hoverEventCallback);
274                 }
275
276             }
277         }
278
279         /// <summary>
280         /// An event for the WheelMoved signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
281         /// The WheelMoved signal is emitted when the wheel event is received.<br />
282         /// </summary>
283         /// <since_tizen> 3 </since_tizen>
284         public event EventHandlerWithReturnType<object, WheelEventArgs, bool> WheelEvent
285         {
286             add
287             {
288                 if (_wheelEventHandler == null)
289                 {
290                     _wheelEventCallback = OnWheelEvent;
291                     this.WheelEventSignal().Connect(_wheelEventCallback);
292                 }
293
294                 _wheelEventHandler += value;
295             }
296
297             remove
298             {
299                 _wheelEventHandler -= value;
300
301                 if (_wheelEventHandler == null && WheelEventSignal().Empty() == false)
302                 {
303                     this.WheelEventSignal().Disconnect(_wheelEventCallback);
304                 }
305
306             }
307         }
308
309         /// <summary>
310         /// An event for the OnWindow signal which can be used to subscribe or unsubscribe the event handler.<br />
311         /// The OnWindow signal is emitted after the view has been connected to the window.<br />
312         /// </summary>
313         /// <since_tizen> 3 </since_tizen>
314         public event EventHandler AddedToWindow
315         {
316             add
317             {
318                 if (_onWindowEventHandler == null)
319                 {
320                     _onWindowEventCallback = OnWindow;
321                     this.OnWindowSignal().Connect(_onWindowEventCallback);
322                 }
323
324                 _onWindowEventHandler += value;
325             }
326
327             remove
328             {
329                 _onWindowEventHandler -= value;
330
331                 if (_onWindowEventHandler == null && OnWindowSignal().Empty() == false)
332                 {
333                     this.OnWindowSignal().Disconnect(_onWindowEventCallback);
334                 }
335             }
336         }
337
338         /// <summary>
339         /// An event for the OffWindow signal, which can be used to subscribe or unsubscribe the event handler.<br />
340         /// OffWindow signal is emitted after the view has been disconnected from the window.<br />
341         /// </summary>
342         /// <since_tizen> 3 </since_tizen>
343         public event EventHandler RemovedFromWindow
344         {
345             add
346             {
347                 if (_offWindowEventHandler == null)
348                 {
349                     _offWindowEventCallback = OffWindow;
350                     this.OffWindowSignal().Connect(_offWindowEventCallback);
351                 }
352
353                 _offWindowEventHandler += value;
354             }
355
356             remove
357             {
358                 _offWindowEventHandler -= value;
359
360                 if (_offWindowEventHandler == null && OffWindowSignal().Empty() == false)
361                 {
362                     this.OffWindowSignal().Disconnect(_offWindowEventCallback);
363                 }
364             }
365         }
366
367         /// <summary>
368         /// An event for visibility change which can be used to subscribe or unsubscribe the event handler.<br />
369         /// This signal is emitted when the visible property of this or a parent view is changed.<br />
370         /// </summary>
371         /// <since_tizen> 3 </since_tizen>
372         public event EventHandler<VisibilityChangedEventArgs> VisibilityChanged
373         {
374             add
375             {
376                 if (_visibilityChangedEventHandler == null)
377                 {
378                     _visibilityChangedEventCallback = OnVisibilityChanged;
379                     VisibilityChangedSignal(this).Connect(_visibilityChangedEventCallback);
380                 }
381
382                 _visibilityChangedEventHandler += value;
383             }
384
385             remove
386             {
387                 _visibilityChangedEventHandler -= value;
388
389                 if (_visibilityChangedEventHandler == null && VisibilityChangedSignal(this).Empty() == false)
390                 {
391                     VisibilityChangedSignal(this).Disconnect(_visibilityChangedEventCallback);
392                 }
393             }
394         }
395
396         /// <summary>
397         /// Event for layout direction change which can be used to subscribe/unsubscribe the event handler.<br />
398         /// This signal is emitted when the layout direction property of this or a parent view is changed.<br />
399         /// </summary>
400         /// <since_tizen> 4 </since_tizen>
401         public event EventHandler<LayoutDirectionChangedEventArgs> LayoutDirectionChanged
402         {
403             add
404             {
405                 if (_layoutDirectionChangedEventHandler == null)
406                 {
407                     _layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
408                     LayoutDirectionChangedSignal(this).Connect(_layoutDirectionChangedEventCallback);
409                 }
410
411                 _layoutDirectionChangedEventHandler += value;
412             }
413
414             remove
415             {
416                 _layoutDirectionChangedEventHandler -= value;
417
418                 if (_layoutDirectionChangedEventHandler == null && LayoutDirectionChangedSignal(this).Empty() == false)
419                 {
420                     LayoutDirectionChangedSignal(this).Disconnect(_layoutDirectionChangedEventCallback);
421                 }
422             }
423         }
424
425         /// <summary>
426         /// An event for the ResourcesLoadedSignal signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
427         /// This signal is emitted after all resources required by a view are loaded and ready.<br />
428         /// </summary>
429         /// <since_tizen> 3 </since_tizen>
430         public event EventHandler ResourcesLoaded
431         {
432             add
433             {
434                 if (_resourcesLoadedEventHandler == null)
435                 {
436                     _ResourcesLoadedCallback = OnResourcesLoaded;
437                     this.ResourcesLoadedSignal().Connect(_ResourcesLoadedCallback);
438                 }
439
440                 _resourcesLoadedEventHandler += value;
441             }
442
443             remove
444             {
445                 _resourcesLoadedEventHandler -= value;
446
447                 if (_resourcesLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
448                 {
449                     this.ResourcesLoadedSignal().Disconnect(_ResourcesLoadedCallback);
450                 }
451             }
452         }
453
454         internal event EventHandler<BackgroundResourceLoadedEventArgs> BackgroundResourceLoaded
455         {
456             add
457             {
458                 if (_backgroundResourceLoadedEventHandler == null)
459                 {
460                     _backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
461                     this.ResourcesLoadedSignal().Connect(_backgroundResourceLoadedCallback);
462                 }
463
464                 _backgroundResourceLoadedEventHandler += value;
465             }
466             remove
467             {
468                 _backgroundResourceLoadedEventHandler -= value;
469
470                 if (_backgroundResourceLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
471                 {
472                     this.ResourcesLoadedSignal().Disconnect(_backgroundResourceLoadedCallback);
473                 }
474             }
475         }
476
477         internal TouchDataSignal TouchSignal()
478         {
479             TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.Actor_TouchSignal(swigCPtr), false);
480             if (NDalicPINVOKE.SWIGPendingException.Pending)
481                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
482             return ret;
483         }
484
485         internal HoverSignal HoveredSignal()
486         {
487             HoverSignal ret = new HoverSignal(Interop.ActorSignal.Actor_HoveredSignal(swigCPtr), false);
488             if (NDalicPINVOKE.SWIGPendingException.Pending)
489                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
490             return ret;
491         }
492
493         internal WheelSignal WheelEventSignal()
494         {
495             WheelSignal ret = new WheelSignal(Interop.ActorSignal.Actor_WheelEventSignal(swigCPtr), false);
496             if (NDalicPINVOKE.SWIGPendingException.Pending)
497                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
498             return ret;
499         }
500
501         internal ViewSignal OnWindowSignal()
502         {
503             ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OnStageSignal(swigCPtr), false);
504             if (NDalicPINVOKE.SWIGPendingException.Pending)
505                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
506             return ret;
507         }
508
509         internal ViewSignal OffWindowSignal()
510         {
511             ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OffStageSignal(swigCPtr), false);
512             if (NDalicPINVOKE.SWIGPendingException.Pending)
513                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
514             return ret;
515         }
516
517         internal ViewSignal OnRelayoutSignal()
518         {
519             ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OnRelayoutSignal(swigCPtr), false);
520             if (NDalicPINVOKE.SWIGPendingException.Pending)
521                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
522             return ret;
523         }
524
525         internal ViewVisibilityChangedSignal VisibilityChangedSignal(View view)
526         {
527             ViewVisibilityChangedSignal ret = new ViewVisibilityChangedSignal(Interop.NDalic.VisibilityChangedSignal(View.getCPtr(view)), false);
528             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
529             return ret;
530         }
531
532         internal ViewLayoutDirectionChangedSignal LayoutDirectionChangedSignal(View view)
533         {
534             ViewLayoutDirectionChangedSignal ret = new ViewLayoutDirectionChangedSignal(Interop.Layout.LayoutDirectionChangedSignal(View.getCPtr(view)), false);
535             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
536             return ret;
537         }
538
539         internal ViewSignal ResourcesLoadedSignal()
540         {
541             ViewSignal ret = new ViewSignal(Interop.View.ResourceReadySignal(swigCPtr), false);
542             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
543             return ret;
544         }
545
546         internal ControlKeySignal KeyEventSignal()
547         {
548             ControlKeySignal ret = new ControlKeySignal(Interop.ViewSignal.View_KeyEventSignal(swigCPtr), false);
549             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
550             return ret;
551         }
552
553         internal KeyInputFocusSignal KeyInputFocusGainedSignal()
554         {
555             KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.View_KeyInputFocusGainedSignal(swigCPtr), false);
556             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
557             return ret;
558         }
559
560         internal KeyInputFocusSignal KeyInputFocusLostSignal()
561         {
562             KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.View_KeyInputFocusLostSignal(swigCPtr), false);
563             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
564             return ret;
565         }
566
567         private void OnSize2DChanged(int width, int height)
568         {
569             Size2D = new Size2D(width, height);
570         }
571
572         private void OnMinimumSizeChanged(int width, int height)
573         {
574             MinimumSize = new Size2D(width, height);
575         }
576
577         private void OnMaximumSizeChanged(int width, int height)
578         {
579             MaximumSize = new Size2D(width, height);
580         }
581
582         private void OnPosition2DChanged(int x, int y)
583         {
584             Position2D = new Position2D(x, y);
585         }
586
587         private void OnSizeChanged(float width, float height, float depth)
588         {
589             Size = new Size(width, height, depth);
590         }
591
592         private void OnPositionChanged(float x, float y, float z)
593         {
594             Position = new Position(x, y, z);
595         }
596
597         private void OnParentOriginChanged(float x, float y, float z)
598         {
599             ParentOrigin = new Position(x, y, z);
600         }
601
602         private void OnPivotPointChanged(float x, float y, float z)
603         {
604             PivotPoint = new Position(x, y, z);
605         }
606
607         private void OnImageShadowChanged(ShadowBase instance)
608         {
609             ImageShadow = (ImageShadow)instance;
610         }
611
612         private void OnBoxShadowChanged(ShadowBase instance)
613         {
614             BoxShadow = (Shadow)instance;
615         }
616
617         private void OnBackgroundImageBorderChanged(int left, int right, int bottom, int top)
618         {
619             BackgroundImageBorder = new Rectangle(left, right, bottom, top);
620         }
621
622         private void OnKeyInputFocusGained(IntPtr view)
623         {
624             if (_keyInputFocusGainedEventHandler != null)
625             {
626                 _keyInputFocusGainedEventHandler(this, null);
627             }
628         }
629
630         private void OnKeyInputFocusLost(IntPtr view)
631         {
632             if (_keyInputFocusLostEventHandler != null)
633             {
634                 _keyInputFocusLostEventHandler(this, null);
635             }
636         }
637
638         private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
639         {
640             if (keyEvent == global::System.IntPtr.Zero)
641             {
642                 NUILog.Error("keyEvent should not be null!");
643                 return true;
644             }
645
646             KeyEventArgs e = new KeyEventArgs();
647
648             bool result = false;
649
650             e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
651
652             if (_keyEventHandler != null)
653             {
654                 Delegate[] delegateList = _keyEventHandler.GetInvocationList();
655
656                 // Oring the result of each callback.
657                 foreach (EventHandlerWithReturnType<object, KeyEventArgs, bool> del in delegateList)
658                 {
659                     result |= del(this, e);
660                 }
661             }
662
663             return result;
664         }
665
666         // Callback for View OnRelayout signal
667         private void OnRelayout(IntPtr data)
668         {
669             if (_onRelayoutEventHandler != null)
670             {
671                 _onRelayoutEventHandler(this, null);
672             }
673         }
674
675         // Callback for View TouchSignal
676         private bool OnTouch(IntPtr view, IntPtr touchData)
677         {
678             if (touchData == global::System.IntPtr.Zero)
679             {
680                 NUILog.Error("touchData should not be null!");
681                 return true;
682             }
683
684             TouchEventArgs e = new TouchEventArgs();
685
686             e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
687
688             if (_touchDataEventHandler != null)
689             {
690                 return _touchDataEventHandler(this, e);
691             }
692             return false;
693         }
694
695         // Callback for View Hover signal
696         private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
697         {
698             if (hoverEvent == global::System.IntPtr.Zero)
699             {
700                 NUILog.Error("hoverEvent should not be null!");
701                 return true;
702             }
703
704             HoverEventArgs e = new HoverEventArgs();
705
706             e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
707
708             if (_hoverEventHandler != null)
709             {
710                 return _hoverEventHandler(this, e);
711             }
712             return false;
713         }
714
715         // Callback for View Wheel signal
716         private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
717         {
718             if (wheelEvent == global::System.IntPtr.Zero)
719             {
720                 NUILog.Error("wheelEvent should not be null!");
721                 return true;
722             }
723
724             WheelEventArgs e = new WheelEventArgs();
725
726             e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
727
728             if (_wheelEventHandler != null)
729             {
730                 return _wheelEventHandler(this, e);
731             }
732             return false;
733         }
734
735         // Callback for View OnWindow signal
736         private void OnWindow(IntPtr data)
737         {
738             if (_onWindowEventHandler != null)
739             {
740                 _onWindowEventHandler(this, null);
741             }
742         }
743
744         // Callback for View OffWindow signal
745         private void OffWindow(IntPtr data)
746         {
747             if (_offWindowEventHandler != null)
748             {
749                 _offWindowEventHandler(this, null);
750             }
751         }
752
753         // Callback for View visibility change signal
754         private void OnVisibilityChanged(IntPtr data, bool visibility, VisibilityChangeType type)
755         {
756             VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
757             if (data != null)
758             {
759                 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
760             }
761             e.Visibility = visibility;
762             e.Type = type;
763
764             if (_visibilityChangedEventHandler != null)
765             {
766                 _visibilityChangedEventHandler(this, e);
767             }
768         }
769
770         // Callback for View layout direction change signal
771         private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
772         {
773             LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
774             if (data != null)
775             {
776                 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
777             }
778             e.Type = type;
779
780             if (_layoutDirectionChangedEventHandler != null)
781             {
782                 _layoutDirectionChangedEventHandler(this, e);
783             }
784         }
785
786         private void OnResourcesLoaded(IntPtr view)
787         {
788             if (_resourcesLoadedEventHandler != null)
789             {
790                 _resourcesLoadedEventHandler(this, null);
791             }
792         }
793
794         private void OnBackgroundResourceLoaded(IntPtr view)
795         {
796             BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
797             e.Status = (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.BACKGROUND);
798
799             if (_backgroundResourceLoadedEventHandler != null)
800             {
801                 _backgroundResourceLoadedEventHandler(this, e);
802             }
803         }
804
805         /// <summary>
806         /// Event argument passed through the ChildAdded event.
807         /// </summary>
808         /// <since_tizen> 5 </since_tizen>
809         public class ChildAddedEventArgs : EventArgs
810         {
811             /// <summary>
812             /// Added child view at moment.
813             /// </summary>
814             /// <since_tizen> 5 </since_tizen>
815             public View Added { get; set; }
816         }
817
818         /// <summary>
819         /// Event argument passed through the ChildRemoved event.
820         /// </summary>
821         /// <since_tizen> 5 </since_tizen>
822         public class ChildRemovedEventArgs : EventArgs
823         {
824             /// <summary>
825             /// Removed child view at moment.
826             /// </summary>
827             /// <since_tizen> 5 </since_tizen>
828             public View Removed { get; set; }
829         }
830
831         /// <summary>
832         /// Event arguments that passed via the KeyEvent signal.
833         /// </summary>
834         /// <since_tizen> 3 </since_tizen>
835         public class KeyEventArgs : EventArgs
836         {
837             private Key _key;
838
839             /// <summary>
840             /// Key - is the key sent to the view.
841             /// </summary>
842             /// <since_tizen> 3 </since_tizen>
843             public Key Key
844             {
845                 get
846                 {
847                     return _key;
848                 }
849                 set
850                 {
851                     _key = value;
852                 }
853             }
854         }
855
856         /// <summary>
857         /// Event arguments that passed via the touch signal.
858         /// </summary>
859         /// <since_tizen> 3 </since_tizen>
860         public class TouchEventArgs : EventArgs
861         {
862             private Touch _touch;
863
864             /// <summary>
865             /// Touch - contains the information of touch points.
866             /// </summary>
867             /// <since_tizen> 3 </since_tizen>
868             public Touch Touch
869             {
870                 get
871                 {
872                     return _touch;
873                 }
874                 set
875                 {
876                     _touch = value;
877                 }
878             }
879         }
880
881         /// <summary>
882         /// Event arguments that passed via the hover signal.
883         /// </summary>
884         /// <since_tizen> 3 </since_tizen>
885         public class HoverEventArgs : EventArgs
886         {
887             private Hover _hover;
888
889             /// <summary>
890             /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
891             /// </summary>
892             /// <since_tizen> 3 </since_tizen>
893             public Hover Hover
894             {
895                 get
896                 {
897                     return _hover;
898                 }
899                 set
900                 {
901                     _hover = value;
902                 }
903             }
904         }
905
906         /// <summary>
907         /// Event arguments that passed via the wheel signal.
908         /// </summary>
909         /// <since_tizen> 3 </since_tizen>
910         public class WheelEventArgs : EventArgs
911         {
912             private Wheel _wheel;
913
914             /// <summary>
915             /// WheelEvent - store a wheel rolling type: MOUSE_WHEEL or CUSTOM_WHEEL.
916             /// </summary>
917             /// <since_tizen> 3 </since_tizen>
918             public Wheel Wheel
919             {
920                 get
921                 {
922                     return _wheel;
923                 }
924                 set
925                 {
926                     _wheel = value;
927                 }
928             }
929         }
930
931         /// <summary>
932         /// Event arguments of visibility changed.
933         /// </summary>
934         /// <since_tizen> 3 </since_tizen>
935         public class VisibilityChangedEventArgs : EventArgs
936         {
937             private View _view;
938             private bool _visibility;
939             private VisibilityChangeType _type;
940
941             /// <summary>
942             /// The view, or child of view, whose visibility has changed.
943             /// </summary>
944             /// <since_tizen> 3 </since_tizen>
945             public View View
946             {
947                 get
948                 {
949                     return _view;
950                 }
951                 set
952                 {
953                     _view = value;
954                 }
955             }
956
957             /// <summary>
958             /// Whether the view is now visible or not.
959             /// </summary>
960             /// <since_tizen> 3 </since_tizen>
961             public bool Visibility
962             {
963                 get
964                 {
965                     return _visibility;
966                 }
967                 set
968                 {
969                     _visibility = value;
970                 }
971             }
972
973             /// <summary>
974             /// Whether the view's visible property has changed or a parent's.
975             /// </summary>
976             /// <since_tizen> 3 </since_tizen>
977             public VisibilityChangeType Type
978             {
979                 get
980                 {
981                     return _type;
982                 }
983                 set
984                 {
985                     _type = value;
986                 }
987             }
988         }
989
990         /// <summary>
991         /// Event arguments of layout direction changed.
992         /// </summary>
993         /// <since_tizen> 4 </since_tizen>
994         public class LayoutDirectionChangedEventArgs : EventArgs
995         {
996             private View _view;
997             private ViewLayoutDirectionType _type;
998
999             /// <summary>
1000             /// The view, or child of view, whose layout direction has changed.
1001             /// </summary>
1002             /// <since_tizen> 4 </since_tizen>
1003             public View View
1004             {
1005                 get
1006                 {
1007                     return _view;
1008                 }
1009                 set
1010                 {
1011                     _view = value;
1012                 }
1013             }
1014
1015             /// <summary>
1016             /// Whether the view's layout direction property has changed or a parent's.
1017             /// </summary>
1018             /// <since_tizen> 4 </since_tizen>
1019             public ViewLayoutDirectionType Type
1020             {
1021                 get
1022                 {
1023                     return _type;
1024                 }
1025                 set
1026                 {
1027                     _type = value;
1028                 }
1029             }
1030         }
1031
1032         internal class BackgroundResourceLoadedEventArgs : EventArgs
1033         {
1034             private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1035             public ResourceLoadingStatusType Status
1036             {
1037                 get
1038                 {
1039                     return status;
1040                 }
1041                 set
1042                 {
1043                     status = value;
1044                 }
1045             }
1046         }
1047     }
1048 }