[NUI] update copyright.
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / Slider.cs
1 /*
2  * Copyright(c) 2022 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 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     /// Slider value changed event data.
26     /// </summary>
27     /// <since_tizen> 8 </since_tizen>
28     public class SliderValueChangedEventArgs : EventArgs
29     {
30         /// <summary>
31         /// Current Slider value
32         /// </summary>
33         /// <since_tizen> 8 </since_tizen>
34         public float CurrentValue { get; set; }
35     }
36
37     /// <summary>
38     /// Slider sliding started event data.
39     /// </summary>
40     /// <since_tizen> 8 </since_tizen>
41     public class SliderSlidingStartedEventArgs : EventArgs
42     {
43         /// <summary>
44         /// Current Slider value
45         /// </summary>
46         /// <since_tizen> 8 </since_tizen>
47         public float CurrentValue { get; set; }
48     }
49
50     /// <summary>
51     /// Slider sliding finished event data.
52     /// </summary>
53     /// <since_tizen> 8 </since_tizen>
54     public class SliderSlidingFinishedEventArgs : EventArgs
55     {
56         /// <summary>
57         /// Current Slider value
58         /// </summary>
59         /// <since_tizen> 8 </since_tizen>
60         public float CurrentValue { get; set; }
61     }
62
63     /// <summary>
64     /// A slider lets users select a value from a continuous or discrete range of values by moving the slider thumb.
65     /// </summary>
66     /// <since_tizen> 6 </since_tizen>
67     public partial class Slider : Control
68     {
69         /// <summary>
70         /// SpaceBetweenTrackAndIndicatorProperty
71         /// </summary>
72         [EditorBrowsable(EditorBrowsableState.Never)]
73         public static readonly BindableProperty IndicatorProperty = BindableProperty.Create(nameof(Indicator), typeof(IndicatorType), typeof(Slider), IndicatorType.None, propertyChanged: (bindable, oldValue, newValue) =>
74         {
75             var instance = (Slider)bindable;
76             if (newValue != null)
77             {
78                 instance.privateIndicatorType = (IndicatorType)newValue;
79             }
80         },
81         defaultValueCreator: (bindable) =>
82         {
83             var instance = (Slider)bindable;
84             return instance.privateIndicatorType;
85         });
86
87         /// <summary>
88         /// SpaceBetweenTrackAndIndicatorProperty
89         /// </summary>
90         [EditorBrowsable(EditorBrowsableState.Never)]
91         public static readonly BindableProperty SpaceBetweenTrackAndIndicatorProperty = BindableProperty.Create(nameof(SpaceBetweenTrackAndIndicator), typeof(uint), typeof(Slider), (uint)0, propertyChanged: (bindable, oldValue, newValue) =>
92         {
93             var instance = (Slider)bindable;
94             if (newValue != null)
95             {
96                 instance.privateSpaceBetweenTrackAndIndicator = (uint)newValue;
97             }
98         },
99         defaultValueCreator: (bindable) =>
100         {
101             var instance = (Slider)bindable;
102             return instance.privateSpaceBetweenTrackAndIndicator;
103         });
104
105         /// <summary>
106         /// TrackThicknessProperty
107         /// </summary>
108         [EditorBrowsable(EditorBrowsableState.Never)]
109         public static readonly BindableProperty TrackThicknessProperty = BindableProperty.Create(nameof(TrackThickness), typeof(uint), typeof(Slider), (uint)0, propertyChanged: (bindable, oldValue, newValue) =>
110         {
111             var instance = (Slider)bindable;
112             if (newValue != null)
113             {
114                 instance.privateTrackThickness = (uint)newValue;
115             }
116         },
117         defaultValueCreator: (bindable) =>
118         {
119             var instance = (Slider)bindable;
120             return instance.privateTrackThickness;
121         });
122
123         /// <summary>
124         /// IsValueShownProperty
125         /// </summary>
126         [EditorBrowsable(EditorBrowsableState.Never)]
127         public static readonly BindableProperty IsValueShownProperty = BindableProperty.Create(nameof(IsValueShown), typeof(bool), typeof(Slider), true, propertyChanged: (bindable, oldValue, newValue) =>
128         {
129             var instance = (Slider)bindable;
130             if (newValue != null)
131             {
132                 bool newValueShown = (bool)newValue;
133                 if (instance.isValueShown != newValueShown)
134                 {
135                     instance.isValueShown = newValueShown;
136                 }
137             }
138         },
139         defaultValueCreator: (bindable) =>
140         {
141             var instance = (Slider)bindable;
142             return instance.isValueShown;
143         });
144
145         /// <summary>
146         /// ValueIndicatorTextProperty
147         /// </summary>
148         [EditorBrowsable(EditorBrowsableState.Never)]
149         public static readonly BindableProperty ValueIndicatorTextProperty = BindableProperty.Create(nameof(ValueIndicatorText), typeof(string), typeof(Slider), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
150         {
151             var instance = (Slider)bindable;
152             if (newValue != null)
153             {
154                 string newText = (string)newValue;
155                 instance.valueIndicatorText.Text = newText;
156             }
157         },
158         defaultValueCreator: (bindable) =>
159         {
160             var instance = (Slider)bindable;
161             return instance.valueIndicatorText.Text;
162         });
163
164         /// <summary>
165         /// Bindable property of CurrentValue
166         /// <remark>
167         /// Hidden API, used for NUI XAML data binding
168         /// </remark>
169         /// </summary>
170         [EditorBrowsable(EditorBrowsableState.Never)]
171         public static readonly BindableProperty CurrentValueProperty = BindableProperty.Create(nameof(CurrentValue), typeof(float), typeof(Slider), 0.0f, BindingMode.TwoWay,
172             propertyChanged: (bindable, oldValue, newValue) =>
173             {
174                 var instance = (Slider)bindable;
175
176                 if (newValue != null)
177                 {
178                     instance.curValue = (float)newValue;
179                     if (Accessibility.Accessibility.IsEnabled && instance.IsHighlighted)
180                     {
181                         instance.EmitAccessibilityEvent(AccessibilityPropertyChangeEvent.Value);
182                     }
183                     instance.UpdateValue();
184                 }
185             },
186             defaultValueCreator: (bindable) =>
187             {
188                 var instance = (Slider)bindable;
189                 return instance.curValue;
190             }
191         );
192
193         static Slider() { }
194
195         /// <summary>
196         /// The constructor of the Slider class.
197         /// </summary>
198         /// <since_tizen> 6 </since_tizen>
199         public Slider()
200         {
201             Initialize();
202         }
203
204         /// <summary>
205         /// The constructor of the Slider class with specific style.
206         /// </summary>
207         /// <param name="style">The string to initialize the Slider</param>
208         /// <since_tizen> 8 </since_tizen>
209         public Slider(string style) : base(style)
210         {
211             Initialize();
212         }
213
214         /// <summary>
215         /// The constructor of the Slider class with specific style.
216         /// </summary>
217         /// <param name="sliderStyle">The style object to initialize the Slider</param>
218         /// <since_tizen> 8 </since_tizen>
219         public Slider(SliderStyle sliderStyle) : base(sliderStyle)
220         {
221             Initialize();
222         }
223
224         /// <summary>
225         /// The value changed event handler.
226         /// </summary>
227         /// <since_tizen> 6 </since_tizen>
228         [Obsolete("Deprecated in API8; Will be removed in API10. Please use ValueChanged event instead.")]
229         public event EventHandler<ValueChangedArgs> ValueChangedEvent
230         {
231             add
232             {
233                 valueChangedHandler += value;
234             }
235             remove
236             {
237                 valueChangedHandler -= value;
238             }
239         }
240
241         /// <summary>
242         /// The sliding finished event handler.
243         /// </summary>
244         /// <since_tizen> 6 </since_tizen>
245         [Obsolete("Deprecated in API8; Will be removed in API10. Please use SlidingFinished event instead.")]
246         public event EventHandler<SlidingFinishedArgs> SlidingFinishedEvent
247         {
248             add
249             {
250                 slidingFinishedHandler += value;
251             }
252             remove
253             {
254                 slidingFinishedHandler -= value;
255             }
256         }
257
258         /// <summary>
259         /// The value changed event handler.
260         /// </summary>
261         /// <since_tizen> 8 </since_tizen>
262         public event EventHandler<SliderValueChangedEventArgs> ValueChanged
263         {
264             add
265             {
266                 sliderValueChangedHandler += value;
267             }
268             remove
269             {
270                 sliderValueChangedHandler -= value;
271             }
272         }
273
274         /// <summary>
275         /// The sliding started event handler.
276         /// </summary>
277         /// <since_tizen> 8 </since_tizen>
278         public event EventHandler<SliderSlidingStartedEventArgs> SlidingStarted
279         {
280             add
281             {
282                 sliderSlidingStartedHandler += value;
283             }
284             remove
285             {
286                 sliderSlidingStartedHandler -= value;
287             }
288         }
289
290         /// <summary>
291         /// The sliding finished event handler.
292         /// </summary>
293         /// <since_tizen> 8 </since_tizen>
294         public event EventHandler<SliderSlidingFinishedEventArgs> SlidingFinished
295         {
296             add
297             {
298                 sliderSlidingFinishedHandler += value;
299             }
300             remove
301             {
302                 sliderSlidingFinishedHandler -= value;
303             }
304         }
305
306         /// <summary>
307         /// The state changed event handler.
308         /// </summary>
309         /// <since_tizen> 6 </since_tizen>
310         [Obsolete("Deprecated in API8; Will be removed in API10. Please use View.ControlStateChangedEvent")]
311         public event EventHandler<StateChangedArgs> StateChangedEvent
312         {
313             add
314             {
315                 stateChangedHandler += value;
316             }
317             remove
318             {
319                 stateChangedHandler -= value;
320             }
321         }
322
323         /// <summary>
324         /// The direction type of slider.
325         /// </summary>
326         /// <since_tizen> 6 </since_tizen>
327         public enum DirectionType
328         {
329             /// <summary>
330             /// The Horizontal type.
331             /// </summary>
332             /// <since_tizen> 6 </since_tizen>
333             Horizontal,
334
335             /// <summary>
336             /// The Vertical type.
337             /// </summary>
338             /// <since_tizen> 6 </since_tizen>
339             Vertical
340         }
341
342         /// <summary>
343         /// The indicator type of slider.
344         /// </summary>
345         /// <since_tizen> 6 </since_tizen>
346         public enum IndicatorType
347         {
348             /// <summary> Only contains slider bar.</summary>
349             /// <since_tizen> 6 </since_tizen>
350             None,
351
352             /// <summary> Contains slider bar, IndicatorImage.</summary>
353             /// <since_tizen> 6 </since_tizen>
354             Image,
355
356             /// <summary> Contains slider bar, IndicatorText.</summary>
357             /// <since_tizen> 6 </since_tizen>
358             Text
359         }
360
361         /// <summary>
362         /// Return currently applied style.
363         /// </summary>
364         /// <remarks>
365         /// Modifying contents in style may cause unexpected behaviour.
366         /// </remarks>
367         /// <since_tizen> 8 </since_tizen>
368         public SliderStyle Style => (SliderStyle)(ViewStyle as SliderStyle)?.Clone();
369
370         /// <summary>
371         /// Gets or sets the direction type of slider.
372         /// </summary>
373         /// <since_tizen> 6 </since_tizen>
374         public DirectionType Direction
375         {
376             get
377             {
378                 return (DirectionType)GetValue(DirectionProperty);
379             }
380             set
381             {
382                 SetValue(DirectionProperty, value);
383                 NotifyPropertyChanged();
384             }
385         }
386         private DirectionType InternalDirection
387         {
388             get
389             {
390                 return direction;
391             }
392             set
393             {
394                 if (direction == value)
395                 {
396                     return;
397                 }
398                 direction = value;
399                 RelayoutBaseComponent(false);
400                 UpdateBgTrackSize();
401                 UpdateBgTrackPosition();
402                 UpdateWarningTrackSize();
403                 UpdateValue();
404             }
405         }
406
407         /// <summary>
408         /// Gets or sets the indicator type, arrow or sign.
409         /// </summary>
410         /// <since_tizen> 6 </since_tizen>
411         public IndicatorType Indicator
412         {
413             get
414             {
415                 return (IndicatorType)GetValue(IndicatorProperty);
416             }
417             set
418             {
419                 SetValue(IndicatorProperty, value);
420             }
421         }
422
423         /// <summary>
424         /// Gets or sets the minimum value of slider.
425         /// </summary>
426         /// <since_tizen> 6 </since_tizen>
427         public float MinValue
428         {
429             get
430             {
431                 return (float)GetValue(MinValueProperty);
432             }
433             set
434             {
435                 SetValue(MinValueProperty, value);
436                 NotifyPropertyChanged();
437             }
438         }
439         private float InternalMinValue
440         {
441             get
442             {
443                 return minValue;
444             }
445             set
446             {
447                 minValue = value;
448                 UpdateValue();
449             }
450         }
451
452         /// <summary>
453         /// Gets or sets the maximum value of slider.
454         /// </summary>
455         /// <since_tizen> 6 </since_tizen>
456         public float MaxValue
457         {
458             get
459             {
460                 return (float)GetValue(MaxValueProperty);
461             }
462             set
463             {
464                 SetValue(MaxValueProperty, value);
465                 NotifyPropertyChanged();
466             }
467         }
468         private float InternalMaxValue
469         {
470             get
471             {
472                 return maxValue;
473             }
474             set
475             {
476                 maxValue = value;
477                 UpdateValue();
478             }
479         }
480
481         /// <summary>
482         /// Gets or sets the current value of slider.
483         /// </summary>
484         /// <since_tizen> 6 </since_tizen>
485         public float CurrentValue
486         {
487             get
488             {
489                 return (float)GetValue(CurrentValueProperty);
490             }
491             set
492             {
493                 SetValue(CurrentValueProperty, value);
494             }
495         }
496
497         /// <summary>
498         /// Gets or sets the size of the thumb image object.
499         /// </summary>
500         /// <since_tizen> 6 </since_tizen>
501         public Size ThumbSize
502         {
503             get
504             {
505                 return GetValue(ThumbSizeProperty) as Size;
506             }
507             set
508             {
509                 SetValue(ThumbSizeProperty, value);
510                 NotifyPropertyChanged();
511             }
512         }
513         private Size InternalThumbSize
514         {
515             get
516             {
517                 return thumbImage?.Size;
518             }
519             set
520             {
521                 if (null != thumbImage)
522                 {
523                     thumbImage.Size = value;
524                     thumbSize = value;
525                 }
526             }
527         }
528
529         /// <summary>
530         /// Gets or sets the resource url of the thumb image object.
531         ///
532         /// Please use ThumbImageUrl property.
533         /// </summary>
534         /// <since_tizen> 6 </since_tizen>
535         public string ThumbImageURL
536         {
537             get
538             {
539                 return GetValue(ThumbImageURLProperty) as string;
540             }
541             set
542             {
543                 SetValue(ThumbImageURLProperty, value);
544                 NotifyPropertyChanged();
545             }
546         }
547         private string InternalThumbImageURL
548         {
549             get
550             {
551                 return thumbImage?.ResourceUrl;
552             }
553             set
554             {
555                 if (null != thumbImage)
556                 {
557                     thumbImage.ResourceUrl = value;
558                     thumbImageUrl = value;
559                 }
560             }
561         }
562
563         /// <summary>
564         /// Gets or sets the resource url selector of the thumb image object.
565         /// Getter returns copied selector value if exist, null otherwise.
566         ///
567         /// Please use ThumbImageUrl property.
568         /// </summary>
569         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
570         /// <since_tizen> 6 </since_tizen>
571         public StringSelector ThumbImageURLSelector
572         {
573             get
574             {
575                 return GetValue(ThumbImageURLSelectorProperty) as StringSelector;
576             }
577             set
578             {
579                 SetValue(ThumbImageURLSelectorProperty, value);
580                 NotifyPropertyChanged();
581             }
582         }
583         private StringSelector InternalThumbImageURLSelector
584         {
585             get => thumbImage?.ResourceUrlSelector == null ? null : new StringSelector(thumbImage.ResourceUrlSelector);
586             set
587             {
588                 if (value == null || thumbImage == null)
589                 {
590                     throw new NullReferenceException("Slider.ThumbImageURLSelector is null");
591                 }
592                 else
593                 {
594                     thumbImage.ResourceUrlSelector = value;
595                 }
596             }
597         }
598
599         /// <summary>
600         /// Gets or sets the Url of the thumb image.
601         /// </summary>
602         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
603         /// <since_tizen> 9 </since_tizen>
604         public Selector<string> ThumbImageUrl
605         {
606             get
607             {
608                 return GetValue(ThumbImageUrlProperty) as Selector<string>;
609             }
610             set
611             {
612                 SetValue(ThumbImageUrlProperty, value);
613                 NotifyPropertyChanged();
614             }
615         }
616         private Selector<string> InternalThumbImageUrl
617         {
618             get
619             {
620                 if (thumbImage == null)
621                 {
622                     return null;
623                 }
624                 else
625                 {
626                     return thumbImage.ResourceUrlSelector;
627                 }
628             }
629             set
630             {
631                 if (value == null || thumbImage == null)
632                 {
633                     throw new NullReferenceException("Slider.ThumbImageUrl is null");
634                 }
635                 else
636                 {
637                     thumbImage.ResourceUrlSelector = value;
638                 }
639             }
640         }
641
642         /// <summary>
643         /// Gets or sets the color of the thumb image object.
644         /// </summary>
645         /// <since_tizen> 8 </since_tizen>
646         public Color ThumbColor
647         {
648             get
649             {
650                 return GetValue(ThumbColorProperty) as Color;
651             }
652             set
653             {
654                 SetValue(ThumbColorProperty, value);
655                 NotifyPropertyChanged();
656             }
657         }
658         private Color InternalThumbColor
659         {
660             get
661             {
662                 return thumbImage?.Color;
663             }
664             set
665             {
666                 if (null != thumbImage)
667                 {
668                     thumbImage.BackgroundColor = value;
669                     thumbColor = value;
670                 }
671             }
672         }
673
674         /// <summary>
675         /// Gets or sets the color of the background track image object.
676         /// </summary>
677         /// <since_tizen> 6 </since_tizen>
678         public Color BgTrackColor
679         {
680             get
681             {
682                 return GetValue(BgTrackColorProperty) as Color;
683             }
684             set
685             {
686                 SetValue(BgTrackColorProperty, value);
687                 NotifyPropertyChanged();
688             }
689         }
690         private Color InternalBgTrackColor
691         {
692             get
693             {
694                 return bgTrackImage?.BackgroundColor;
695             }
696             set
697             {
698                 if (null != bgTrackImage)
699                 {
700                     bgTrackImage.BackgroundColor = value;
701                 }
702             }
703         }
704
705         /// <summary>
706         /// Gets or sets the color of the slided track image object.
707         /// </summary>
708         /// <since_tizen> 6 </since_tizen>
709         public Color SlidedTrackColor
710         {
711             get
712             {
713                 return GetValue(SlidedTrackColorProperty) as Color;
714             }
715             set
716             {
717                 SetValue(SlidedTrackColorProperty, value);
718                 NotifyPropertyChanged();
719             }
720         }
721         private Color InternalSlidedTrackColor
722         {
723             get
724             {
725                 return slidedTrackImage?.BackgroundColor;
726             }
727             set
728             {
729                 if (null != slidedTrackImage)
730                 {
731                     slidedTrackImage.BackgroundColor = value;
732                 }
733             }
734         }
735
736         /// <summary>
737         /// Gets or sets the thickness value of the track.
738         /// </summary>
739         /// <since_tizen> 6 </since_tizen>
740         public uint TrackThickness
741         {
742             get
743             {
744                 return (uint)GetValue(TrackThicknessProperty);
745             }
746             set
747             {
748                 SetValue(TrackThicknessProperty, value);
749             }
750         }
751
752         /// <summary>
753         /// Gets or sets the warning start value between minimum value and maximum value of slider.
754         /// </summary>
755         /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
756         [EditorBrowsable(EditorBrowsableState.Never)]
757         public float WarningStartValue
758         {
759             get
760             {
761                 return (float)GetValue(WarningStartValueProperty);
762             }
763             set
764             {
765                 SetValue(WarningStartValueProperty, value);
766                 NotifyPropertyChanged();
767             }
768         }
769         private float InternalWarningStartValue
770         {
771             get
772             {
773                 return warningStartValue;
774             }
775             set
776             {
777                 warningStartValue = value;
778                 UpdateValue();
779             }
780         }
781
782         /// <summary>
783         /// Gets or sets the color of the warning track image object.
784         /// </summary>
785         /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
786         [EditorBrowsable(EditorBrowsableState.Never)]
787         public Color WarningTrackColor
788         {
789             get
790             {
791                 return GetValue(WarningTrackColorProperty) as Color;
792             }
793             set
794             {
795                 SetValue(WarningTrackColorProperty, value);
796                 NotifyPropertyChanged();
797             }
798         }
799         private Color InternalWarningTrackColor
800         {
801             get
802             {
803                 return warningTrackImage?.BackgroundColor;
804             }
805             set
806             {
807                 if (null != warningTrackImage)
808                 {
809                     warningTrackImage.BackgroundColor = value;
810                 }
811             }
812         }
813
814         /// <summary>
815         /// Gets or sets the color of the warning slided track image object.
816         /// </summary>
817         /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
818         [EditorBrowsable(EditorBrowsableState.Never)]
819         public Color WarningSlidedTrackColor
820         {
821             get
822             {
823                 return GetValue(WarningSlidedTrackColorProperty) as Color;
824             }
825             set
826             {
827                 SetValue(WarningSlidedTrackColorProperty, value);
828                 NotifyPropertyChanged();
829             }
830         }
831         private Color InternalWarningSlidedTrackColor
832         {
833             get
834             {
835                 return warningSlidedTrackImage?.BackgroundColor;
836             }
837             set
838             {
839                 if (null != warningSlidedTrackImage)
840                 {
841                     warningSlidedTrackImage.BackgroundColor = value;
842                 }
843             }
844         }
845
846         /// <summary>
847         /// Gets or sets the Url of the warning thumb image.
848         /// </summary>
849         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
850         /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
851         [EditorBrowsable(EditorBrowsableState.Never)]
852         public Selector<string> WarningThumbImageUrl
853         {
854             get
855             {
856                 return GetValue(WarningThumbImageUrlProperty) as Selector<string>;
857             }
858             set
859             {
860                 SetValue(WarningThumbImageUrlProperty, value);
861                 NotifyPropertyChanged();
862             }
863         }
864         private Selector<string> InternalWarningThumbImageUrl
865         {
866             get
867             {
868                 return warningThumbImageUrlSelector;
869             }
870             set
871             {
872                 if (value == null || thumbImage == null)
873                 {
874                     throw new NullReferenceException("Slider.WarningThumbImageUrl is null");
875                 }
876                 else
877                 {
878                     warningThumbImageUrlSelector = value;
879                 }
880             }
881         }
882
883         /// <summary>
884         /// Gets or sets the color of the warning thumb image object.
885         /// </summary>
886         /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
887         [EditorBrowsable(EditorBrowsableState.Never)]
888         public Color WarningThumbColor
889         {
890             get
891             {
892                 return GetValue(WarningThumbColorProperty) as Color;
893             }
894             set
895             {
896                 SetValue(WarningThumbColorProperty, value);
897                 NotifyPropertyChanged();
898             }
899         }
900         private Color InternalWarningThumbColor
901         {
902             get
903             {
904                 return warningThumbColor;
905             }
906             set
907             {
908                 warningThumbColor = value;
909             }
910         }
911
912         /// <summary>
913         /// Gets or sets the resource url of the low indicator image object.
914         /// </summary>
915         /// <since_tizen> 6 </since_tizen>
916         public string LowIndicatorImageURL
917         {
918             get
919             {
920                 return GetValue(LowIndicatorImageURLProperty) as string;
921             }
922             set
923             {
924                 SetValue(LowIndicatorImageURLProperty, value);
925                 NotifyPropertyChanged();
926             }
927         }
928         private string InternalLowIndicatorImageURL
929         {
930             get
931             {
932                 return lowIndicatorImage?.ResourceUrl;
933             }
934             set
935             {
936                 if (null == lowIndicatorImage) lowIndicatorImage = new ImageView();
937                 lowIndicatorImage.ResourceUrl = value;
938             }
939         }
940
941         /// <summary>
942         /// Gets or sets the resource url of the high indicator image object.
943         /// </summary>
944         /// <since_tizen> 6 </since_tizen>
945         public string HighIndicatorImageURL
946         {
947             get
948             {
949                 return GetValue(HighIndicatorImageURLProperty) as string;
950             }
951             set
952             {
953                 SetValue(HighIndicatorImageURLProperty, value);
954                 NotifyPropertyChanged();
955             }
956         }
957         private string InternalHighIndicatorImageURL
958         {
959             get
960             {
961                 return highIndicatorImage?.ResourceUrl;
962             }
963             set
964             {
965                 if (null == highIndicatorImage) highIndicatorImage = new ImageView();
966                 highIndicatorImage.ResourceUrl = value;
967             }
968         }
969
970         /// <summary>
971         /// Gets or sets the text content of the low indicator text object.
972         /// </summary>
973         /// <since_tizen> 6 </since_tizen>
974         public string LowIndicatorTextContent
975         {
976             get
977             {
978                 return GetValue(LowIndicatorTextContentProperty) as string;
979             }
980             set
981             {
982                 SetValue(LowIndicatorTextContentProperty, value);
983                 NotifyPropertyChanged();
984             }
985         }
986         private string InternalLowIndicatorTextContent
987         {
988             get
989             {
990                 return lowIndicatorText?.Text;
991             }
992             set
993             {
994                 if (null != lowIndicatorText)
995                 {
996                     lowIndicatorText.Text = value;
997                 }
998             }
999         }
1000
1001         /// <summary>
1002         /// Gets or sets the text content of the high indicator text object.
1003         /// </summary>
1004         /// <since_tizen> 6 </since_tizen>
1005         public string HighIndicatorTextContent
1006         {
1007             get
1008             {
1009                 return GetValue(HighIndicatorTextContentProperty) as string;
1010             }
1011             set
1012             {
1013                 SetValue(HighIndicatorTextContentProperty, value);
1014                 NotifyPropertyChanged();
1015             }
1016         }
1017         private string InternalHighIndicatorTextContent
1018         {
1019             get
1020             {
1021                 return highIndicatorText?.Text;
1022             }
1023             set
1024             {
1025                 if (null != highIndicatorText)
1026                 {
1027                     highIndicatorText.Text = value;
1028                 }
1029             }
1030         }
1031
1032         /// <summary>
1033         /// Gets or sets the size of the low indicator object(image or text).
1034         /// </summary>
1035         /// <since_tizen> 6 </since_tizen>
1036         public Size LowIndicatorSize
1037         {
1038             get
1039             {
1040                 return GetValue(LowIndicatorSizeProperty) as Size;
1041             }
1042             set
1043             {
1044                 SetValue(LowIndicatorSizeProperty, value);
1045                 NotifyPropertyChanged();
1046             }
1047         }
1048         private Size InternalLowIndicatorSize
1049         {
1050             get
1051             {
1052                 return lowIndicatorSize;
1053             }
1054             set
1055             {
1056                 lowIndicatorSize = value;
1057                 UpdateLowIndicatorSize();
1058                 UpdateBgTrackSize();
1059                 UpdateBgTrackPosition();
1060                 UpdateValue();
1061             }
1062         }
1063
1064         /// <summary>
1065         /// Gets or sets the size of the high indicator object(image or text).
1066         /// </summary>
1067         /// <since_tizen> 6 </since_tizen>
1068         public Size HighIndicatorSize
1069         {
1070             get
1071             {
1072                 return GetValue(HighIndicatorSizeProperty) as Size;
1073             }
1074             set
1075             {
1076                 SetValue(HighIndicatorSizeProperty, value);
1077                 NotifyPropertyChanged();
1078             }
1079         }
1080         private Size InternalHighIndicatorSize
1081         {
1082             get
1083             {
1084                 return highIndicatorText?.Size;
1085             }
1086             set
1087             {
1088                 if (null != highIndicatorText)
1089                 {
1090                     highIndicatorText.Size = value;
1091                 }
1092             }
1093         }
1094
1095         /// <summary>
1096         /// Gets or sets the value of the space between track and indicator.
1097         /// </summary>
1098         /// <since_tizen> 6 </since_tizen>
1099         public uint SpaceBetweenTrackAndIndicator
1100         {
1101             get
1102             {
1103                 return (uint)GetValue(SpaceBetweenTrackAndIndicatorProperty);
1104             }
1105             set
1106             {
1107                 SetValue(SpaceBetweenTrackAndIndicatorProperty, value);
1108             }
1109         }
1110
1111         /// <summary>
1112         /// Flag to decide whether the value indicator is shown
1113         /// </summary>
1114         /// <since_tizen> 9 </since_tizen>
1115         public bool IsValueShown
1116         {
1117             get
1118             {
1119                 return (bool)GetValue(IsValueShownProperty);
1120             }
1121             set
1122             {
1123                 SetValue(IsValueShownProperty, value);
1124             }
1125         }
1126
1127         /// <summary>
1128         /// Gets or sets the text of value indicator.
1129         /// </summary>
1130         /// <since_tizen> 9 </since_tizen>
1131         public string ValueIndicatorText
1132         {
1133             get
1134             {
1135                 return (string)GetValue(ValueIndicatorTextProperty);
1136             }
1137             set
1138             {
1139                 SetValue(ValueIndicatorTextProperty, value);
1140             }
1141         }
1142
1143         /// <summary>
1144         /// Gets or sets the size of the value indicator image object.
1145         /// </summary>
1146         /// <since_tizen> 9 </since_tizen>
1147         public Size ValueIndicatorSize
1148         {
1149             get
1150             {
1151                 return GetValue(ValueIndicatorSizeProperty) as Size;
1152             }
1153             set
1154             {
1155                 SetValue(ValueIndicatorSizeProperty, value);
1156                 NotifyPropertyChanged();
1157             }
1158         }
1159         private Size InternalValueIndicatorSize
1160         {
1161             get
1162             {
1163                 return valueIndicatorImage?.Size;
1164             }
1165             set
1166             {
1167                 if (null != valueIndicatorImage)
1168                 {
1169                     valueIndicatorImage.Size = value;
1170                 }
1171             }
1172         }
1173
1174         /// <summary>
1175         /// Gets or sets the resource url of the value indicator image object.
1176         /// </summary>
1177         /// <since_tizen> 9 </since_tizen>
1178         public string ValueIndicatorUrl
1179         {
1180             get
1181             {
1182                 return GetValue(ValueIndicatorUrlProperty) as string;
1183             }
1184             set
1185             {
1186                 SetValue(ValueIndicatorUrlProperty, value);
1187                 NotifyPropertyChanged();
1188             }
1189         }
1190         private string InternalValueIndicatorUrl
1191         {
1192             get
1193             {
1194                 return valueIndicatorImage?.ResourceUrl;
1195             }
1196             set
1197             {
1198                 if (null != valueIndicatorImage)
1199                 {
1200                     valueIndicatorImage.ResourceUrl = value;
1201                 }
1202             }
1203         }
1204
1205         /// <summary>
1206         /// Flag to decide whether the thumb snaps to the nearest discrete value when the user drags the thumb or taps.
1207         ///
1208         /// The default value is false.
1209         /// </summary>
1210         /// <since_tizen> 9 </since_tizen>
1211         public bool IsDiscrete
1212         {
1213             get
1214             {
1215                 return (bool)GetValue(IsDiscreteProperty);
1216             }
1217             set
1218             {
1219                 SetValue(IsDiscreteProperty, value);
1220                 NotifyPropertyChanged();
1221             }
1222         }
1223         private bool InternalIsDiscrete { get; set; } = false;
1224
1225         /// <summary>
1226         /// Gets or sets the discrete value of slider.
1227         /// </summary>
1228         /// <remarks>
1229         /// The discrete value is evenly spaced between MinValue and MaxValue.
1230         /// For example, MinValue is 0, MaxValue is 100, and DiscreteValue is 20.
1231         /// Then, the thumb can only go to 0, 20, 40, 60, 80, and 100.
1232         /// The default is 0.
1233         /// </remarks>
1234         /// <since_tizen> 9 </since_tizen>
1235         public float DiscreteValue
1236         {
1237             get
1238             {
1239                 return (float)GetValue(DiscreteValueProperty);
1240             }
1241             set
1242             {
1243                 SetValue(DiscreteValueProperty, value);
1244                 NotifyPropertyChanged();
1245             }
1246         }
1247         private float InternalDiscreteValue
1248         {
1249             get
1250             {
1251                 return discreteValue;
1252             }
1253             set
1254             {
1255                 discreteValue = value;
1256                 UpdateValue();
1257             }
1258         }
1259
1260         private Extents spaceBetweenTrackAndIndicator
1261         {
1262             get
1263             {
1264                 if (null == spaceTrackIndicator)
1265                 {
1266                     spaceTrackIndicator = new Extents((ushort start, ushort end, ushort top, ushort bottom) =>
1267                     {
1268                         Extents extents = new Extents(start, end, top, bottom);
1269                         spaceTrackIndicator.CopyFrom(extents);
1270                     }, 0, 0, 0, 0);
1271                 }
1272
1273                 return spaceTrackIndicator;
1274             }
1275         }
1276
1277         private IndicatorType privateIndicatorType
1278         {
1279             get
1280             {
1281                 return indicatorType;
1282             }
1283             set
1284             {
1285                 if (indicatorType == value)
1286                 {
1287                     return;
1288                 }
1289                 indicatorType = value;
1290                 RelayoutBaseComponent(false);
1291                 UpdateBgTrackSize();
1292                 UpdateBgTrackPosition();
1293                 UpdateValue();
1294             }
1295         }
1296
1297         private uint privateTrackThickness
1298         {
1299             get
1300             {
1301                 return trackThickness ?? 0;
1302             }
1303             set
1304             {
1305                 trackThickness = value;
1306                 if (bgTrackImage != null)
1307                 {
1308                     if (direction == DirectionType.Horizontal)
1309                     {
1310                         bgTrackImage.SizeHeight = (float)trackThickness.Value;
1311                     }
1312                     else if (direction == DirectionType.Vertical)
1313                     {
1314                         bgTrackImage.SizeWidth = (float)trackThickness.Value;
1315                     }
1316                 }
1317                 if (slidedTrackImage != null)
1318                 {
1319                     if (direction == DirectionType.Horizontal)
1320                     {
1321                         slidedTrackImage.SizeHeight = (float)trackThickness.Value;
1322                     }
1323                     else if (direction == DirectionType.Vertical)
1324                     {
1325                         slidedTrackImage.SizeWidth = (float)trackThickness.Value;
1326                     }
1327                 }
1328                 if (warningTrackImage != null)
1329                 {
1330                     if (direction == DirectionType.Horizontal)
1331                     {
1332                         warningTrackImage.SizeHeight = (float)trackThickness.Value;
1333                     }
1334                     else if (direction == DirectionType.Vertical)
1335                     {
1336                         warningTrackImage.SizeWidth = (float)trackThickness.Value;
1337                     }
1338                 }
1339                 if (warningSlidedTrackImage != null)
1340                 {
1341                     if (direction == DirectionType.Horizontal)
1342                     {
1343                         warningSlidedTrackImage.SizeHeight = (float)trackThickness.Value;
1344                     }
1345                     else if (direction == DirectionType.Vertical)
1346                     {
1347                         warningSlidedTrackImage.SizeWidth = (float)trackThickness.Value;
1348                     }
1349                 }
1350             }
1351         }
1352
1353         private uint privateSpaceBetweenTrackAndIndicator
1354         {
1355             get
1356             {
1357                 return privateTrackPadding.Start;
1358             }
1359             set
1360             {
1361                 ushort val = (ushort)value;
1362                 privateTrackPadding = new Extents(val, val, val, val);
1363             }
1364         }
1365
1366         private Extents privateTrackPadding
1367         {
1368             get
1369             {
1370                 return spaceBetweenTrackAndIndicator;
1371             }
1372             set
1373             {
1374                 spaceBetweenTrackAndIndicator.CopyFrom(value);
1375                 UpdateComponentByIndicatorTypeChanged();
1376                 UpdateBgTrackSize();
1377                 UpdateBgTrackPosition();
1378                 UpdateValue();
1379             }
1380         }
1381
1382         /// <summary>
1383         /// Focus gained callback.
1384         /// </summary>
1385         /// <since_tizen> 8 </since_tizen>
1386         public override void OnFocusGained()
1387         {
1388             //State = ControlStates.Focused;
1389             UpdateState(true, isPressed);
1390             base.OnFocusGained();
1391         }
1392
1393         /// <summary>
1394         /// Focus Lost callback.
1395         /// </summary>
1396         /// <since_tizen> 8 </since_tizen>
1397         public override void OnFocusLost()
1398         {
1399             //State = ControlStates.Normal;
1400             UpdateState(false, isPressed);
1401             base.OnFocusLost();
1402         }
1403
1404         /// <inheritdoc/>
1405         [EditorBrowsable(EditorBrowsableState.Never)]
1406         public override bool OnKey(Key key)
1407         {
1408             if (!IsEnabled || null == key)
1409             {
1410                 return false;
1411             }
1412
1413             if (key.State == Key.StateType.Down)
1414             {
1415                 if ((direction == DirectionType.Horizontal && key.KeyPressedName == "Left") ||
1416                     (direction == DirectionType.Vertical && key.KeyPressedName == "Down"))
1417                 {
1418                     if (MinValue < CurrentValue)
1419                     {
1420                         isPressed = true;
1421                         if (IsDiscrete)
1422                         {
1423                             float value = CurrentValue - discreteValue;
1424                             CurrentValue = value < MinValue ? MinValue : value;
1425                         }
1426                         else
1427                         {
1428                             CurrentValue -= 1;
1429                         }
1430                         return true; // Consumed
1431                     }
1432                 }
1433                 else if ((direction == DirectionType.Horizontal && key.KeyPressedName == "Right") ||
1434                          (direction == DirectionType.Vertical && key.KeyPressedName == "Up"))
1435                 {
1436                     if (MaxValue > CurrentValue)
1437                     {
1438                         isPressed = true;
1439                         if (IsDiscrete)
1440                         {
1441                             float value = CurrentValue + discreteValue;
1442                             CurrentValue = value > MaxValue ? MaxValue : value;
1443                         }
1444                         else
1445                         {
1446                             CurrentValue += 1;
1447                         }
1448                         return true; // Consumed
1449                     }
1450                 }
1451             }
1452             else if (key.State == Key.StateType.Up)
1453             {
1454                 isPressed = false;
1455             }
1456
1457             return false;
1458         }
1459
1460         /// <summary>
1461         /// Apply style to scrollbar.
1462         /// </summary>
1463         /// <param name="viewStyle">The style to apply.</param>
1464         /// <since_tizen> 8 </since_tizen>
1465         public override void ApplyStyle(ViewStyle viewStyle)
1466         {
1467             base.ApplyStyle(viewStyle);
1468
1469             SliderStyle sliderStyle = viewStyle as SliderStyle;
1470
1471             if (null != sliderStyle?.Progress)
1472             {
1473                 CreateSlidedTrack().ApplyStyle(sliderStyle.Progress);
1474             }
1475
1476             if (null != sliderStyle?.LowIndicator)
1477             {
1478                 CreateLowIndicatorText().ApplyStyle(sliderStyle.LowIndicator);
1479             }
1480
1481             if (null != sliderStyle?.HighIndicator)
1482             {
1483                 CreateHighIndicatorText().ApplyStyle(sliderStyle.HighIndicator);
1484             }
1485
1486             if (null != sliderStyle?.Track)
1487             {
1488                 CreateBackgroundTrack().ApplyStyle(sliderStyle.Track);
1489             }
1490
1491             if (null != sliderStyle?.Thumb)
1492             {
1493                 CreateThumb().ApplyStyle(sliderStyle.Thumb);
1494             }
1495
1496             if (null != sliderStyle?.ValueIndicatorText)
1497             {
1498                 CreateValueIndicatorText().ApplyStyle(sliderStyle.ValueIndicatorText);
1499             }
1500
1501             if (null != sliderStyle?.ValueIndicatorImage)
1502             {
1503                 CreateValueIndicator().ApplyStyle(sliderStyle.ValueIndicatorImage);
1504             }
1505
1506             if (null != sliderStyle?.WarningTrack)
1507             {
1508                 CreateWarningTrack().ApplyStyle(sliderStyle.WarningTrack);
1509             }
1510
1511             if (null != sliderStyle?.WarningProgress)
1512             {
1513                 CreateWarningSlidedTrack().ApplyStyle(sliderStyle.WarningProgress);
1514             }
1515
1516             EnableControlStatePropagation = true;
1517         }
1518
1519         /// <summary>
1520         /// Prevents from showing child widgets in AT-SPI tree.
1521         /// </summary>
1522         [EditorBrowsable(EditorBrowsableState.Never)]
1523         protected override bool AccessibilityShouldReportZeroChildren()
1524         {
1525             return true;
1526         }
1527
1528         /// <summary>
1529         /// Gets minimum value for Accessibility.
1530         /// </summary>
1531         [EditorBrowsable(EditorBrowsableState.Never)]
1532         protected override double AccessibilityGetMinimum()
1533         {
1534             return (double)MinValue;
1535         }
1536
1537         /// <summary>
1538         /// Gets the current value for Accessibility.
1539         /// </summary>
1540         [EditorBrowsable(EditorBrowsableState.Never)]
1541         protected override double AccessibilityGetCurrent()
1542         {
1543             return (double)CurrentValue;
1544         }
1545
1546         /// <summary>
1547         /// Gets maximum value for Accessibility.
1548         /// </summary>
1549         [EditorBrowsable(EditorBrowsableState.Never)]
1550         protected override double AccessibilityGetMaximum()
1551         {
1552             return (double)MaxValue;
1553         }
1554
1555         /// <summary>
1556         /// Sets the current value using Accessibility.
1557         /// </summary>
1558         [EditorBrowsable(EditorBrowsableState.Never)]
1559         protected override bool AccessibilitySetCurrent(double value)
1560         {
1561             var current = (float)value;
1562
1563             if (current >= MinValue && current <= MaxValue)
1564             {
1565                 CurrentValue = current;
1566                 if (sliderValueChangedHandler != null)
1567                 {
1568                     sliderValueChangedHandler(this, new SliderValueChangedEventArgs { CurrentValue = current });
1569                 }
1570                 return true;
1571             }
1572
1573             return false;
1574         }
1575
1576         /// <summary>
1577         /// Gets minimum increment for Accessibility.
1578         /// </summary>
1579         [EditorBrowsable(EditorBrowsableState.Never)]
1580         protected override double AccessibilityGetMinimumIncrement()
1581         {
1582             // FIXME
1583             return (MaxValue - MinValue) / 20.0;
1584         }
1585
1586         /// <summary>
1587         /// Initialize AT-SPI object.
1588         /// </summary>
1589         [EditorBrowsable(EditorBrowsableState.Never)]
1590         public override void OnInitialize()
1591         {
1592             base.OnInitialize();
1593             SetAccessibilityConstructor(Role.Slider, AccessibilityInterface.Value);
1594         }
1595
1596         /// <summary>
1597         /// Get Slider style.
1598         /// </summary>
1599         /// <returns>The default slider style.</returns>
1600         /// <since_tizen> 8 </since_tizen>
1601         protected override ViewStyle CreateViewStyle()
1602         {
1603             return new SliderStyle();
1604         }
1605
1606         /// <summary>
1607         /// Dispose Slider.
1608         /// </summary>
1609         /// <param name="type">Dispose type.</param>
1610         /// <since_tizen> 6 </since_tizen>
1611         protected override void Dispose(DisposeTypes type)
1612         {
1613             if (disposed)
1614             {
1615                 return;
1616             }
1617
1618             if (type == DisposeTypes.Explicit)
1619             {
1620                 if (null != panGestureDetector)
1621                 {
1622                     panGestureDetector.Detach(this);
1623                     panGestureDetector.Detected -= OnPanGestureDetected;
1624                     panGestureDetector.Dispose();
1625                     panGestureDetector = null;
1626                 }
1627
1628                 if (null != thumbImage)
1629                 {
1630                     thumbImage.TouchEvent -= OnTouchEventForThumb;
1631                     Utility.Dispose(thumbImage);
1632                 }
1633                 Utility.Dispose(warningSlidedTrackImage);
1634                 Utility.Dispose(warningTrackImage);
1635                 Utility.Dispose(slidedTrackImage);
1636                 Utility.Dispose(bgTrackImage);
1637                 Utility.Dispose(lowIndicatorImage);
1638                 Utility.Dispose(highIndicatorImage);
1639                 Utility.Dispose(lowIndicatorText);
1640                 Utility.Dispose(highIndicatorText);
1641                 Utility.Dispose(valueIndicatorImage);
1642                 Utility.Dispose(valueIndicatorText);
1643
1644                 this.TouchEvent -= OnTouchEventForTrack;
1645             }
1646
1647             base.Dispose(type);
1648         }
1649
1650         /// <summary>
1651         /// Update Slider by style.
1652         /// </summary>
1653         /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
1654         [EditorBrowsable(EditorBrowsableState.Never)]
1655         protected override void OnUpdate()
1656         {
1657             RelayoutBaseComponent();
1658
1659             UpdateComponentByIndicatorTypeChanged();
1660             UpdateBgTrackSize();
1661             UpdateBgTrackPosition();
1662             UpdateWarningTrackSize();
1663             UpdateLowIndicatorSize();
1664             UpdateValue();
1665         }
1666
1667         /// <inheritdoc/>
1668         [EditorBrowsable(EditorBrowsableState.Never)]
1669         protected override void OnEnabled(bool enabled)
1670         {
1671             base.OnEnabled(enabled);
1672             UpdateValue();
1673         }
1674
1675         private void CalculateCurrentValueByGesture(float offset)
1676         {
1677             currentSlidedOffset += offset;
1678
1679             if (currentSlidedOffset <= 0)
1680             {
1681                 this.CurrentValue = minValue;
1682             }
1683             else if (currentSlidedOffset >= BgTrackLength())
1684             {
1685                 this.CurrentValue = maxValue;
1686             }
1687             else
1688             {
1689                 int bgTrackLength = BgTrackLength();
1690                 if (bgTrackLength != 0)
1691                 {
1692                     this.CurrentValue = ((currentSlidedOffset / (float)bgTrackLength) * (float)(maxValue - minValue)) + minValue;
1693                 }
1694             }
1695
1696             if (IsDiscrete)
1697             {
1698                 this.CurrentValue = CalculateDiscreteValue(this.CurrentValue);
1699             }
1700
1701             if (valueChangedHandler != null)
1702             {
1703                 ValueChangedArgs args = new ValueChangedArgs();
1704                 args.CurrentValue = this.CurrentValue;
1705                 valueChangedHandler(this, args);
1706             }
1707
1708             if (sliderValueChangedHandler != null)
1709             {
1710                 SliderValueChangedEventArgs args = new SliderValueChangedEventArgs();
1711                 args.CurrentValue = this.CurrentValue;
1712                 sliderValueChangedHandler(this, args);
1713             }
1714         }
1715
1716         private bool OnTouchEventForTrack(object source, TouchEventArgs e)
1717         {
1718             if (!IsEnabled)
1719             {
1720                 return false;
1721             }
1722
1723             PointStateType state = e.Touch.GetState(0);
1724             if (state == PointStateType.Down)
1725             {
1726                 if (isValueShown)
1727                 {
1728                     valueIndicatorImage.Show();
1729                 }
1730
1731                 Vector2 pos = e.Touch.GetLocalPosition(0);
1732                 CalculateCurrentValueByTouch(pos);
1733                 UpdateValue();
1734                 if (null != slidingFinishedHandler)
1735                 {
1736                     SlidingFinishedArgs args = new SlidingFinishedArgs();
1737                     args.CurrentValue = curValue;
1738                     slidingFinishedHandler(this, args);
1739                 }
1740
1741                 if (null != sliderSlidingFinishedHandler)
1742                 {
1743                     SliderSlidingFinishedEventArgs args = new SliderSlidingFinishedEventArgs();
1744                     args.CurrentValue = curValue;
1745                     sliderSlidingFinishedHandler(this, args);
1746                 }
1747             }
1748             else if (state == PointStateType.Up)
1749             {
1750                 if (isValueShown)
1751                 {
1752                     valueIndicatorImage.Hide();
1753                 }
1754             }
1755             return false;
1756         }
1757
1758         private bool OnTouchEventForThumb(object source, TouchEventArgs e)
1759         {
1760             PointStateType state = e.Touch.GetState(0);
1761             if (state == PointStateType.Down)
1762             {
1763                 UpdateState(isFocused, true);
1764             }
1765             else if (state == PointStateType.Up)
1766             {
1767                 UpdateState(isFocused, false);
1768             }
1769             return true;
1770         }
1771
1772         private void CalculateCurrentValueByTouch(Vector2 pos)
1773         {
1774             int bgTrackLength = BgTrackLength();
1775             if (direction == DirectionType.Horizontal)
1776             {
1777                 currentSlidedOffset = pos.X;
1778             }
1779             else if (direction == DirectionType.Vertical)
1780             {
1781                 currentSlidedOffset = bgTrackLength - pos.Y;
1782             }
1783
1784             if (bgTrackLength != 0)
1785             {
1786                 this.CurrentValue = ((currentSlidedOffset / (float)bgTrackLength) * (maxValue - minValue)) + minValue;
1787
1788                 if (IsDiscrete)
1789                 {
1790                     this.CurrentValue = CalculateDiscreteValue(this.CurrentValue);
1791                 }
1792
1793                 if (null != valueChangedHandler)
1794                 {
1795                     ValueChangedArgs args = new ValueChangedArgs();
1796                     args.CurrentValue = this.CurrentValue;
1797                     valueChangedHandler(this, args);
1798                 }
1799
1800                 if (null != sliderValueChangedHandler)
1801                 {
1802                     SliderValueChangedEventArgs args = new SliderValueChangedEventArgs();
1803                     args.CurrentValue = this.CurrentValue;
1804                     sliderValueChangedHandler(this, args);
1805                 }
1806             }
1807         }
1808
1809         private float CalculateDiscreteValue(float value)
1810         {
1811             return ((float)Math.Round((value / discreteValue)) * discreteValue);
1812         }
1813
1814         private void UpdateState(bool isFocusedNew, bool isPressedNew)
1815         {
1816             if (isFocused == isFocusedNew && isPressed == isPressedNew)
1817             {
1818                 return;
1819             }
1820             if (thumbImage == null || Style == null)
1821             {
1822                 return;
1823             }
1824             isFocused = isFocusedNew;
1825             isPressed = isPressedNew;
1826
1827             if(!IsEnabled) // Disabled
1828             {
1829                 ControlState = ControlState.Disabled;
1830
1831                 if (stateChangedHandler != null)
1832                 {
1833                     StateChangedArgs args = new StateChangedArgs();
1834                     args.CurrentState = (ControlStates)ControlStates.Disabled;
1835                     stateChangedHandler(this, args);
1836                 }
1837             }
1838             else if (!isFocused && !isPressed)
1839             {
1840                 ControlState = ControlState.Normal;
1841
1842                 if (stateChangedHandler != null)
1843                 {
1844                     StateChangedArgs args = new StateChangedArgs();
1845                     args.CurrentState = (ControlStates)ControlStates.Normal;
1846                     stateChangedHandler(this, args);
1847                 }
1848             }
1849             else if (isPressed)
1850             {
1851                 ControlState = ControlState.Pressed;
1852
1853                 if (stateChangedHandler != null)
1854                 {
1855                     StateChangedArgs args = new StateChangedArgs();
1856                     args.CurrentState = (ControlStates)ControlStates.Pressed;
1857                     stateChangedHandler(this, args);
1858                 }
1859             }
1860             else if (!isPressed && isFocused)
1861             {
1862                 ControlState = ControlState.Focused;
1863
1864                 if (stateChangedHandler != null)
1865                 {
1866                     StateChangedArgs args = new StateChangedArgs();
1867                     args.CurrentState = (ControlStates)ControlStates.Focused;
1868                     stateChangedHandler(this, args);
1869                 }
1870             }
1871         }
1872
1873         private void UpdateComponentByIndicatorTypeChanged()
1874         {
1875             IndicatorType type = CurrentIndicatorType();
1876             if (type == IndicatorType.None)
1877             {
1878                 if (lowIndicatorImage != null)
1879                 {
1880                     lowIndicatorImage.Hide();
1881                 }
1882                 if (highIndicatorImage != null)
1883                 {
1884                     highIndicatorImage.Hide();
1885                 }
1886                 if (lowIndicatorText != null)
1887                 {
1888                     lowIndicatorText.Hide();
1889                 }
1890                 if (highIndicatorText != null)
1891                 {
1892                     highIndicatorText.Hide();
1893                 }
1894             }
1895             else if (type == IndicatorType.Image)
1896             {
1897                 if (lowIndicatorImage != null)
1898                 {
1899                     lowIndicatorImage.Show();
1900                 }
1901                 if (highIndicatorImage != null)
1902                 {
1903                     highIndicatorImage.Show();
1904                 }
1905                 if (lowIndicatorText != null)
1906                 {
1907                     lowIndicatorText.Hide();
1908                 }
1909                 if (highIndicatorText != null)
1910                 {
1911                     highIndicatorText.Hide();
1912                 }
1913             }
1914             else if (type == IndicatorType.Text)
1915             {
1916                 if (lowIndicatorText != null)
1917                 {
1918                     lowIndicatorText.Show();
1919                 }
1920                 if (highIndicatorText != null)
1921                 {
1922                     highIndicatorText.Show();
1923                 }
1924                 if (lowIndicatorImage != null)
1925                 {
1926                     lowIndicatorImage.Hide();
1927                 }
1928                 if (highIndicatorImage != null)
1929                 {
1930                     highIndicatorImage.Hide();
1931                 }
1932             }
1933         }
1934
1935         /// <summary>
1936         /// Value Changed event data.
1937         /// </summary>
1938         /// <since_tizen> 6 </since_tizen>
1939         [Obsolete("Deprecated in API8; Will be removed in API10. Please use SliderValueChangedEventArgs instead.")]
1940         [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
1941         public class ValueChangedArgs : EventArgs
1942         {
1943             /// <summary>
1944             /// Current value
1945             /// </summary>
1946             /// <since_tizen> 6 </since_tizen>
1947             /// It will be removed in API10
1948             [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:Do not declare visible instance fields")]
1949             [Obsolete("Deprecated in API8; Will be removed in API10. Please use SliderValueChangedEventArgs.CurrentValue instead.")]
1950             public float CurrentValue;
1951         }
1952
1953         /// <summary>
1954         /// Value Changed event data.
1955         /// </summary>
1956         /// <since_tizen> 6 </since_tizen>
1957         [Obsolete("Deprecated in API8; Will be removed in API10. Please use SliderSlidingFinishedEventArgs instead.")]
1958         [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
1959         public class SlidingFinishedArgs : EventArgs
1960         {
1961             /// <summary>
1962             /// Current value
1963             /// </summary>
1964             /// <since_tizen> 6 </since_tizen>
1965             /// It will be removed in API10
1966             [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:Do not declare visible instance fields")]
1967             [Obsolete("Deprecated in API8; Will be removed in API10. Please use SliderSlidingFinishedEventArgs.CurrentValue instead.")]
1968             public float CurrentValue;
1969         }
1970
1971         /// <summary>
1972         /// State Changed event data.
1973         /// </summary>
1974         /// <since_tizen> 6 </since_tizen>
1975         [Obsolete("Deprecated in API8; Will be removed in API10. Please use View.ControlStateChangedEventArgs")]
1976         [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
1977         public class StateChangedArgs : EventArgs
1978         {
1979             /// <summary>
1980             /// Current state
1981             /// </summary>
1982             /// <since_tizen> 6 </since_tizen>
1983             /// It will be removed in API10
1984             [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:Do not declare visible instance fields")]
1985             [Obsolete("Deprecated in API8; Will be removed in API10")]
1986             public ControlStates CurrentState;
1987         }
1988     }
1989 }