[NUI.Components] Improve sam score to 4.21 (#1720)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / Slider.cs
1 /*
2  * Copyright(c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 using System;
18 using Tizen.NUI.BaseComponents;
19 using System.ComponentModel;
20 using Tizen.NUI.Binding;
21
22 namespace Tizen.NUI.Components
23 {
24     /// <summary>
25     /// A slider lets users select a value from a continuous or discrete range of values by moving the slider thumb.
26     /// </summary>
27     /// <since_tizen> 6 </since_tizen>
28     public partial class Slider : Control
29     {
30         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
31         [EditorBrowsable(EditorBrowsableState.Never)]
32         public static readonly BindableProperty IndicatorTypeProperty = BindableProperty.Create("IndicatorType", typeof(IndicatorType), typeof(Slider), IndicatorType.None, propertyChanged: (bindable, oldValue, newValue) =>
33         {
34             var instance = (Slider)bindable;
35             if (newValue != null)
36             {
37                 instance.privateIndicatorType = (IndicatorType)newValue;
38             }
39         },
40         defaultValueCreator: (bindable) =>
41         {
42             var instance = (Slider)bindable;
43             return instance.privateIndicatorType;
44         });
45         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
46         [EditorBrowsable(EditorBrowsableState.Never)]
47         public static readonly BindableProperty SpaceBetweenTrackAndIndicatorProperty = BindableProperty.Create(nameof(SpaceBetweenTrackAndIndicator), typeof(uint), typeof(Slider), (uint)0, propertyChanged: (bindable, oldValue, newValue) =>
48         {
49             var instance = (Slider)bindable;
50             if (newValue != null)
51             {
52                 instance.privateSpaceBetweenTrackAndIndicator = (uint)newValue;
53             }
54         },
55         defaultValueCreator: (bindable) =>
56         {
57             var instance = (Slider)bindable;
58             return instance.privateSpaceBetweenTrackAndIndicator;
59         });
60         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
61         [EditorBrowsable(EditorBrowsableState.Never)]
62         public static readonly BindableProperty TrackThicknessProperty = BindableProperty.Create(nameof(TrackThickness), typeof(uint), typeof(Slider), (uint)0, propertyChanged: (bindable, oldValue, newValue) =>
63         {
64             var instance = (Slider)bindable;
65             if (newValue != null)
66             {
67                 instance.privateTrackThickness = (uint)newValue;
68             }
69         },
70         defaultValueCreator: (bindable) =>
71         {
72             var instance = (Slider)bindable;
73             return instance.privateTrackThickness;
74         });
75
76         static Slider() { }
77
78         /// <summary>
79         /// The constructor of the Slider class.
80         /// </summary>
81         /// <since_tizen> 6 </since_tizen>
82         public Slider() 
83         {
84             Initialize();
85         }
86
87         /// <summary>
88         /// The constructor of the Slider class with specific style.
89         /// </summary>
90         /// <param name="style">The string to initialize the Slider</param>
91         /// <since_tizen> 8 </since_tizen>
92         public Slider(string style) : base(style)
93         {
94             Initialize();
95         }
96
97         /// <summary>
98         /// The constructor of the Slider class with specific style.
99         /// </summary>
100         /// <param name="sliderStyle">The style object to initialize the Slider</param>
101         /// <since_tizen> 8 </since_tizen>
102         public Slider(SliderStyle sliderStyle) : base(sliderStyle)
103         {
104             Initialize();
105         }
106
107         /// <summary>
108         /// The value changed event handler.
109         /// </summary>
110         /// <since_tizen> 6 </since_tizen>
111         public event EventHandler<ValueChangedArgs> ValueChangedEvent
112         {
113             add
114             {
115                 valueChangedHandler += value;
116             }
117             remove
118             {
119                 valueChangedHandler -= value;
120             }
121         }
122
123         /// <summary>
124         /// The sliding finished event handler.
125         /// </summary>
126         /// <since_tizen> 6 </since_tizen>
127         public event EventHandler<SlidingFinishedArgs> SlidingFinishedEvent
128         {
129             add
130             {
131                 slidingFinishedHandler += value;
132             }
133             remove
134             {
135                 slidingFinishedHandler -= value;
136             }
137         }
138
139         /// <summary>
140         /// The state changed event handler.
141         /// </summary>
142         /// <since_tizen> 6 </since_tizen>
143         public event EventHandler<StateChangedArgs> StateChangedEvent
144         {
145             add
146             {
147                 stateChangedHandler += value;
148             }
149             remove
150             {
151                 stateChangedHandler -= value;
152             }
153         }
154
155         /// <summary>
156         /// The direction type of slider.
157         /// </summary>
158         /// <since_tizen> 6 </since_tizen>
159         public enum DirectionType
160         {
161             /// <summary>
162             /// The Horizontal type.
163             /// </summary>
164             /// <since_tizen> 6 </since_tizen>
165             Horizontal,
166
167             /// <summary>
168             /// The Vertical type.
169             /// </summary>
170             /// <since_tizen> 6 </since_tizen>
171             Vertical
172         }
173
174         /// <summary>
175         /// The indicator type of slider.
176         /// </summary>
177         /// <since_tizen> 6 </since_tizen>
178         public enum IndicatorType
179         {
180             /// <summary> Only contains slider bar.</summary>
181             /// <since_tizen> 6 </since_tizen>
182             None,
183
184             /// <summary> Contains slider bar, IndicatorImage.</summary>
185             /// <since_tizen> 6 </since_tizen>
186             Image,
187
188             /// <summary> Contains slider bar, IndicatorText.</summary>
189             /// <since_tizen> 6 </since_tizen>
190             Text
191         }
192
193         /// <summary>
194         /// Get style of slider.
195         /// </summary>
196         /// <since_tizen> 8 </since_tizen>
197         public new SliderStyle Style => ViewStyle as SliderStyle;
198
199         /// <summary>
200         /// Gets or sets the direction type of slider.
201         /// </summary>
202         /// <since_tizen> 6 </since_tizen>
203         public DirectionType Direction
204         {
205             get
206             {
207                 return direction;
208             }
209             set
210             {
211                 if (direction == value)
212                 {
213                     return;
214                 }
215                 direction = value;
216                 RelayoutBaseComponent(false);
217                 UpdateBgTrackSize();
218                 UpdateBgTrackPosition();
219                 UpdateValue();
220             }
221         }
222
223         /// <summary>
224         /// Gets or sets the indicator type, arrow or sign.
225         /// </summary>
226         /// <since_tizen> 6 </since_tizen>
227         public IndicatorType Indicator
228         {
229             get
230             {
231                 return (IndicatorType)GetValue(IndicatorTypeProperty);
232             }
233             set
234             {
235                 SetValue(IndicatorTypeProperty, value);
236             }
237         }
238
239         /// <summary>
240         /// Gets or sets the minimum value of slider.
241         /// </summary>
242         /// <since_tizen> 6 </since_tizen>
243         public float MinValue
244         {
245             get
246             {
247                 return minValue;
248             }
249             set
250             {
251                 minValue = value;
252                 UpdateValue();
253             }
254         }
255
256         /// <summary>
257         /// Gets or sets the maximum value of slider.
258         /// </summary>
259         /// <since_tizen> 6 </since_tizen>
260         public float MaxValue
261         {
262             get
263             {
264                 return maxValue;
265             }
266             set
267             {
268                 maxValue = value;
269                 UpdateValue();
270             }
271         }
272
273         /// <summary>
274         /// Gets or sets the current value of slider.
275         /// </summary>
276         /// <since_tizen> 6 </since_tizen>
277         public float CurrentValue
278         {
279             get
280             {
281                 return curValue;
282             }
283             set
284             {
285                 curValue = value;
286                 UpdateValue();
287             }
288         }
289
290         /// <summary>
291         /// Gets or sets the size of the thumb image object.
292         /// </summary>
293         /// <since_tizen> 6 </since_tizen>
294         public Size ThumbSize
295         {
296             get
297             {
298                 return Style.Thumb?.Size;
299             }
300             set
301             {
302                 Style.Thumb.Size = value;
303             }
304         }
305
306         /// <summary>
307         /// Gets or sets the resource url of the thumb image object.
308         /// </summary>
309         /// <since_tizen> 6 </since_tizen>
310         public string ThumbImageURL
311         {
312             get
313             {
314                 return Style?.Thumb?.ResourceUrl?.All;
315             }
316             set
317             {
318                 if (null != Style?.Thumb)
319                 {
320                     Style.Thumb.ResourceUrl = value; 
321                 }
322             }
323         }
324
325         /// <summary>
326         /// Gets or sets the resource url selector of the thumb image object.
327         /// </summary>
328         /// <since_tizen> 6 </since_tizen>
329         public StringSelector ThumbImageURLSelector
330         {
331             get
332             {
333                 return thumbImageURLSelector;
334             }
335             set
336             {
337                 if (value == null || thumbImageURLSelector == null)
338                 {
339                     Tizen.Log.Fatal("NUI", "[Exception] Slider.ThumbImageURLSelector is null");
340                     throw new NullReferenceException("Slider.ThumbImageURLSelector is null");
341                 }
342                 else
343                 {
344                     thumbImageURLSelector.Clone(value);
345                 }
346             }
347         }
348
349         /// <summary>
350         /// Gets or sets the color of the background track image object.
351         /// </summary>
352         /// <since_tizen> 6 </since_tizen>
353         public Color BgTrackColor
354         {
355             get
356             {
357                 return Style?.Track?.BackgroundColor?.All;
358             }
359             set
360             {
361                 if (null != Style?.Track)
362                 {
363                     Style.Track.BackgroundColor = value;
364                 }
365             }
366         }
367
368         /// <summary>
369         /// Gets or sets the color of the slided track image object.
370         /// </summary>
371         /// <since_tizen> 6 </since_tizen>
372         public Color SlidedTrackColor
373         {
374             get
375             {
376                 return Style?.Progress?.BackgroundColor?.All;
377             }
378             set
379             {
380                 if (null != Style?.Progress)
381                 {
382                     Style.Progress.BackgroundColor = value;
383                 }
384             }
385         }
386
387         /// <summary>
388         /// Gets or sets the thickness value of the track.
389         /// </summary>
390         /// <since_tizen> 6 </since_tizen>
391         public uint TrackThickness
392         {
393             get
394             {
395                 return (uint)GetValue(TrackThicknessProperty);
396             }
397             set
398             {
399                 SetValue(TrackThicknessProperty, value);
400             }
401         }
402
403         /// <summary>
404         /// Gets or sets the resource url of the low indicator image object.
405         /// </summary>
406         /// <since_tizen> 6 </since_tizen>
407         public string LowIndicatorImageURL
408         {
409             get
410             {
411                 return Style?.LowIndicatorImage?.ResourceUrl?.All;
412             }
413             set
414             {
415                 if (null != Style?.LowIndicatorImage)
416                 {
417                     Style.LowIndicatorImage.ResourceUrl = value;
418                 }
419             }
420         }
421
422         /// <summary>
423         /// Gets or sets the resource url of the high indicator image object.
424         /// </summary>
425         /// <since_tizen> 6 </since_tizen>
426         public string HighIndicatorImageURL
427         {
428             get
429             {
430                 return Style?.HighIndicatorImage?.ResourceUrl?.All;
431             }
432             set
433             {
434                 if (null != Style?.HighIndicatorImage)
435                 {
436                     Style.HighIndicatorImage.ResourceUrl = value;
437                 }
438             }
439         }
440
441         /// <summary>
442         /// Gets or sets the text content of the low indicator text object.
443         /// </summary>
444         /// <since_tizen> 6 </since_tizen>
445         public string LowIndicatorTextContent
446         {
447             get
448             {
449                 return Style?.LowIndicator?.Text?.All;
450             }
451             set
452             {
453                 if (null != Style?.LowIndicator)
454                 {
455                     Style.LowIndicator.Text= value;
456                 }
457             }
458         }
459
460         /// <summary>
461         /// Gets or sets the text content of the high indicator text object.
462         /// </summary>
463         /// <since_tizen> 6 </since_tizen>
464         public string HighIndicatorTextContent
465         {
466             get
467             {
468                 return Style?.HighIndicator?.Text?.All;
469             }
470             set
471             {
472                 if (null != Style?.HighIndicator)
473                 {
474                     Style.HighIndicator.Text = value;
475                 }
476             }
477         }
478
479         /// <summary>
480         /// Gets or sets the size of the low indicator object(image or text).
481         /// </summary>
482         /// <since_tizen> 6 </since_tizen>
483         public Size LowIndicatorSize
484         {
485             get
486             {
487                 return lowIndicatorSize;
488             }
489             set
490             {
491                 lowIndicatorSize = value;
492                 UpdateLowIndicatorSize();
493                 UpdateBgTrackSize();
494                 UpdateBgTrackPosition();
495                 UpdateValue();
496             }
497         }
498
499         /// <summary>
500         /// Gets or sets the size of the high indicator object(image or text).
501         /// </summary>
502         /// <since_tizen> 6 </since_tizen>
503         public Size HighIndicatorSize
504         {
505             get
506             {
507                 return Style.HighIndicator.Size;
508             }
509             set
510             {
511                 Style.HighIndicator.Size = value;
512             }
513         }
514
515         /// <summary>
516         /// Gets or sets the value of the space between track and indicator.
517         /// </summary>
518         /// <since_tizen> 6 </since_tizen>
519         public uint SpaceBetweenTrackAndIndicator
520         {
521             get
522             {
523                 return (uint)GetValue(SpaceBetweenTrackAndIndicatorProperty);
524             }
525             set
526             {
527                 SetValue(SpaceBetweenTrackAndIndicatorProperty, value);
528             }
529         }
530
531         private Extents spaceBetweenTrackAndIndicator
532         {
533             get
534             {
535                 if (null == _spaceBetweenTrackAndIndicator)
536                 {
537                     _spaceBetweenTrackAndIndicator = new Extents((ushort start, ushort end, ushort top, ushort bottom) =>
538                     {
539                         Extents extents = new Extents(start, end, top, bottom);
540                         _spaceBetweenTrackAndIndicator.CopyFrom(extents);
541                     }, 0, 0, 0, 0);
542                 }
543
544                 return _spaceBetweenTrackAndIndicator;
545             }
546         }
547
548         private IndicatorType privateIndicatorType
549         {
550             get
551             {
552                 return indicatorType;
553             }
554             set
555             {
556                 if (indicatorType == value)
557                 {
558                     return;
559                 }
560                 indicatorType = value;
561                 RelayoutBaseComponent(false);
562                 UpdateBgTrackSize();
563                 UpdateBgTrackPosition();
564                 UpdateValue();
565             }
566         }
567
568         private uint privateTrackThickness
569         {
570             get
571             {
572                 return trackThickness ?? 0;
573             }
574             set
575             {
576                 trackThickness = value;
577                 if (bgTrackImage != null)
578                 {
579                     if (direction == DirectionType.Horizontal)
580                     {
581                         bgTrackImage.SizeHeight = (float)trackThickness.Value;
582                     }
583                     else if (direction == DirectionType.Vertical)
584                     {
585                         bgTrackImage.SizeWidth = (float)trackThickness.Value;
586                     }
587                 }
588                 if (slidedTrackImage != null)
589                 {
590                     if (direction == DirectionType.Horizontal)
591                     {
592                         slidedTrackImage.SizeHeight = (float)trackThickness.Value;
593                     }
594                     else if (direction == DirectionType.Vertical)
595                     {
596                         slidedTrackImage.SizeWidth = (float)trackThickness.Value;
597                     }
598                 }
599             }
600         }
601
602         private uint privateSpaceBetweenTrackAndIndicator
603         {
604             get
605             {
606                 return privateTrackPadding.Start;
607             }
608             set
609             {
610                 ushort val = (ushort)value;
611                 privateTrackPadding = new Extents(val, val, val, val);
612             }
613         }
614
615         private Extents privateTrackPadding
616         {
617             get
618             {
619                 return spaceBetweenTrackAndIndicator;
620             }
621             set
622             {
623                 spaceBetweenTrackAndIndicator.CopyFrom(value);
624                 UpdateComponentByIndicatorTypeChanged();
625                 UpdateBgTrackSize();
626                 UpdateBgTrackPosition();
627                 UpdateValue();
628             }
629         }
630
631         /// <summary>
632         /// Focus gained callback.
633         /// </summary>
634         /// <since_tizen> 6 </since_tizen>
635         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
636         [EditorBrowsable(EditorBrowsableState.Never)]
637         public override void OnFocusGained()
638         {
639             //State = ControlStates.Focused;
640             UpdateState(true, isPressed);
641             base.OnFocusGained();
642         }
643
644         /// <summary>
645         /// Focus Lost callback.
646         /// </summary>
647         /// <since_tizen> 6 </since_tizen>
648         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
649         [EditorBrowsable(EditorBrowsableState.Never)]
650         public override void OnFocusLost()
651         {
652             //State = ControlStates.Normal;
653             UpdateState(false, isPressed);
654             base.OnFocusLost();
655         }
656
657         /// <summary>
658         /// Apply style to scrollbar.
659         /// </summary>
660         /// <param name="viewStyle">The style to apply.</param>
661         /// <since_tizen> 8 </since_tizen>
662         public override void ApplyStyle(ViewStyle viewStyle)
663         {
664             base.ApplyStyle(viewStyle);
665
666             SliderStyle sliderStyle = viewStyle as SliderStyle;
667
668             if (null != sliderStyle?.Progress)
669             {
670                 CreateSlidedTrack().ApplyStyle(sliderStyle.Progress);
671             }
672
673             if (null != sliderStyle?.LowIndicator)
674             {
675                 CreateLowIndicatorText().ApplyStyle(sliderStyle.LowIndicator);
676             }
677
678             if (null != sliderStyle?.HighIndicator)
679             {
680                 CreateHighIndicatorText().ApplyStyle(sliderStyle.HighIndicator);
681             }
682
683             if (null != sliderStyle?.Track)
684             {
685                 CreateBackgroundTrack().ApplyStyle(sliderStyle.Track);
686             }
687
688             if (null != sliderStyle?.Thumb)
689             {
690                 CreateThumb().ApplyStyle(sliderStyle.Thumb);
691             }
692
693             EnableControlStatePropagation = true;
694         }
695
696         /// <summary>
697         /// Get Slider style.
698         /// </summary>
699         /// <returns>The default slider style.</returns>
700         /// <since_tizen> 8 </since_tizen>
701         protected override ViewStyle CreateViewStyle()
702         {
703             return new SliderStyle();
704         }
705
706         /// <summary>
707         /// Dispose Slider.
708         /// </summary>
709         /// <param name="type">Dispose type.</param>
710         /// <since_tizen> 6 </since_tizen>
711         protected override void Dispose(DisposeTypes type)
712         {
713             if (disposed)
714             {
715                 return;
716             }
717
718             if (type == DisposeTypes.Explicit)
719             {
720                 if (null != panGestureDetector)
721                 {
722                     if (null != thumbImage)
723                     {
724                         panGestureDetector.Detach(thumbImage);
725                     }
726                     panGestureDetector.Detected -= OnPanGestureDetected;
727                     panGestureDetector.Dispose();
728                     panGestureDetector = null;
729                 }
730
731                 if (null != thumbImage)
732                 {
733                     thumbImage.TouchEvent -= OnTouchEventForThumb;
734                     Utility.Dispose(thumbImage);
735                 }
736                 Utility.Dispose(slidedTrackImage);
737                 if (null != bgTrackImage)
738                 {
739                     bgTrackImage.TouchEvent -= OnTouchEventForBgTrack;
740                     Utility.Dispose(bgTrackImage);
741                 }
742                 Utility.Dispose(lowIndicatorImage);
743                 Utility.Dispose(highIndicatorImage);
744                 Utility.Dispose(lowIndicatorText);
745                 Utility.Dispose(highIndicatorText);
746             }
747
748             base.Dispose(type);
749         }
750
751         /// <summary>
752         /// Update Slider by style.
753         /// </summary>
754         /// <since_tizen> 6 </since_tizen>
755         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
756         [EditorBrowsable(EditorBrowsableState.Never)]
757         protected override void OnUpdate()
758         {
759             RelayoutBaseComponent();
760
761             UpdateComponentByIndicatorTypeChanged();
762             UpdateBgTrackSize();
763             UpdateBgTrackPosition();
764             UpdateLowIndicatorSize();
765             UpdateValue();
766         }
767
768         /// <summary>
769         /// Theme change callback when theme is changed, this callback will be trigger.
770         /// </summary>
771         /// <param name="sender">The sender</param>
772         /// <param name="e">The event data</param>
773         /// <since_tizen> 8 </since_tizen>
774         protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e)
775         {
776             SliderStyle sliderStyle = StyleManager.Instance.GetViewStyle(StyleName) as SliderStyle;
777             if (sliderStyle != null)
778             {
779                 Style?.CopyFrom(sliderStyle);
780                 RelayoutRequest();
781             }
782         }
783
784         private void CalculateCurrentValueByGesture(float offset)
785         {
786             currentSlidedOffset += offset;
787
788             if (currentSlidedOffset <= 0)
789             {
790                 curValue = minValue;
791             }
792             else if (currentSlidedOffset >= BgTrackLength())
793             {
794                 curValue = maxValue;
795             }
796             else
797             {
798                 int bgTrackLength = BgTrackLength();
799                 if (bgTrackLength != 0)
800                 {
801                     curValue = ((currentSlidedOffset / (float)bgTrackLength) * (float)(maxValue - minValue)) + minValue;
802                 }
803             }
804             if (valueChangedHandler != null)
805             {
806                 ValueChangedArgs args = new ValueChangedArgs();
807                 args.CurrentValue = curValue;
808                 valueChangedHandler(this, args);
809             }
810         }
811
812         private bool OnTouchEventForBgTrack(object source, TouchEventArgs e)
813         {
814             PointStateType state = e.Touch.GetState(0);
815             if (state == PointStateType.Down)
816             {
817                 Vector2 pos = e.Touch.GetLocalPosition(0);
818                 CalculateCurrentValueByTouch(pos);
819                 UpdateValue();
820                 if (null != slidingFinishedHandler)
821                 {
822                     SlidingFinishedArgs args = new SlidingFinishedArgs();
823                     args.CurrentValue = curValue;
824                     slidingFinishedHandler(this, args);
825                 }
826             }
827             return false;
828         }
829
830         private bool OnTouchEventForThumb(object source, TouchEventArgs e)
831         {
832             PointStateType state = e.Touch.GetState(0);
833             if (state == PointStateType.Down)
834             {
835                 UpdateState(isFocused, true);
836             }
837             else if (state == PointStateType.Up)
838             {
839                 UpdateState(isFocused, false);
840             }
841             return true;
842         }
843
844         private void CalculateCurrentValueByTouch(Vector2 pos)
845         {
846             int bgTrackLength = BgTrackLength();
847             if (direction == DirectionType.Horizontal)
848             {
849                 currentSlidedOffset = pos.X;
850             }
851             else if (direction == DirectionType.Vertical)
852             {
853                 currentSlidedOffset = bgTrackLength - pos.Y;
854             }
855             if (bgTrackLength != 0)
856             {
857                 curValue = ((currentSlidedOffset / (float)bgTrackLength) * (maxValue - minValue)) + minValue;
858                 if (null != valueChangedHandler)
859                 {
860                     ValueChangedArgs args = new ValueChangedArgs();
861                     args.CurrentValue = curValue;
862                     valueChangedHandler(this, args);
863                 }
864             }
865         }
866
867         private void UpdateState(bool isFocusedNew, bool isPressedNew)
868         {
869             if (isFocused == isFocusedNew && isPressed == isPressedNew)
870             {
871                 return;
872             }
873             if (thumbImage == null || Style == null)
874             {
875                 return;
876             }
877             isFocused = isFocusedNew;
878             isPressed = isPressedNew;
879
880             if (!isFocused && !isPressed)
881             {
882                 ControlState = ControlStates.Normal;
883                 if (stateChangedHandler != null)
884                 {
885                     StateChangedArgs args = new StateChangedArgs();
886                     args.CurrentState = (ControlStates)ControlStates.Normal;
887                     stateChangedHandler(this, args);
888                 }
889             }
890             else if (isPressed)
891             {
892                 ControlState = ControlStates.Pressed;
893
894                 if (stateChangedHandler != null)
895                 {
896                     StateChangedArgs args = new StateChangedArgs();
897                     args.CurrentState = (ControlStates)ControlStates.Pressed;
898                     stateChangedHandler(this, args);
899                 }
900             }
901             else if (!isPressed && isFocused)
902             {
903                 ControlState = ControlStates.Focused;
904
905                 if (stateChangedHandler != null)
906                 {
907                     StateChangedArgs args = new StateChangedArgs();
908                     args.CurrentState = (ControlStates)ControlStates.Focused;
909                     stateChangedHandler(this, args);
910                 }
911             }
912         }
913
914         private void UpdateComponentByIndicatorTypeChanged()
915         {
916             IndicatorType type = CurrentIndicatorType();
917             if (type == IndicatorType.None)
918             {
919                 if (lowIndicatorImage != null)
920                 {
921                     lowIndicatorImage.Hide();
922                 }
923                 if (highIndicatorImage != null)
924                 {
925                     highIndicatorImage.Hide();
926                 }
927                 if (lowIndicatorText != null)
928                 {
929                     lowIndicatorText.Hide();
930                 }
931                 if (highIndicatorText != null)
932                 {
933                     highIndicatorText.Hide();
934                 }
935             }
936             else if (type == IndicatorType.Image)
937             {
938                 if (lowIndicatorImage != null)
939                 {
940                     lowIndicatorImage.Show();
941                 }
942                 if (highIndicatorImage != null)
943                 {
944                     highIndicatorImage.Show();
945                 }
946                 if (lowIndicatorText != null)
947                 {
948                     lowIndicatorText.Hide();
949                 }
950                 if (highIndicatorText != null)
951                 {
952                     highIndicatorText.Hide();
953                 }
954             }
955             else if (type == IndicatorType.Text)
956             {
957                 if (lowIndicatorText != null)
958                 {
959                     lowIndicatorText.Show();
960                 }
961                 if (highIndicatorText != null)
962                 {
963                     highIndicatorText.Show();
964                 }
965                 if (lowIndicatorImage != null)
966                 {
967                     lowIndicatorImage.Hide();
968                 }
969                 if (highIndicatorImage != null)
970                 {
971                     highIndicatorImage.Hide();
972                 }
973             }
974         }
975
976         /// <summary>
977         /// Value Changed event data.
978         /// </summary>
979         /// <since_tizen> 6 </since_tizen>
980         public class ValueChangedArgs : EventArgs
981         {
982             /// <summary>
983             /// Curren value
984             /// </summary>
985             /// <since_tizen> 6 </since_tizen>
986             public float CurrentValue;
987         }
988
989         /// <summary>
990         /// Value Changed event data.
991         /// </summary>
992         /// <since_tizen> 6 </since_tizen>
993         public class SlidingFinishedArgs : EventArgs
994         {
995             /// <summary>
996             /// Curren value
997             /// </summary>
998             /// <since_tizen> 6 </since_tizen>
999             public float CurrentValue;
1000         }
1001
1002         /// <summary>
1003         /// State Changed event data.
1004         /// </summary>
1005         /// <since_tizen> 6 </since_tizen>
1006         public class StateChangedArgs : EventArgs
1007         {
1008             /// <summary>
1009             /// Curent state
1010             /// </summary>
1011             /// <since_tizen> 6 </since_tizen>
1012             public ControlStates CurrentState;
1013         }
1014     }
1015 }