691655c68b3f44d753a9624711e57d10cfc309f7
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Window / DefaultBorder.cs
1 /*
2  * Copyright(c) 2022 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 Tizen.NUI.BaseComponents;
21 using Tizen.NUI.Binding;
22
23 namespace Tizen.NUI
24 {
25     /// <summary>
26     /// This class creates a border UI.
27     /// </summary>
28     [EditorBrowsable(EditorBrowsableState.Never)]
29     public class DefaultBorder : BindableObject, IDisposable, IBorderInterface
30     {
31         #region Constant Fields
32         private static readonly string ResourcePath = FrameworkInformation.ResourcePath;
33         private static readonly string MinimalizeIcon = ResourcePath + "minimalize.png";
34         private static readonly string MaximalizeIcon = ResourcePath + "maximalize.png";
35         private static readonly string CloseIcon = ResourcePath + "close.png";
36         private static readonly string LeftCornerIcon = ResourcePath + "leftCorner.png";
37         private static readonly string RightCornerIcon = ResourcePath + "rightCorner.png";
38
39         private static readonly string DarkMinimalizeIcon = ResourcePath + "dark_minimalize.png";
40         private static readonly string DarkPreviousIcon = ResourcePath + "dark_smallwindow.png";
41         private static readonly string DarkCloseIcon = ResourcePath + "dark_close.png";
42         private static readonly string DarkLeftCornerIcon = ResourcePath + "dark_leftCorner.png";
43         private static readonly string DarkRightCornerIcon = ResourcePath + "dark_rightCorner.png";
44
45
46         private const float DefaultHeight = 50;
47         private const uint DefaultLineThickness = 5;
48         private const uint DefaultTouchThickness = 0;
49         private static readonly Color DefaultBackgroundColor = new Color(0.7f, 0.7f, 0.7f, 0.6f);
50         private static readonly Color DefaultClickedBackgroundColor = new Color(0.7f, 0.7f, 0.7f, 0.7f);
51         private static readonly Size2D DefaultMinSize = new Size2D(100, 0);
52         #endregion //Constant Fields
53
54
55         #region Fields
56         private bool disposed = false;
57         private Color backgroundColor;
58         private View borderView;
59
60         private ImageView minimalizeIcon;
61         private ImageView maximalizeIcon;
62         private ImageView closeIcon;
63         private ImageView leftCornerIcon;
64         private ImageView rightCornerIcon;
65
66         private Window.BorderDirection direction = Window.BorderDirection.None;
67         private float preScale = 0;
68
69         private View windowView = null;
70         private Timer overlayTimer;
71
72         private uint borderLineThickness;
73         private Size2D minSize;
74         private Size2D maxSize;
75         private Window.BorderResizePolicyType resizePolicy;
76
77         #endregion //Fields
78
79         #region Events
80         private PanGestureDetector borderPanGestureDetector;
81         #endregion //Events
82
83         #region Enums
84         #endregion //Enums
85
86         #region Methods
87
88         [EditorBrowsable(EditorBrowsableState.Never)]
89         public static readonly BindableProperty BorderLineThicknessProperty = BindableProperty.Create(nameof(BorderLineThickness), typeof(uint), typeof(DefaultBorder), default(uint), propertyChanged: (bindable, oldValue, newValue) =>
90         {
91             var instance = (DefaultBorder)bindable;
92             if (newValue != null)
93             {
94                 instance.borderLineThickness = (uint)newValue;
95                 instance.UpdateProperty();
96             }
97         },
98         defaultValueCreator: (bindable) =>
99         {
100             var instance = (DefaultBorder)bindable;
101             return instance.borderLineThickness;
102         });
103
104         [EditorBrowsable(EditorBrowsableState.Never)]
105         public static readonly BindableProperty MinSizeProperty = BindableProperty.Create(nameof(MinSize), typeof(Size2D), typeof(DefaultBorder), default(Size2D), propertyChanged: (bindable, oldValue, newValue) =>
106         {
107             var instance = (DefaultBorder)bindable;
108             if (newValue != null)
109             {
110                 instance.minSize = (Size2D)newValue;
111                 instance.UpdateProperty();
112             }
113         },
114         defaultValueCreator: (bindable) =>
115         {
116             var instance = (DefaultBorder)bindable;
117             return instance.minSize;
118         });
119
120         [EditorBrowsable(EditorBrowsableState.Never)]
121         public static readonly BindableProperty MaxSizeProperty = BindableProperty.Create(nameof(MaxSize), typeof(Size2D), typeof(DefaultBorder), default(Size2D), propertyChanged: (bindable, oldValue, newValue) =>
122         {
123             var instance = (DefaultBorder)bindable;
124             if (newValue != null)
125             {
126                 instance.maxSize = (Size2D)newValue;
127                 instance.UpdateProperty();
128             }
129         },
130         defaultValueCreator: (bindable) =>
131         {
132             var instance = (DefaultBorder)bindable;
133             return instance.maxSize;
134         });
135
136         [EditorBrowsable(EditorBrowsableState.Never)]
137         public static readonly BindableProperty ResizePolicyProperty = BindableProperty.Create(nameof(ResizePolicy), typeof(Window.BorderResizePolicyType), typeof(DefaultBorder), default(Window.BorderResizePolicyType), propertyChanged: (bindable, oldValue, newValue) =>
138         {
139             var instance = (DefaultBorder)bindable;
140             if (newValue != null)
141             {
142                 instance.resizePolicy = (Window.BorderResizePolicyType)newValue;
143                 instance.UpdateProperty();
144             }
145         },
146         defaultValueCreator: (bindable) =>
147         {
148             var instance = (DefaultBorder)bindable;
149             return instance.resizePolicy;
150         });
151
152
153         /// <summary>
154         /// The thickness of the border.
155         /// </summary>
156         [EditorBrowsable(EditorBrowsableState.Never)]
157         public uint BorderLineThickness
158         {
159             get
160             {
161                 return (uint)GetValue(BorderLineThicknessProperty);
162             }
163             set
164             {
165                 SetValue(BorderLineThicknessProperty, value);
166             }
167         }
168
169         /// <summary>
170         /// The thickness of the border's touch area.
171         /// </summary>
172         [EditorBrowsable(EditorBrowsableState.Never)]
173         public uint TouchThickness {get; set;}
174
175         /// <summary>
176         /// The height of the border.
177         /// This value is the initial value used when creating borders.
178         /// </summary>
179         [EditorBrowsable(EditorBrowsableState.Never)]
180         public float BorderHeight {get; set;}
181
182         /// <summary>
183         /// The minimum size by which the window will small.
184         /// </summary>
185         [EditorBrowsable(EditorBrowsableState.Never)]
186         public Size2D MinSize
187         {
188             get
189             {
190                 return (Size2D)GetValue(MinSizeProperty);
191             }
192             set
193             {
194                 SetValue(MinSizeProperty, value);
195             }
196         }
197
198         /// <summary>
199         /// The maximum size by which the window will big.
200         /// </summary>
201         [EditorBrowsable(EditorBrowsableState.Never)]
202         public Size2D MaxSize
203         {
204             get
205             {
206                 return (Size2D)GetValue(MaxSizeProperty);
207             }
208             set
209             {
210                 SetValue(MaxSizeProperty, value);
211             }
212         }
213
214         /// <summary>
215         /// The window with borders added.
216         /// </summary>
217         [EditorBrowsable(EditorBrowsableState.Never)]
218         public Window BorderWindow {get; set;}
219
220         /// <summary>
221         /// Whether overlay mode.
222         /// If overlay mode is true, the border area is hidden when the window is maximized.
223         /// And if you touched at screen, the border area is shown on the screen.
224         /// Default value is false;
225         /// </summary>
226         [EditorBrowsable(EditorBrowsableState.Never)]
227         public bool OverlayMode {get; set;}
228
229         /// <summary>
230         /// Set the window resizing policy.
231         /// Default value is BorderResizePolicyType.Free;
232         /// </summary>
233         [EditorBrowsable(EditorBrowsableState.Never)]
234         public Window.BorderResizePolicyType ResizePolicy
235         {
236             get
237             {
238                 return (Window.BorderResizePolicyType)GetValue(ResizePolicyProperty);
239             }
240             set
241             {
242                 SetValue(ResizePolicyProperty, value);
243             }
244         }
245
246         /// <summary>
247         /// Update properties
248         /// </summary>
249         [EditorBrowsable(EditorBrowsableState.Never)]
250         public void UpdateProperty()
251         {
252             BorderWindow?.UpdateProperty();
253         }
254
255         /// <summary>
256         /// Creates a default border
257         /// </summary>
258         [EditorBrowsable(EditorBrowsableState.Never)]
259         public DefaultBorder() : base()
260         {
261             BorderLineThickness = DefaultLineThickness;
262             TouchThickness = DefaultTouchThickness;
263             BorderHeight = DefaultHeight;
264             MinSize = DefaultMinSize;
265             OverlayMode = false;
266             ResizePolicy = Window.BorderResizePolicyType.Free;
267         }
268
269         /// <summary>
270         /// Create top border UI. User can override this method to draw top border UI.
271         /// </summary>
272         /// <param name="topView">The top view on which the border.</param>
273         [EditorBrowsable(EditorBrowsableState.Never)]
274         public virtual bool CreateTopBorderView(View topView)
275         {
276             return false;
277         }
278
279         /// <summary>
280         /// Create bottom border UI. User can override this method to draw bottom border UI.
281         /// </summary>
282         /// <param name="bottomView">The bottom view on which the border.</param>
283         [EditorBrowsable(EditorBrowsableState.Never)]
284         public virtual bool CreateBottomBorderView(View bottomView)
285         {
286             if (bottomView == null)
287             {
288                 return false;
289             }
290             bottomView.Layout = new RelativeLayout();
291
292             minimalizeIcon = new ImageView()
293             {
294                 Focusable = true,
295                 ResourceUrl = MinimalizeIcon,
296                 AccessibilityHighlightable = true,
297             };
298
299             maximalizeIcon = new ImageView()
300             {
301                 Focusable = true,
302                 ResourceUrl = MaximalizeIcon,
303                 AccessibilityHighlightable = true,
304             };
305
306             closeIcon = new ImageView()
307             {
308                 Focusable = true,
309                 ResourceUrl = CloseIcon,
310                 AccessibilityHighlightable = true,
311             };
312
313             leftCornerIcon = new ImageView()
314             {
315                 Focusable = true,
316                 ResourceUrl = LeftCornerIcon,
317                 AccessibilityHighlightable = true,
318             };
319
320             rightCornerIcon = new ImageView()
321             {
322                 Focusable = true,
323                 ResourceUrl = RightCornerIcon,
324                 AccessibilityHighlightable = true,
325             };
326
327             RelativeLayout.SetRightTarget(minimalizeIcon, maximalizeIcon);
328             RelativeLayout.SetRightRelativeOffset(minimalizeIcon, 0.0f);
329             RelativeLayout.SetHorizontalAlignment(minimalizeIcon, RelativeLayout.Alignment.End);
330             RelativeLayout.SetRightTarget(maximalizeIcon, closeIcon);
331             RelativeLayout.SetRightRelativeOffset(maximalizeIcon, 0.0f);
332             RelativeLayout.SetHorizontalAlignment(maximalizeIcon, RelativeLayout.Alignment.End);
333             RelativeLayout.SetRightTarget(closeIcon, rightCornerIcon);
334             RelativeLayout.SetRightRelativeOffset(closeIcon, 0.0f);
335             RelativeLayout.SetHorizontalAlignment(closeIcon, RelativeLayout.Alignment.End);
336             RelativeLayout.SetRightRelativeOffset(rightCornerIcon, 1.0f);
337             RelativeLayout.SetHorizontalAlignment(rightCornerIcon, RelativeLayout.Alignment.End);
338             bottomView.Add(leftCornerIcon);
339             bottomView.Add(minimalizeIcon);
340             bottomView.Add(maximalizeIcon);
341             bottomView.Add(closeIcon);
342             bottomView.Add(rightCornerIcon);
343
344
345             minimalizeIcon.TouchEvent += OnMinimizeIconTouched;
346             maximalizeIcon.TouchEvent += OnMaximizeIconTouched;
347             closeIcon.TouchEvent += OnCloseIconTouched;
348             leftCornerIcon.TouchEvent += OnLeftBottomCornerIconTouched;
349             rightCornerIcon.TouchEvent += OnRightBottomCornerIconTouched;
350
351             minimalizeIcon.AccessibilityActivated += (s, e) =>
352             {
353                 MinimizeBorderWindow();
354             };
355             maximalizeIcon.AccessibilityActivated += (s, e) =>
356             {
357                 MaximizeBorderWindow();
358             };
359             closeIcon.AccessibilityActivated += (s, e) =>
360             {
361                 CloseBorderWindow();
362             };
363
364             minimalizeIcon.AccessibilityNameRequested += (s, e) =>
365             {
366                 e.Name = "Minimize";
367             };
368             maximalizeIcon.AccessibilityNameRequested += (s, e) =>
369             {
370                 e.Name = "Maximize";
371             };
372             closeIcon.AccessibilityNameRequested += (s, e) =>
373             {
374                 e.Name = "Close";
375             };
376             leftCornerIcon.AccessibilityNameRequested += (s, e) =>
377             {
378                 e.Name = "Resize";
379             };
380             rightCornerIcon.AccessibilityNameRequested += (s, e) =>
381             {
382                 e.Name = "Resize";
383             };
384
385             minimalizeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
386             maximalizeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
387             closeIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
388             leftCornerIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
389             rightCornerIcon.SetAccessibilityReadingInfoTypes(Tizen.NUI.BaseComponents.AccessibilityReadingInfoTypes.Name);
390
391             return true;
392         }
393
394
395         /// <summary>
396         /// Create border UI. User can override this method to draw border UI.
397         /// A top border and a bottom border are added to this view.
398         /// </summary>
399         /// <param name="borderView">The root view on which the border.</param>
400         [EditorBrowsable(EditorBrowsableState.Never)]
401         public virtual void CreateBorderView(View borderView)
402         {
403             if (borderView == null)
404             {
405                 return;
406             }
407
408             if (string.IsNullOrEmpty(borderView.BackgroundImage))
409             {
410                 borderView.BackgroundColor = DefaultBackgroundColor;
411             }
412             borderView.BorderlineColor = new Color(0.5f, 0.5f, 0.5f, 0.3f);
413             borderView.BorderlineWidth = 1.0f;
414             borderView.BorderlineOffset = -1f;
415             borderView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f);
416             borderView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
417
418             // Register touch event for effect when border is touched.
419             borderView.LeaveRequired = true;
420             borderView.TouchEvent += OnBorderViewTouched;
421             this.borderView = borderView;
422         }
423
424         private bool OnBorderViewTouched(object sender, View.TouchEventArgs e)
425         {
426             if (string.IsNullOrEmpty(borderView.BackgroundImage))
427             {
428                 if (e.Touch.GetState(0) == PointStateType.Started)
429                 {
430                     backgroundColor = new Color(borderView.BackgroundColor);
431                     borderView.BackgroundColor = DefaultClickedBackgroundColor;
432                 }
433                 else if (e.Touch.GetState(0) == PointStateType.Finished ||
434                         e.Touch.GetState(0) == PointStateType.Leave ||
435                         e.Touch.GetState(0) == PointStateType.Interrupted)
436                 {
437                     borderView.BackgroundColor = backgroundColor;
438                 }
439             }
440             return true;
441         }
442
443         /// Determines the behavior of pinch gesture.
444         private void OnPinchGestureDetected(object source, PinchGestureDetector.DetectedEventArgs e)
445         {
446             if (e == null)
447             {
448                 return;
449             }
450             if (e.PinchGesture.State == Gesture.StateType.Started)
451             {
452                 preScale = e.PinchGesture.Scale;
453             }
454             else if (e.PinchGesture.State == Gesture.StateType.Finished || e.PinchGesture.State == Gesture.StateType.Cancelled)
455             {
456                 if (preScale > e.PinchGesture.Scale)
457                 {
458                     if (BorderWindow.IsMaximized())
459                     {
460                         BorderWindow.Maximize(false);
461                     }
462                     else
463                     {
464                         BorderWindow.Minimize(true);
465                         OnMinimize(true);
466                     }
467                 }
468                 else
469                 {
470                     BorderWindow.Maximize(true);
471                 }
472             }
473         }
474
475         /// Determines the behavior of borders.
476         private void OnPanGestureDetected(object source, PanGestureDetector.DetectedEventArgs e)
477         {
478             if (e == null)
479             {
480                 return;
481             }
482             PanGesture panGesture = e.PanGesture;
483
484             if (panGesture.State == Gesture.StateType.Started && panGesture.Position != null)
485             {
486                 direction = BorderWindow.GetDirection(panGesture.Position.X, panGesture.Position.Y);
487
488                 if (direction == Window.BorderDirection.Move)
489                 {
490                     if (BorderWindow.IsMaximized() == true)
491                     {
492                         BorderWindow.Maximize(false);
493                     }
494                     else
495                     {
496                         OnRequestMove();
497                         BorderWindow.RequestMoveToServer();
498                     }
499                 }
500                 else if (direction != Window.BorderDirection.None && ResizePolicy != Window.BorderResizePolicyType.Fixed)
501                 {
502                     OnRequestResize();
503                     BorderWindow.RequestResizeToServer((Window.ResizeDirection)direction);
504                 }
505             }
506             else if (panGesture.State == Gesture.StateType.Finished || panGesture.State == Gesture.StateType.Cancelled)
507             {
508                 direction = Window.BorderDirection.None;
509             }
510         }
511
512         /// <summary>
513         /// This is an event callback when the left top corner icon is touched.
514         /// </summary>
515         [EditorBrowsable(EditorBrowsableState.Never)]
516         public virtual bool OnLeftTopCornerIconTouched(object sender, View.TouchEventArgs e)
517         {
518             SetDispatchParentGestureEvents(sender as View, false);
519             if (e != null && e.Touch.GetState(0) == PointStateType.Down)
520             {
521               if (ResizePolicy != Window.BorderResizePolicyType.Fixed)
522               {
523                 OnRequestResize();
524                 BorderWindow.RequestResizeToServer(Window.ResizeDirection.TopLeft);
525               }
526             }
527             return true;
528         }
529
530         /// <summary>
531         ///This is an event callback when the right bottom corner icon is touched.
532         /// </summary>
533         [EditorBrowsable(EditorBrowsableState.Never)]
534         public virtual bool OnRightTopCornerIconTouched(object sender, View.TouchEventArgs e)
535         {
536             SetDispatchParentGestureEvents(sender as View, false);
537             if (e != null && e.Touch.GetState(0) == PointStateType.Down)
538             {
539               if (ResizePolicy != Window.BorderResizePolicyType.Fixed)
540               {
541                 OnRequestResize();
542                 BorderWindow.RequestResizeToServer(Window.ResizeDirection.TopRight);
543               }
544             }
545             return true;
546         }
547
548
549         /// <summary>
550         /// This is an event callback when the left bottom corner icon is touched.
551         /// </summary>
552         [EditorBrowsable(EditorBrowsableState.Never)]
553         public virtual bool OnLeftBottomCornerIconTouched(object sender, View.TouchEventArgs e)
554         {
555             SetDispatchParentGestureEvents(sender as View, false);
556             if (e != null && e.Touch.GetState(0) == PointStateType.Down)
557             {
558               if (ResizePolicy != Window.BorderResizePolicyType.Fixed)
559               {
560                 OnRequestResize();
561                 BorderWindow.RequestResizeToServer(Window.ResizeDirection.BottomLeft);
562               }
563             }
564             return true;
565         }
566
567         /// <summary>
568         ///This is an event callback when the right bottom corner icon is touched.
569         /// </summary>
570         [EditorBrowsable(EditorBrowsableState.Never)]
571         public virtual bool OnRightBottomCornerIconTouched(object sender, View.TouchEventArgs e)
572         {
573             SetDispatchParentGestureEvents(sender as View, false);
574             if (e != null && e.Touch.GetState(0) == PointStateType.Down)
575             {
576               if (ResizePolicy != Window.BorderResizePolicyType.Fixed)
577               {
578                 OnRequestResize();
579                 BorderWindow.RequestResizeToServer(Window.ResizeDirection.BottomRight);
580               }
581             }
582             return true;
583         }
584
585
586         /// <summary>
587         /// Minimize border window.
588         /// </summary>
589         [EditorBrowsable(EditorBrowsableState.Never)]
590         protected void MinimizeBorderWindow()
591         {
592             BorderWindow.Minimize(true);
593             OnMinimize(true);
594         }
595
596         /// <summary>
597         /// This is an event callback when the minimize icon is touched.
598         /// </summary>
599         [EditorBrowsable(EditorBrowsableState.Never)]
600         public virtual bool OnMinimizeIconTouched(object sender, View.TouchEventArgs e)
601         {
602             SetDispatchParentGestureEvents(sender as View, false);
603             if (e != null && e.Touch.GetState(0) == PointStateType.Up)
604             {
605                 MinimizeBorderWindow();
606             }
607             return true;
608         }
609
610         /// <summary>
611         /// Maximize border window.
612         /// </summary>
613         [EditorBrowsable(EditorBrowsableState.Never)]
614         protected void MaximizeBorderWindow()
615         {
616             if (BorderWindow.IsMaximized())
617             {
618               BorderWindow.Maximize(false);
619             }
620             else
621             {
622               BorderWindow.Maximize(true);
623             }
624         }
625
626         /// <summary>
627         /// This is an event callback when the maximum icon is touched.
628         /// </summary>
629         [EditorBrowsable(EditorBrowsableState.Never)]
630         public virtual bool OnMaximizeIconTouched(object sender, View.TouchEventArgs e)
631         {
632             SetDispatchParentGestureEvents(sender as View, false);
633             if (e != null && e.Touch.GetState(0) == PointStateType.Up)
634             {
635                 MaximizeBorderWindow();
636             }
637             return true;
638         }
639
640         /// <summary>
641         /// Close border window.
642         /// </summary>
643         [EditorBrowsable(EditorBrowsableState.Never)]
644         protected void CloseBorderWindow()
645         {
646             BorderWindow.BorderDestroy();
647         }
648
649         /// <summary>
650         /// This is an event callback when the close icon is touched.
651         /// </summary>
652         [EditorBrowsable(EditorBrowsableState.Never)]
653         public virtual bool OnCloseIconTouched(object sender, View.TouchEventArgs e)
654         {
655             SetDispatchParentGestureEvents(sender as View, false);
656             if (e != null && e.Touch.GetState(0) == PointStateType.Up)
657             {
658                 CloseBorderWindow();
659             }
660             return true;
661         }
662
663         private void SetDispatchParentGestureEvents(View view, bool dispatch)
664         {
665             if (view != null)
666             {
667                 // If this is set, my parents will not receive gesture events.
668                 // This is to prevent the move action by PanGesture when the icon is touched.
669                 view.DispatchParentGestureEvents = dispatch;
670             }
671         }
672
673
674         private void UpdateIcons()
675         {
676             if (BorderWindow != null && borderView != null)
677             {
678                 if (BorderWindow.IsMaximized() == true)
679                 {
680                     if (maximalizeIcon != null)
681                     {
682                         maximalizeIcon.ResourceUrl = DarkPreviousIcon;
683                     }
684                     if (minimalizeIcon != null)
685                     {
686                         minimalizeIcon.ResourceUrl = DarkMinimalizeIcon;
687                     }
688                     if (closeIcon != null)
689                     {
690                         closeIcon.ResourceUrl = DarkCloseIcon;
691                     }
692                     if (leftCornerIcon != null)
693                     {
694                         leftCornerIcon.ResourceUrl = DarkLeftCornerIcon;
695                     }
696                     if (rightCornerIcon != null)
697                     {
698                         rightCornerIcon.ResourceUrl = DarkRightCornerIcon;
699                     }
700                     borderView.CornerRadius = new Vector4(0, 0, 0, 0);
701                     borderView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
702                 }
703                 else
704                 {
705                     if (maximalizeIcon != null)
706                     {
707                         maximalizeIcon.ResourceUrl = MaximalizeIcon;
708                     }
709                     if (minimalizeIcon != null)
710                     {
711                         minimalizeIcon.ResourceUrl = MinimalizeIcon;
712                     }
713                     if (closeIcon != null)
714                     {
715                         closeIcon.ResourceUrl = CloseIcon;
716                     }
717                     if (leftCornerIcon != null)
718                     {
719                         leftCornerIcon.ResourceUrl = LeftCornerIcon;
720                     }
721                     if (rightCornerIcon != null)
722                     {
723                         rightCornerIcon.ResourceUrl = RightCornerIcon;
724                     }
725                     borderView.CornerRadius = new Vector4(0.03f, 0.03f, 0.03f, 0.03f);
726                     borderView.CornerRadiusPolicy = VisualTransformPolicyType.Relative;
727                 }
728             }
729         }
730
731         /// <summary>
732         /// Called after the border UI is created.
733         /// </summary>
734         /// <param name="borderView">The border view on which the border.</param>
735         [EditorBrowsable(EditorBrowsableState.Never)]
736         public virtual void OnCreated(View borderView)
737         {
738             if (borderView == null)
739             {
740                 return;
741             }
742             this.borderView = borderView;
743
744             BorderWindow.BackgroundColor = Color.Transparent;
745
746             // Register to resize and move through pan gestures.
747             borderPanGestureDetector = new PanGestureDetector();
748             borderPanGestureDetector.Attach(borderView);
749             borderPanGestureDetector.Detected += OnPanGestureDetected;
750
751             UpdateIcons();
752         }
753
754         /// <summary>
755         /// Called when requesting a resize
756         /// </summary>
757         [EditorBrowsable(EditorBrowsableState.Never)]
758         public virtual void OnRequestResize() {}
759
760         /// <summary>
761         /// Called when the window is resized.
762         /// </summary>
763         /// <param name="width">The width of the resized window</param>
764         /// <param name="height">The height of the resized window</param>
765         [EditorBrowsable(EditorBrowsableState.Never)]
766         public virtual void OnResized(int width, int height)
767         {
768             if (overlayTimer != null)
769             {
770                 overlayTimer.Stop();
771                 overlayTimer.Dispose();
772                 overlayTimer = null;
773             }
774             UpdateIcons();
775         }
776
777         /// <summary>
778         /// Called when requesting a move
779         /// </summary>
780         [EditorBrowsable(EditorBrowsableState.Never)]
781         public virtual void OnRequestMove() {}
782
783         /// <summary>
784         /// Called when the window is moved.
785         /// </summary>
786         /// <param name="x">The x of the moved window</param>
787         /// <param name="y">The y of the moved window</param>
788         [EditorBrowsable(EditorBrowsableState.Never)]
789         public virtual void OnMoved(int x, int y) {}
790
791         /// <summary>
792         /// Called when window has been moved the display server.
793         /// </summary>
794         /// <param name="x">The x of the has been moved window</param>
795         /// <param name="y">The y of the has been moved window</param>
796         [EditorBrowsable(EditorBrowsableState.Never)]
797         public virtual void OnMoveCompleted(int x, int y) {}
798
799         /// <summary>
800         /// Called when window has been resized the display server.
801         /// </summary>
802         /// <param name="width">The width of the resized window</param>
803         /// <param name="height">The height of the resized window</param>
804         [EditorBrowsable(EditorBrowsableState.Never)]
805         public virtual void OnResizeCompleted(int width, int height) {}
806
807         /// <summary>
808         /// Called when the window is maximized.
809         /// </summary>
810         /// <param name="isMaximized">If window is maximized or unmaximized.</param>
811         [EditorBrowsable(EditorBrowsableState.Never)]
812         public virtual void OnMaximize(bool isMaximized)
813         {
814             Tizen.Log.Info("NUI", $"OnMaximize {isMaximized}\n");
815             if (BorderWindow.IsMaximized() == true)
816             {
817                 BorderWindow.SetTransparency(false);
818             }
819             else
820             {
821                 BorderWindow.SetTransparency(true);
822             }
823
824         }
825
826         /// <summary>
827         /// Called when the window is minimized.
828         /// </summary>
829         /// <param name="isMinimized">If window is mnimized or unminimized.</param>
830         [EditorBrowsable(EditorBrowsableState.Never)]
831         public virtual void OnMinimize(bool isMinimized)
832         {
833             UpdateIcons();
834         }
835
836         /// <summary>
837         /// Called when there is a change in overlay mode.
838         /// </summary>
839         /// <param name="enabled">If true, borderView has entered overlayMode.</param>
840         [EditorBrowsable(EditorBrowsableState.Never)]
841         public virtual void OnOverlayMode(bool enabled)
842         {
843             if (borderView != null && OverlayMode == true)
844             {
845                 Tizen.Log.Info("NUI", $"OnOverlayMode {enabled}\n");
846                 if (enabled == true)
847                 {
848                     backgroundColor = new Color(borderView.BackgroundColor);
849                     if (string.IsNullOrEmpty(borderView.BackgroundImage))
850                     {
851                         borderView.BackgroundColor = Color.Transparent;
852                     }
853                     borderView.Hide();
854                 }
855                 else
856                 {
857                     if (string.IsNullOrEmpty(borderView.BackgroundImage))
858                     {
859                         borderView.BackgroundColor = backgroundColor;
860                     }
861                     borderView.Show();
862                 }
863             }
864         }
865
866         /// <summary>
867         /// Show the border when OverlayMode is true and the window is now Maximize.
868         /// </summary>
869         /// <param name="time">Time(ms) for borders to disappear again</param>
870         /// <returns>True if border became show, false otherwise</returns>
871         [EditorBrowsable(EditorBrowsableState.Never)]
872         public virtual bool OverlayBorderShow(uint time = 3000)
873         {
874             if (BorderWindow != null && BorderWindow.IsMaximized())
875             {
876                 if (overlayTimer == null)
877                 {
878                     overlayTimer = new Timer(time);
879                     overlayTimer.Tick += (s, e) =>
880                     {
881                         borderView?.Hide();
882                         overlayTimer?.Stop();
883                         overlayTimer?.Dispose();
884                         overlayTimer = null;
885                         return false;
886                     };
887                     overlayTimer.Start();
888                     borderView?.Show();
889                 }
890                 else
891                 {
892                     overlayTimer.Start();
893                 }
894                 return true;
895             }
896             return false;
897         }
898
899         /// <summary>
900         /// Hide the border when OverlayMode is true and the window is now Maximize.
901         /// </summary>
902         /// <returns>True if border became hide, false otherwise</returns>
903         [EditorBrowsable(EditorBrowsableState.Never)]
904         public virtual bool OverlayBorderHide()
905         {
906             if (BorderWindow != null && BorderWindow.IsMaximized())
907             {
908                 borderView?.Hide();
909                 overlayTimer?.Stop();
910                 overlayTimer?.Dispose();
911                 overlayTimer = null;
912                 return true;
913             }
914             return false;
915         }
916
917         [EditorBrowsable(EditorBrowsableState.Never)]
918         public void Dispose()
919         {
920             Dispose(true);
921             global::System.GC.SuppressFinalize(this);
922         }
923
924         protected virtual void Dispose(bool disposing)
925         {
926             if (disposed)
927             {
928                 return;
929             }
930
931             if (disposing)
932             {
933                 borderView?.Dispose();
934                 windowView?.Dispose();
935                 borderPanGestureDetector?.Dispose();
936                 backgroundColor?.Dispose();
937                 minimalizeIcon?.Dispose();
938                 maximalizeIcon?.Dispose();
939                 closeIcon?.Dispose();
940                 leftCornerIcon?.Dispose();
941                 rightCornerIcon?.Dispose();
942                 overlayTimer?.Dispose();
943             }
944             disposed = true;
945         }
946
947         #endregion //Methods
948
949     }
950 }