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