[NUI] Open the APIs of Button/CheckBox/RadioButton/Slider/Switch (#1722)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / Button.cs
1 /*
2  * Copyright(c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 using System;
18 using System.ComponentModel;
19 using Tizen.NUI.BaseComponents;
20 using Tizen.NUI.Binding;
21 using Tizen.NUI.Components.Extension;
22
23 namespace Tizen.NUI.Components
24 {
25     /// <summary>
26     /// Button is one kind of common component, a button clearly describes what action will occur when the user selects it.
27     /// Button may contain text or an icon.
28     /// </summary>
29     /// <since_tizen> 6 </since_tizen>
30     public partial class Button : Control
31     {
32         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
33         [EditorBrowsable(EditorBrowsableState.Never)]
34         public static readonly BindableProperty IconRelativeOrientationProperty = BindableProperty.Create(nameof(IconRelativeOrientation), typeof(IconOrientation?), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) =>
35         {
36             var instance = (Button)bindable;
37             if (newValue != null)
38             {
39                 if (instance.Style != null && instance.Style.IconRelativeOrientation != (IconOrientation?)newValue)
40                 {
41                     instance.Style.IconRelativeOrientation = (IconOrientation?)newValue;
42                     instance.UpdateUIContent();
43                 }
44             }
45         },
46         defaultValueCreator: (bindable) =>
47         {
48             var instance = (Button)bindable;
49             return instance.Style?.IconRelativeOrientation;
50         });
51         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
52         [EditorBrowsable(EditorBrowsableState.Never)]
53         public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
54         {
55             var instance = (Button)bindable;
56             if (newValue != null)
57             {
58                 instance.isEnabled = (bool)newValue;
59                 instance.UpdateState();
60             }
61         },
62         defaultValueCreator: (bindable) =>
63         {
64             var instance = (Button)bindable;
65             return instance.isEnabled;
66         });
67         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
68         [EditorBrowsable(EditorBrowsableState.Never)]
69         public static readonly BindableProperty IsSelectedProperty = BindableProperty.Create(nameof(IsSelected), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
70         {
71             var instance = (Button)bindable;
72             if (newValue != null)
73             {
74                 instance.isSelected = (bool)newValue;
75                 instance.UpdateState();
76             }
77         },
78         defaultValueCreator: (bindable) =>
79         {
80             var instance = (Button)bindable;
81             return instance.isSelected;
82         });
83         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
84         [EditorBrowsable(EditorBrowsableState.Never)]
85         public static readonly BindableProperty IsSelectableProperty = BindableProperty.Create(nameof(IsSelectable), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
86         {
87             var instance = (Button)bindable;
88             if (newValue != null)
89             {
90                 instance.Style.IsSelectable = (bool)newValue;
91             }
92         },
93         defaultValueCreator: (bindable) =>
94         {
95             var instance = (Button)bindable;
96             return instance.Style?.IsSelectable ?? false;
97         });
98         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
99         [EditorBrowsable(EditorBrowsableState.Never)]
100         public static readonly BindableProperty IconPaddingProperty = BindableProperty.Create(nameof(IconPadding), typeof(Extents), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) =>
101         {
102             var instance = (Button)bindable;
103             if (null != newValue && null != instance.Style?.IconPadding)
104             {
105                 instance.Style.IconPadding.CopyFrom((Extents)newValue);
106                 instance.UpdateUIContent();
107             }
108         },
109         defaultValueCreator: (bindable) =>
110         {
111             var instance = (Button)bindable;
112             return instance.Style?.IconPadding;
113         });
114         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
115         [EditorBrowsable(EditorBrowsableState.Never)]
116         public static readonly BindableProperty TextPaddingProperty = BindableProperty.Create(nameof(TextPadding), typeof(Extents), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) =>
117         {
118             var instance = (Button)bindable;
119             if (null != newValue && null != instance.Style?.TextPadding)
120             {
121                 instance.Style.TextPadding.CopyFrom((Extents)newValue);
122                 instance.UpdateUIContent();
123             }
124         },
125         defaultValueCreator: (bindable) =>
126         {
127             var instance = (Button)bindable;
128             return instance.Style?.TextPadding;
129         });
130
131         static Button() { }
132
133         /// <summary>
134         /// Creates a new instance of a Button.
135         /// </summary>
136         /// <since_tizen> 6 </since_tizen>
137         public Button() : base()
138         {
139             Initialize();
140         }
141
142         /// <summary>
143         /// Creates a new instance of a Button with style.
144         /// </summary>
145         /// <param name="style">Create Button by special style defined in UX.</param>
146         /// <since_tizen> 8 </since_tizen>
147         public Button(string style) : base(style)
148         {
149             Initialize();
150         }
151
152         /// <summary>
153         /// Creates a new instance of a Button with style.
154         /// </summary>
155         /// <param name="buttonStyle">Create Button by style customized by user.</param>
156         /// <since_tizen> 8 </since_tizen>
157         public Button(ButtonStyle buttonStyle) : base(buttonStyle)
158         {
159             Initialize();
160         }
161
162         /// <summary>
163         /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
164         /// </summary>
165         /// <since_tizen> 6 </since_tizen>
166         public event EventHandler<ClickEventArgs> ClickEvent;
167
168         /// <summary>
169         /// An event for the button state changed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
170         /// </summary>
171         /// <since_tizen> 6 </since_tizen>
172         public event EventHandler<StateChangedEventArgs> StateChangedEvent
173         {
174             add
175             {
176                 stateChangeHander += value;
177             }
178             remove
179             {
180                 stateChangeHander -= value;
181             }
182         }
183
184         /// <summary>
185         /// Icon orientation.
186         /// </summary>
187         /// <since_tizen> 6 </since_tizen>
188         public enum IconOrientation
189         {
190             /// <summary>
191             /// Top.
192             /// </summary>
193             /// <since_tizen> 6 </since_tizen>
194             Top,
195             /// <summary>
196             /// Bottom.
197             /// </summary>
198             /// <since_tizen> 6 </since_tizen>
199             Bottom,
200             /// <summary>
201             /// Left.
202             /// </summary>
203             /// <since_tizen> 6 </since_tizen>
204             Left,
205             /// <summary>
206             /// Right.
207             /// </summary>
208             /// <since_tizen> 6 </since_tizen>
209             Right,
210         }
211
212         /// <summary>
213         /// Button's icon part.
214         /// </summary>
215         /// <since_tizen> 8 </since_tizen>
216         public ImageView Icon
217         {
218             get
219             {
220                 if (null == buttonIcon)
221                 {
222                     buttonIcon = CreateIcon();
223                     if (null != Extension)
224                     {
225                         buttonIcon = Extension.OnCreateIcon(this, buttonIcon);
226                     }
227                     Add(buttonIcon);
228                     buttonIcon.Relayout += OnIconRelayout;
229                 }
230                 return buttonIcon;
231             }
232             internal set
233             {
234                 buttonIcon = value;
235             }
236         }
237
238         /// <summary>
239         /// Button's overlay image part.
240         /// </summary>
241         /// <since_tizen> 8 </since_tizen>
242         public ImageView OverlayImage
243         {
244             get
245             {
246                 if (null == overlayImage)
247                 {
248                     overlayImage = CreateOverlayImage();
249                     if (null != Extension)
250                     {
251                         overlayImage = Extension.OnCreateOverlayImage(this, overlayImage);
252                     }
253                     overlayImage.WidthResizePolicy = ResizePolicyType.FillToParent;
254                     overlayImage.HeightResizePolicy = ResizePolicyType.FillToParent;
255                     Add(overlayImage);
256                 }
257                 return overlayImage;
258             }
259             internal set
260             {
261                 overlayImage = value;
262             }
263         }
264
265         /// <summary>
266         /// Button's text part.
267         /// </summary>
268         /// <since_tizen> 8 </since_tizen>
269         public TextLabel TextLabel
270         {
271             get
272             {
273                 if (null == buttonText)
274                 {
275                     buttonText = CreateText();
276                     if (null != Extension)
277                     {
278                         buttonText = Extension.OnCreateText(this, buttonText);
279                     }
280                     buttonText.HorizontalAlignment = HorizontalAlignment.Center;
281                     buttonText.VerticalAlignment = VerticalAlignment.Center;
282                     Add(buttonText);
283                 }
284                 return buttonText;
285             }
286             internal set
287             {
288                 buttonText = value;
289             }
290         }
291
292         /// <summary>
293         /// Return a copied Style instance of Button
294         /// </summary>
295         /// <remarks>
296         /// It returns copied Style instance and changing it does not effect to the Button.
297         /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
298         /// </remarks>
299         /// <since_tizen> 8 </since_tizen>
300         public new ButtonStyle Style => ViewStyle as ButtonStyle;
301
302         /// <summary>
303         /// The text of Button.
304         /// </summary>
305         /// <since_tizen> 6 </since_tizen>
306         public string Text
307         {
308             get
309             {
310                 return Style?.Text?.Text?.GetValue(ControlState);
311             }
312             set
313             {
314                 if (null != Style?.Text)
315                 {
316                     Style.Text.Text = value;
317                 }
318             }
319         }
320
321         /// <summary>
322         /// Flag to decide Button can be selected or not.
323         /// </summary>
324         /// <since_tizen> 6 </since_tizen>
325         public bool IsSelectable
326         {
327             get
328             {
329                 return (bool)GetValue(IsSelectableProperty);
330             }
331             set
332             {
333                 SetValue(IsSelectableProperty, value);
334             }
335         }
336
337         /// <summary>
338         /// Translate text string in Button.
339         /// </summary>
340         /// <since_tizen> 6 </since_tizen>
341         public string TranslatableText
342         {
343             get
344             {
345                 return Style?.Text?.TranslatableText?.All;
346             }
347             set
348             {
349                 if (null != Style?.Text)
350                 {
351                     Style.Text.TranslatableText = value;
352                 }
353             }
354         }
355
356         /// <summary>
357         /// Text point size in Button.
358         /// </summary>
359         /// <since_tizen> 6 </since_tizen>
360         public float PointSize
361         {
362             get
363             {
364                 return Style?.Text?.PointSize?.All ?? 0;
365             }
366             set
367             {
368                 if (null != Style?.Text)
369                 {
370                     Style.Text.PointSize = value;
371                 }
372             }
373         }
374
375         /// <summary>
376         /// Text font family in Button.
377         /// </summary>
378         /// <since_tizen> 6 </since_tizen>
379         public string FontFamily
380         {
381             get
382             {
383                 return Style?.Text?.FontFamily.All;
384             }
385             set
386             {
387                 if (null != Style?.Text)
388                 {
389                     Style.Text.FontFamily = value;
390                 }
391             }
392         }
393
394         /// <summary>
395         /// Text color in Button.
396         /// </summary>
397         /// <since_tizen> 6 </since_tizen>
398         public Color TextColor
399         {
400             get
401             {
402                 return Style?.Text?.TextColor?.All;
403             }
404             set
405             {
406                 if (null != Style?.Text)
407                 {
408                     Style.Text.TextColor = value;
409                 }
410             }
411         }
412
413         /// <summary>
414         /// Text horizontal alignment in Button.
415         /// </summary>
416         /// <since_tizen> 6 </since_tizen>
417         public HorizontalAlignment TextAlignment
418         {
419             get
420             {
421                 return Style?.Text?.HorizontalAlignment ?? HorizontalAlignment.Center;
422             }
423             set
424             {
425                 if (null != Style?.Text)
426                 {
427                     Style.Text.HorizontalAlignment = value;
428                 }
429             }
430         }
431
432         /// <summary>
433         /// Icon image's resource url in Button.
434         /// </summary>
435         /// <since_tizen> 6 </since_tizen>
436         public string IconURL
437         {
438             get
439             {
440                 return Style?.Icon?.ResourceUrl?.All;
441             }
442             set
443             {
444                 if (null != Style?.Icon)
445                 {
446                     Style.Icon.ResourceUrl = value;
447                 }
448             }
449         }
450
451         /// <summary>
452         /// Text string selector in Button.
453         /// </summary>
454         /// <since_tizen> 6 </since_tizen>
455         public StringSelector TextSelector
456         {
457             get
458             {
459                 return textSelector;
460             }
461             set
462             {
463                 if (value == null || textSelector == null)
464                 {
465                     Tizen.Log.Fatal("NUI", "[Exception] Button.TextSelector is null");
466                     throw new NullReferenceException("Button.TextSelector is null");
467                 }
468                 else
469                 {
470                     textSelector.Clone(value);
471                 }
472             }
473         }
474
475         /// <summary>
476         /// Translateable text string selector in Button.
477         /// </summary>
478         /// <since_tizen> 6 </since_tizen>
479         public StringSelector TranslatableTextSelector
480         {
481             get
482             {
483                 return translatableTextSelector;
484             }
485             set
486             {
487                 if (value == null || translatableTextSelector == null)
488                 {
489                     Tizen.Log.Fatal("NUI", "[Exception] Button.TranslatableTextSelector is null");
490                     throw new NullReferenceException("Button.TranslatableTextSelector is null");
491                 }
492                 else
493                 {
494                     translatableTextSelector.Clone(value);
495                 }
496             }
497         }
498
499         /// <summary>
500         /// Text color selector in Button.
501         /// </summary>
502         /// <since_tizen> 6 </since_tizen>
503         public ColorSelector TextColorSelector
504         {
505             get
506             {
507                 return textColorSelector;
508             }
509             set
510             {
511                 if (value == null || textColorSelector == null)
512                 {
513                     Tizen.Log.Fatal("NUI", "[Exception] Button.textColorSelector is null");
514                     throw new NullReferenceException("Button.textColorSelector is null");
515                 }
516                 else
517                 {
518                     textColorSelector.Clone(value);
519                 }
520             }
521         }
522
523         /// <summary>
524         /// Text font size selector in Button.
525         /// </summary>
526         /// <since_tizen> 6 </since_tizen>
527         public FloatSelector PointSizeSelector
528         {
529             get
530             {
531                 return pointSizeSelector;
532             }
533             set
534             {
535                 if (value == null || pointSizeSelector == null)
536                 {
537                     Tizen.Log.Fatal("NUI", "[Exception] Button.pointSizeSelector is null");
538                     throw new NullReferenceException("Button.pointSizeSelector is null");
539                 }
540                 else
541                 {
542                     pointSizeSelector.Clone(value);
543                 }
544             }
545         }
546
547         /// <summary>
548         /// Icon image's resource url selector in Button.
549         /// </summary>
550         /// <since_tizen> 6 </since_tizen>
551         public StringSelector IconURLSelector
552         {
553             get
554             {
555                 return iconURLSelector;
556             }
557             set
558             {
559                 if (value == null || iconURLSelector == null)
560                 {
561                     Tizen.Log.Fatal("NUI", "[Exception] Button.iconURLSelector is null");
562                     throw new NullReferenceException("Button.iconURLSelector is null");
563                 }
564                 else
565                 {
566                     iconURLSelector.Clone(value);
567                 }
568             }
569         }
570
571         /// <summary>
572         /// Flag to decide selected state in Button.
573         /// </summary>
574         /// <since_tizen> 6 </since_tizen>
575         public bool IsSelected
576         {
577             get
578             {
579                 return (bool)GetValue(IsSelectedProperty);
580             }
581             set
582             {
583                 SetValue(IsSelectedProperty, value);
584             }
585         }
586
587         /// <summary>
588         /// Flag to decide enable or disable in Button.
589         /// </summary>
590         /// <since_tizen> 6 </since_tizen>
591         public bool IsEnabled
592         {
593             get
594             {
595                 return (bool)GetValue(IsEnabledProperty);
596             }
597             set
598             {
599                 SetValue(IsEnabledProperty, value);
600             }
601         }
602
603         /// <summary>
604         /// Icon relative orientation in Button, work only when show icon and text.
605         /// </summary>
606         /// <since_tizen> 8 </since_tizen>
607         public IconOrientation? IconRelativeOrientation
608         {
609             get
610             {
611                 return (IconOrientation?)GetValue(IconRelativeOrientationProperty);
612             }
613             set
614             {
615                 SetValue(IconRelativeOrientationProperty, value);
616             }
617         }
618
619         /// <summary>
620         /// Icon padding in Button, work only when show icon and text.
621         /// </summary>
622         /// <since_tizen> 6 </since_tizen>
623         public Extents IconPadding
624         {
625             get => (Extents)GetValue(IconPaddingProperty);
626             set => SetValue(IconPaddingProperty, value);
627         }
628
629         /// <summary>
630         /// Text padding in Button, work only when show icon and text.
631         /// </summary>
632         /// <since_tizen> 6 </since_tizen>
633         public Extents TextPadding
634         {
635             get => (Extents)GetValue(TextPaddingProperty);
636             set => SetValue(TextPaddingProperty, value);
637         }
638
639         /// <summary>
640         /// Called after a key event is received by the view that has had its focus set.
641         /// </summary>
642         /// <param name="key">The key event.</param>
643         /// <returns>True if the key event should be consumed.</returns>
644         /// <since_tizen> 6 </since_tizen>
645         public override bool OnKey(Key key)
646         {
647             if (null == key) return false;
648             if (key.State == Key.StateType.Down)
649             {
650                 if (key.KeyPressedName == "Return")
651                 {
652                     isPressed = true;
653                     UpdateState();
654                 }
655             }
656             else if (key.State == Key.StateType.Up)
657             {
658                 if (key.KeyPressedName == "Return")
659                 {
660                     bool clicked = isPressed && isEnabled;
661
662                     isPressed = false;
663
664                     if (Style.IsSelectable != null && Style.IsSelectable == true)
665                     {
666                         IsSelected = !IsSelected;
667                     }
668                     else
669                     {
670                         UpdateState();
671                     }
672
673                     if (clicked)
674                     {
675                         ClickEventArgs eventArgs = new ClickEventArgs();
676                         OnClickInternal(eventArgs);
677                     }
678                 }
679             }
680             return base.OnKey(key);
681         }
682
683         /// <summary>
684         /// Called when the control gain key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is gained.
685         /// </summary>
686         /// <since_tizen> 8 </since_tizen>
687         public override void OnFocusGained()
688         {
689             base.OnFocusGained();
690             UpdateState();
691         }
692
693         /// <summary>
694         /// Called when the control loses key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is lost.
695         /// </summary>
696         /// <since_tizen> 8 </since_tizen>
697         public override void OnFocusLost()
698         {
699             base.OnFocusLost();
700             UpdateState();
701         }
702
703         /// <summary>
704         /// Called after a touch event is received by the owning view.<br />
705         /// CustomViewBehaviour.REQUIRES_TOUCH_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).<br />
706         /// </summary>
707         /// <param name="touch">The touch event.</param>
708         /// <returns>True if the event should be consumed.</returns>
709         /// <since_tizen> 8 </since_tizen>
710         public override bool OnTouch(Touch touch)
711         {
712             if (null == touch) return false;
713             PointStateType state = touch.GetState(0);
714
715             switch (state)
716             {
717                 case PointStateType.Down:
718                     isPressed = true;
719                     Extension?.SetTouchInfo(touch);
720                     UpdateState();
721                     return true;
722                 case PointStateType.Interrupted:
723                     isPressed = false;
724                     UpdateState();
725                     return true;
726                 case PointStateType.Up:
727                     {
728                         bool clicked = isPressed && isEnabled;
729
730                         isPressed = false;
731
732                         if (Style.IsSelectable != null && Style.IsSelectable == true)
733                         {
734                             Extension?.SetTouchInfo(touch);
735                             IsSelected = !IsSelected;
736                         }
737                         else
738                         {
739                             Extension?.SetTouchInfo(touch);
740                             UpdateState();
741                         }
742
743                         if (clicked)
744                         {
745                             ClickEventArgs eventArgs = new ClickEventArgs();
746                             OnClickInternal(eventArgs);
747                         }
748
749                         return true;
750                     }
751                 default:
752                     break;
753             }
754             return base.OnTouch(touch);
755         }
756
757         /// <summary>
758         /// Apply style to button.
759         /// </summary>
760         /// <param name="viewStyle">The style to apply.</param>
761         /// <since_tizen> 8 </since_tizen>
762         public override void ApplyStyle(ViewStyle viewStyle)
763         {
764             base.ApplyStyle(viewStyle);
765
766             ButtonStyle buttonStyle = viewStyle as ButtonStyle;
767             if (null != buttonStyle)
768             {
769                 Extension = buttonStyle.CreateExtension();
770                 if (buttonStyle.Overlay != null)
771                 {
772                     OverlayImage?.ApplyStyle(buttonStyle.Overlay);
773                 }
774
775                 if (buttonStyle.Text != null)
776                 {
777                     TextLabel?.ApplyStyle(buttonStyle.Text);
778                 }
779
780                 if (buttonStyle.Icon != null)
781                 {
782                     Icon?.ApplyStyle(buttonStyle.Icon);
783                 }
784             }
785         }
786
787         /// <summary>
788         /// ClickEventArgs is a class to record button click event arguments which will sent to user.
789         /// </summary>
790         /// <since_tizen> 6 </since_tizen>
791         public class ClickEventArgs : EventArgs
792         {
793         }
794
795         /// <summary>
796         /// StateChangeEventArgs is a class to record button state change event arguments which will sent to user.
797         /// </summary>
798         /// <since_tizen> 6 </since_tizen>
799         public class StateChangedEventArgs : EventArgs
800         {
801             /// <summary> previous state of Button </summary>
802             /// <since_tizen> 6 </since_tizen>
803             public ControlStates PreviousState;
804             /// <summary> current state of Button </summary>
805             /// <since_tizen> 6 </since_tizen>
806             public ControlStates CurrentState;
807         }
808
809         /// <summary>
810         /// Get current text part to the attached ButtonExtension.
811         /// </summary>
812         /// <remarks>
813         /// It returns null if the passed extension is invaild.
814         /// </remarks>
815         /// <param name="extension">The extension instance that is currently attached to this Button.</param>
816         /// <return>The button's text part.</return>
817         [EditorBrowsable(EditorBrowsableState.Never)]
818         public TextLabel GetCurrentText(ButtonExtension extension)
819         {
820             return (extension == Extension) ? TextLabel : null;
821         }
822
823         /// <summary>
824         /// Get current icon part to the attached ButtonExtension.
825         /// </summary>
826         /// <remarks>
827         /// It returns null if the passed extension is invaild.
828         /// </remarks>
829         /// <param name="extension">The extension instance that is currently attached to this Button.</param>
830         /// <return>The button's icon part.</return>
831         [EditorBrowsable(EditorBrowsableState.Never)]
832         public ImageView GetCurrentIcon(ButtonExtension extension)
833         {
834             return (extension == Extension) ? Icon : null;
835         }
836
837         /// <summary>
838         /// Get current overlay image part to the attached ButtonExtension.
839         /// </summary>
840         /// <remarks>
841         /// It returns null if the passed extension is invaild.
842         /// </remarks>
843         /// <param name="extension">The extension instance that is currently attached to this Button.</param>
844         /// <return>The button's overlay image part.</return>
845         [EditorBrowsable(EditorBrowsableState.Never)]
846         public ImageView GetCurrentOverlayImage(ButtonExtension extension)
847         {
848             return (extension == Extension) ? OverlayImage : null;
849         }
850     }
851 }