Refine background property of control (#1183)
[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 class Slider : Control
29     {
30         // the background track image object
31         private ImageView bgTrackImage = null;
32         // the slided track image object
33         private ImageView slidedTrackImage = null;
34         // the thumb image object
35         private ImageView thumbImage = null;
36         // the low indicator image object
37         private ImageView lowIndicatorImage = null;
38         // the high indicator image object
39         private ImageView highIndicatorImage = null;
40         // the low indicator text object
41         private TextLabel lowIndicatorText = null;
42         // the high indicator text object
43         private TextLabel highIndicatorText = null;
44         // the direction type
45         private DirectionType direction = DirectionType.Horizontal;
46         // the indicator type
47         private IndicatorType indicatorType = IndicatorType.None;
48         private const float round = 0.5f;
49         // the minimum value
50         private float? minValue = null;
51         // the maximum value
52         private float? maxValue = null;
53         // the current value
54         private float? curValue = null;
55         // the size of the low indicator
56         private Size lowIndicatorSize = null;
57         // the size of the high indicator
58         private Size highIndicatorSize = null;
59         // the track thickness value
60         private uint? trackThickness = null;
61         // the value of the space between track and indicator object
62         private Extents _spaceBetweenTrackAndIndicator = null;
63         private Extents spaceBetweenTrackAndIndicator
64         {
65             get
66             {
67                 if (null == _spaceBetweenTrackAndIndicator)
68                 {
69                     _spaceBetweenTrackAndIndicator = new Extents((ushort start, ushort end, ushort top, ushort bottom) =>
70                     {
71                         Extents extents = new Extents(start, end, top, bottom);
72                         _spaceBetweenTrackAndIndicator.CopyFrom(extents);
73                     }, 0, 0, 0, 0);
74                 }
75
76                 return _spaceBetweenTrackAndIndicator;
77             }
78         }
79
80
81         private PanGestureDetector panGestureDetector = null;
82         private float currentSlidedOffset;
83         private EventHandler<ValueChangedArgs> valueChangedHandler;
84         private EventHandler<SlidingFinishedArgs> slidingFinishedHandler;
85         private EventHandler<StateChangedArgs> stateChangedHandler;
86
87         bool isFocused = false;
88         bool isPressed = false;
89
90         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
91         [EditorBrowsable(EditorBrowsableState.Never)]
92         public static readonly BindableProperty IndicatorTypeProperty = BindableProperty.Create("IndicatorType", typeof(IndicatorType), typeof(Slider), IndicatorType.None, propertyChanged: (bindable, oldValue, newValue) =>
93         {
94             var instance = (Slider)bindable;
95             if (newValue != null)
96             {
97                 instance.privateIndicatorType = (IndicatorType)newValue;
98             }
99         },
100         defaultValueCreator: (bindable) =>
101         {
102             var instance = (Slider)bindable;
103             return instance.privateIndicatorType;
104         });
105         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
106         [EditorBrowsable(EditorBrowsableState.Never)]
107         public static readonly BindableProperty SpaceBetweenTrackAndIndicatorProperty = BindableProperty.Create("SpaceBetweenTrackAndIndicator", typeof(uint), typeof(Slider), (uint)0, propertyChanged: (bindable, oldValue, newValue) =>
108         {
109             var instance = (Slider)bindable;
110             if (newValue != null)
111             {
112                 instance.privateSpaceBetweenTrackAndIndicator = (uint)newValue;
113             }
114         },
115         defaultValueCreator: (bindable) =>
116         {
117             var instance = (Slider)bindable;
118             return instance.privateSpaceBetweenTrackAndIndicator;
119         });
120         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
121         [EditorBrowsable(EditorBrowsableState.Never)]
122         public static readonly BindableProperty TrackThicknessProperty = BindableProperty.Create("TrackThickness", typeof(uint), typeof(Slider), (uint)0, propertyChanged: (bindable, oldValue, newValue) =>
123         {
124             var instance = (Slider)bindable;
125             if (newValue != null)
126             {
127                 instance.privateTrackThickness = (uint)newValue;
128             }
129         },
130         defaultValueCreator: (bindable) =>
131         {
132             var instance = (Slider)bindable;
133             return instance.privateTrackThickness;
134         });
135         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
136         [EditorBrowsable(EditorBrowsableState.Never)]
137         public static readonly BindableProperty TrackPaddingProperty = BindableProperty.Create("TrackPadding", typeof(Extents), typeof(Slider), null, propertyChanged: (bindable, oldValue, newValue) =>
138         {
139             var instance = (Slider)bindable;
140             if (newValue != null)
141             {
142                 instance.privateTrackPadding.CopyFrom((Extents)newValue);
143             }
144         },
145         defaultValueCreator: (bindable) =>
146         {
147             var instance = (Slider)bindable;
148             return instance.privateTrackPadding;
149         });
150
151         /// <summary>
152         /// The constructor of the Slider class.
153         /// </summary>
154         /// <since_tizen> 6 </since_tizen>
155         public Slider() 
156         {
157             Initialize();
158         }
159
160         /// <summary>
161         /// The constructor of the Slider class with specific style.
162         /// </summary>
163         /// <param name="style">The string to initialize the Slider</param>
164         /// <since_tizen> 6 </since_tizen>
165         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
166         [EditorBrowsable(EditorBrowsableState.Never)]
167         public Slider(string style) : base(style)
168         {
169             Initialize();
170         }
171
172         /// <summary>
173         /// The constructor of the Slider class with specific style.
174         /// </summary>
175         /// <param name="style">The style object to initialize the Slider</param>
176         /// <since_tizen> 6 </since_tizen>
177         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
178         [EditorBrowsable(EditorBrowsableState.Never)]
179         public Slider(SliderStyle style) : base(style)
180         {
181             Initialize();
182         }
183
184         /// <summary>
185         /// The value changed event handler.
186         /// </summary>
187         /// <since_tizen> 6 </since_tizen>
188         public event EventHandler<ValueChangedArgs> ValueChangedEvent
189         {
190             add
191             {
192                 valueChangedHandler += value;
193             }
194             remove
195             {
196                 valueChangedHandler -= value;
197             }
198         }
199
200         /// <summary>
201         /// The sliding finished event handler.
202         /// </summary>
203         /// <since_tizen> 6 </since_tizen>
204         public event EventHandler<SlidingFinishedArgs> SlidingFinishedEvent
205         {
206             add
207             {
208                 slidingFinishedHandler += value;
209             }
210             remove
211             {
212                 slidingFinishedHandler -= value;
213             }
214         }
215
216         /// <summary>
217         /// The state changed event handler.
218         /// </summary>
219         /// <since_tizen> 6 </since_tizen>
220         public event EventHandler<StateChangedArgs> StateChangedEvent
221         {
222             add
223             {
224                 stateChangedHandler += value;
225             }
226             remove
227             {
228                 stateChangedHandler -= value;
229             }
230         }
231
232         /// <summary>
233         /// The direction type of slider.
234         /// </summary>
235         /// <since_tizen> 6 </since_tizen>
236         public enum DirectionType
237         {
238             /// <summary>
239             /// The Horizontal type.
240             /// </summary>
241             /// <since_tizen> 6 </since_tizen>
242             Horizontal,
243
244             /// <summary>
245             /// The Vertical type.
246             /// </summary>
247             /// <since_tizen> 6 </since_tizen>
248             Vertical
249         }
250
251         /// <summary>
252         /// The indicator type of slider.
253         /// </summary>
254         /// <since_tizen> 6 </since_tizen>
255         public enum IndicatorType
256         {
257             /// <summary> Only contains slider bar.</summary>
258             /// <since_tizen> 6 </since_tizen>
259             None,
260
261             /// <summary> Contains slider bar, IndicatorImage.</summary>
262             /// <since_tizen> 6 </since_tizen>
263             Image,
264
265             /// <summary> Contains slider bar, IndicatorText.</summary>
266             /// <since_tizen> 6 </since_tizen>
267             Text
268         }
269
270         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
271         [EditorBrowsable(EditorBrowsableState.Never)]
272         public new SliderStyle Style => ViewStyle as SliderStyle;
273
274         /// <summary>
275         /// Gets or sets the direction type of slider.
276         /// </summary>
277         /// <since_tizen> 6 </since_tizen>
278         public DirectionType Direction
279         {
280             get
281             {
282                 return direction;
283             }
284             set
285             {
286                 if (direction == value)
287                 {
288                     return;
289                 }
290                 direction = value;
291                 RelayoutBaseComponent(false);
292                 UpdateBgTrackSize();
293                 UpdateBgTrackPosition();
294                 UpdateValue();
295             }
296         }
297
298         /// <summary>
299         /// Gets or sets the indicator type, arrow or sign.
300         /// </summary>
301         /// <since_tizen> 6 </since_tizen>
302         public IndicatorType Indicator
303         {
304             get
305             {
306                 return (IndicatorType)GetValue(IndicatorTypeProperty);
307             }
308             set
309             {
310                 SetValue(IndicatorTypeProperty, value);
311             }
312         }
313         private IndicatorType privateIndicatorType
314         {
315             get
316             {
317                 return indicatorType;
318             }
319             set
320             {
321                 if (indicatorType == value)
322                 {
323                     return;
324                 }
325                 indicatorType = value;
326                 RelayoutBaseComponent(false);
327                 UpdateBgTrackSize();
328                 UpdateBgTrackPosition();
329                 UpdateValue();
330             }
331         }
332
333         /// <summary>
334         /// Gets or sets the minimum value of slider.
335         /// </summary>
336         /// <since_tizen> 6 </since_tizen>
337         public float MinValue
338         {
339             get
340             {
341                 return minValue ?? 0;
342             }
343             set
344             {
345                 minValue = value;
346                 UpdateValue();
347             }
348         }
349
350         /// <summary>
351         /// Gets or sets the maximum value of slider.
352         /// </summary>
353         /// <since_tizen> 6 </since_tizen>
354         public float MaxValue
355         {
356             get
357             {
358                 return maxValue ?? 100;
359             }
360             set
361             {
362                 maxValue = value;
363                 UpdateValue();
364             }
365         }
366
367         /// <summary>
368         /// Gets or sets the current value of slider.
369         /// </summary>
370         /// <since_tizen> 6 </since_tizen>
371         public float CurrentValue
372         {
373             get
374             {
375                 return curValue ?? 0;
376             }
377             set
378             {
379                 curValue = value;
380                 UpdateValue();
381             }
382         }
383
384         /// <summary>
385         /// Gets or sets the size of the thumb image object.
386         /// </summary>
387         /// <since_tizen> 6 </since_tizen>
388         public Size ThumbSize
389         {
390             get
391             {
392                 return Style.Thumb?.Size;
393             }
394             set
395             {
396                 Style.Thumb.Size = value;
397             }
398         }
399
400         /// <summary>
401         /// Gets or sets the resource url of the thumb image object.
402         /// </summary>
403         /// <since_tizen> 6 </since_tizen>
404         public string ThumbImageURL
405         {
406             get
407             {
408                 return Style?.Thumb?.ResourceUrl?.All;
409             }
410             set
411             {
412                 if (null != Style?.Thumb)
413                 {
414                     Style.Thumb.ResourceUrl = value; 
415                 }
416             }
417         }
418
419         private StringSelector thumbImageURLSelector = new StringSelector();
420         /// <summary>
421         /// Gets or sets the resource url selector of the thumb image object.
422         /// </summary>
423         /// <since_tizen> 6 </since_tizen>
424         public StringSelector ThumbImageURLSelector
425         {
426             get
427             {
428                 return thumbImageURLSelector;
429             }
430             set
431             {
432                 thumbImageURLSelector.Clone(value);
433             }
434         }
435
436         /// <summary>
437         /// Gets or sets the color of the background track image object.
438         /// </summary>
439         /// <since_tizen> 6 </since_tizen>
440         public Color BgTrackColor
441         {
442             get
443             {
444                 return Style?.Track?.BackgroundColor?.All;
445             }
446             set
447             {
448                 if (null != Style?.Track)
449                 {
450                     Style.Track.BackgroundColor = value;
451                 }
452             }
453         }
454
455         /// <summary>
456         /// Gets or sets the color of the slided track image object.
457         /// </summary>
458         /// <since_tizen> 6 </since_tizen>
459         public Color SlidedTrackColor
460         {
461             get
462             {
463                 return Style?.Progress?.BackgroundColor?.All;
464             }
465             set
466             {
467                 if (null != Style?.Progress)
468                 {
469                     Style.Progress.BackgroundColor = value;
470                 }
471             }
472         }
473
474         /// <summary>
475         /// Gets or sets the thickness value of the track.
476         /// </summary>
477         /// <since_tizen> 6 </since_tizen>
478         public uint TrackThickness
479         {
480             get
481             {
482                 return (uint)GetValue(TrackThicknessProperty);
483             }
484             set
485             {
486                 SetValue(TrackThicknessProperty, value);
487             }
488         }
489         private uint privateTrackThickness
490         {
491             get
492             {
493                 return trackThickness ?? 0;
494             }
495             set
496             {
497                 trackThickness = value;
498                 if (bgTrackImage != null)
499                 {
500                     if (direction == DirectionType.Horizontal)
501                     {
502                         bgTrackImage.SizeHeight = (float)trackThickness.Value;
503                     }
504                     else if (direction == DirectionType.Vertical)
505                     {
506                         bgTrackImage.SizeWidth = (float)trackThickness.Value;
507                     }
508                 }
509                 if (slidedTrackImage != null)
510                 {
511                     if (direction == DirectionType.Horizontal)
512                     {
513                         slidedTrackImage.SizeHeight = (float)trackThickness.Value;
514                     }
515                     else if (direction == DirectionType.Vertical)
516                     {
517                         slidedTrackImage.SizeWidth = (float)trackThickness.Value;
518                     }
519                 }
520             }
521         }
522
523         /// <summary>
524         /// Gets or sets the resource url of the low indicator image object.
525         /// </summary>
526         /// <since_tizen> 6 </since_tizen>
527         public string LowIndicatorImageURL
528         {
529             get
530             {
531                 return Style?.LowIndicatorImage?.ResourceUrl?.All;
532             }
533             set
534             {
535                 if (null != Style?.LowIndicatorImage)
536                 {
537                     Style.LowIndicatorImage.ResourceUrl = value;
538                 }
539             }
540         }
541
542         /// <summary>
543         /// Gets or sets the resource url of the high indicator image object.
544         /// </summary>
545         /// <since_tizen> 6 </since_tizen>
546         public string HighIndicatorImageURL
547         {
548             get
549             {
550                 return Style?.HighIndicatorImage?.ResourceUrl?.All;
551             }
552             set
553             {
554                 if (null != Style?.HighIndicatorImage)
555                 {
556                     Style.HighIndicatorImage.ResourceUrl = value;
557                 }
558             }
559         }
560
561         /// <summary>
562         /// Gets or sets the text content of the low indicator text object.
563         /// </summary>
564         /// <since_tizen> 6 </since_tizen>
565         public string LowIndicatorTextContent
566         {
567             get
568             {
569                 return Style?.LowIndicator?.Text?.All;
570             }
571             set
572             {
573                 if (null != Style?.LowIndicator)
574                 {
575                     Style.LowIndicator.Text= value;
576                 }
577             }
578         }
579
580         /// <summary>
581         /// Gets or sets the text content of the high indicator text object.
582         /// </summary>
583         /// <since_tizen> 6 </since_tizen>
584         public string HighIndicatorTextContent
585         {
586             get
587             {
588                 return Style?.HighIndicator?.Text?.All;
589             }
590             set
591             {
592                 if (null != Style?.HighIndicator)
593                 {
594                     Style.HighIndicator.Text = value;
595                 }
596             }
597         }
598
599         /// <summary>
600         /// Gets or sets the size of the low indicator object(image or text).
601         /// </summary>
602         /// <since_tizen> 6 </since_tizen>
603         public Size LowIndicatorSize
604         {
605             get
606             {
607                 return lowIndicatorSize;
608             }
609             set
610             {
611                 lowIndicatorSize = value;
612                 UpdateLowIndicatorSize();
613                 UpdateBgTrackSize();
614                 UpdateBgTrackPosition();
615                 UpdateValue();
616             }
617         }
618
619         /// <summary>
620         /// Gets or sets the size of the high indicator object(image or text).
621         /// </summary>
622         /// <since_tizen> 6 </since_tizen>
623         public Size HighIndicatorSize
624         {
625             get
626             {
627                 return Style.HighIndicator.Size;
628             }
629             set
630             {
631                 Style.HighIndicator.Size = value;
632             }
633         }
634
635         /// <summary>
636         /// Gets or sets the value of the space between track and indicator.
637         /// </summary>
638         /// <since_tizen> 6 </since_tizen>
639         public uint SpaceBetweenTrackAndIndicator
640         {
641             get
642             {
643                 return (uint)GetValue(SpaceBetweenTrackAndIndicatorProperty);
644             }
645             set
646             {
647                 SetValue(SpaceBetweenTrackAndIndicatorProperty, value);
648             }
649         }
650         private uint privateSpaceBetweenTrackAndIndicator
651         {
652             get
653             {
654                 return TrackPadding.Start;
655             }
656             set
657             {
658                 ushort val = (ushort)value;
659                 TrackPadding = new Extents(val, val, val, val);
660             }
661         }
662
663         /// <summary>
664         /// Gets or sets the value of the space between track and indicator.
665         /// </summary>
666         /// <since_tizen> 6 </since_tizen>
667         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
668         [EditorBrowsable(EditorBrowsableState.Never)]
669         public Extents TrackPadding
670         {
671             get
672             {
673                 return (Extents)GetValue(TrackPaddingProperty);
674             }
675             set
676             {
677                 SetValue(TrackPaddingProperty, value);
678             }
679         }
680         private Extents privateTrackPadding
681         {
682             get
683             {
684                 return spaceBetweenTrackAndIndicator;
685             }
686             set
687             {
688                 spaceBetweenTrackAndIndicator.CopyFrom(value);
689                 UpdateComponentByIndicatorTypeChanged();
690                 UpdateBgTrackSize();
691                 UpdateBgTrackPosition();
692                 UpdateValue();
693             }
694         }
695
696         /// <summary>
697         /// Focus gained callback.
698         /// </summary>
699         /// <since_tizen> 6 </since_tizen>
700         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
701         [EditorBrowsable(EditorBrowsableState.Never)]
702         public override void OnFocusGained()
703         {
704             //State = ControlStates.Focused;
705             UpdateState(true, isPressed);
706             base.OnFocusGained();
707         }
708
709         /// <summary>
710         /// Focus Lost callback.
711         /// </summary>
712         /// <since_tizen> 6 </since_tizen>
713         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
714         [EditorBrowsable(EditorBrowsableState.Never)]
715         public override void OnFocusLost()
716         {
717             //State = ControlStates.Normal;
718             UpdateState(false, isPressed);
719             base.OnFocusLost();
720         }
721
722         /// <summary>
723         /// Get Slider attribues.
724         /// </summary>
725         /// <since_tizen> 6 </since_tizen>
726         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
727         [EditorBrowsable(EditorBrowsableState.Never)]
728         protected override ViewStyle GetViewStyle()
729         {
730             return new SliderStyle();
731         }
732
733         /// <summary>
734         /// Dispose Slider.
735         /// </summary>
736         /// <param name="type">Dispose type.</param>
737         /// <since_tizen> 6 </since_tizen>
738         protected override void Dispose(DisposeTypes type)
739         {
740             if (disposed)
741             {
742                 return;
743             }
744
745             if (type == DisposeTypes.Explicit)
746             {
747                 if (null != panGestureDetector)
748                 {
749                     if (null != thumbImage)
750                     {
751                         panGestureDetector.Detach(thumbImage);
752                     }
753                     panGestureDetector.Detected -= OnPanGestureDetected;
754                     panGestureDetector.Dispose();
755                     panGestureDetector = null;
756                 }
757                 
758                 if (null != thumbImage)
759                 {
760                     thumbImage.TouchEvent -= OnTouchEventForThumb;
761                     Utility.Dispose(thumbImage);
762                 }
763                 Utility.Dispose(slidedTrackImage);
764                 if (null != bgTrackImage)
765                 {
766                     bgTrackImage.TouchEvent -= OnTouchEventForBgTrack;
767                     Utility.Dispose(bgTrackImage);
768                 }
769                 Utility.Dispose(lowIndicatorImage);
770                 Utility.Dispose(highIndicatorImage);
771                 Utility.Dispose(lowIndicatorText);
772                 Utility.Dispose(highIndicatorText);
773             }
774
775             base.Dispose(type);
776         }
777
778         /// <summary>
779         /// Update Slider by attributes.
780         /// </summary>
781         /// <since_tizen> 6 </since_tizen>
782         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
783         [EditorBrowsable(EditorBrowsableState.Never)]
784         protected override void OnUpdate()
785         {
786             RelayoutBaseComponent();
787
788             UpdateComponentByIndicatorTypeChanged();
789             UpdateBgTrackSize();
790             UpdateBgTrackPosition();
791             UpdateLowIndicatorSize();
792             UpdateValue();
793         }
794
795         /// <summary>
796         /// Theme change callback when theme is changed, this callback will be trigger.
797         /// </summary>
798         /// <param name="sender">serder object</param>
799         /// <param name="e">ThemeChangeEventArgs</param>
800         /// <since_tizen> 6 </since_tizen>
801         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
802         [EditorBrowsable(EditorBrowsableState.Never)]
803         protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e)
804         {
805             SliderStyle sliderStyle = StyleManager.Instance.GetAttributes(style) as SliderStyle;
806             if (sliderStyle != null)
807             {
808                 Style?.CopyFrom(sliderStyle);
809                 RelayoutRequest();
810             }
811         }
812
813         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
814         [EditorBrowsable(EditorBrowsableState.Never)]
815         public override void ApplyStyle(ViewStyle viewStyle)
816         {
817             base.ApplyStyle(viewStyle);
818
819             SliderStyle sliderStyle = viewStyle as SliderStyle;
820
821             if (null != sliderStyle.Progress)
822             {
823                 CreateSlidedTrackAttributes();
824             }
825
826             if (null != sliderStyle.LowIndicator)
827             {
828                 CreateLowIndicatorTextAttributes();
829             }
830
831             if (null != sliderStyle.HighIndicator)
832             {
833                 CreateHighIndicatorTextAttributes();
834             }
835
836             if (null != sliderStyle.Track)
837             {
838                 CreateBackgroundTrackAttributes();
839             }
840
841             if (null != sliderStyle.Thumb)
842             {
843                 CreateThumbAttributes();
844             }
845         }
846
847         private void Initialize()
848         {
849             currentSlidedOffset = 0;
850             isFocused = false;
851             isPressed = false;
852             LayoutDirectionChanged += OnLayoutDirectionChanged;
853         }
854
855         private void OnLayoutDirectionChanged(object sender, LayoutDirectionChangedEventArgs e)
856         {
857             RelayoutRequest();
858         }
859
860         private void CreateSlidedTrackAttributes()
861         {
862             if (null == slidedTrackImage)
863             {
864                 slidedTrackImage = new ImageView()
865                 {
866                     WidthResizePolicy = ResizePolicyType.Fixed,
867                     HeightResizePolicy = ResizePolicyType.Fixed
868                 };
869
870                 if (bgTrackImage != null)
871                 {
872                     bgTrackImage.Add(slidedTrackImage);
873                 }
874
875                 if (null != thumbImage)
876                 {
877                     slidedTrackImage.Add(thumbImage);
878                 }
879             }
880
881             if (null == Style.Progress)
882             {
883                 Style.Progress = new ImageViewStyle();
884             }
885
886             slidedTrackImage.ApplyStyle(Style.Progress);
887         }
888
889         private void CreateLowIndicatorTextAttributes()
890         {
891             if (null == lowIndicatorText)
892             {
893                 lowIndicatorText = new TextLabel()
894                 {
895                     WidthResizePolicy = ResizePolicyType.Fixed,
896                     HeightResizePolicy = ResizePolicyType.Fixed
897                 };
898                 this.Add(lowIndicatorText);
899             }
900
901             if (null == Style.LowIndicator)
902             {
903                 Style.LowIndicator = new TextLabelStyle();
904             }
905
906             lowIndicatorText.ApplyStyle(Style.LowIndicator);
907         }
908
909         private void CreateHighIndicatorTextAttributes()
910         {
911             if (null == highIndicatorText)
912             {
913                 highIndicatorText = new TextLabel()
914                 {
915                     WidthResizePolicy = ResizePolicyType.Fixed,
916                     HeightResizePolicy = ResizePolicyType.Fixed
917                 };
918                 this.Add(highIndicatorText);
919             }
920
921             if (null == Style.HighIndicator)
922             {
923                 Style.HighIndicator = new TextLabelStyle();
924             }
925
926             highIndicatorText.ApplyStyle(Style.HighIndicator);
927         }
928
929         private void CreateBackgroundTrackAttributes()
930         {
931             if (null == bgTrackImage)
932             {
933                 bgTrackImage = new ImageView()
934                 {
935                     WidthResizePolicy = ResizePolicyType.Fixed,
936                     HeightResizePolicy = ResizePolicyType.Fixed,
937                     ParentOrigin = Tizen.NUI.ParentOrigin.Center,
938                     PivotPoint = Tizen.NUI.PivotPoint.Center,
939                     PositionUsesPivotPoint = true
940                 };
941                 this.Add(bgTrackImage);
942
943                 if (null != slidedTrackImage)
944                 {
945                     bgTrackImage.Add(slidedTrackImage);
946                 }
947
948                 bgTrackImage.TouchEvent += OnTouchEventForBgTrack;
949             }
950
951             if (null == Style.Track)
952             {
953                 Style.Track = new ImageViewStyle();
954             }
955
956             bgTrackImage.ApplyStyle(Style.Track);
957         }
958
959         private void CreateThumbAttributes()
960         {
961             if (null == thumbImage)
962             {
963                 thumbImage = new ImageView()
964                 {
965                     WidthResizePolicy = ResizePolicyType.Fixed,
966                     HeightResizePolicy = ResizePolicyType.Fixed,
967                     ParentOrigin = NUI.ParentOrigin.Center,
968                     PivotPoint = NUI.PivotPoint.Center,
969                     PositionUsesPivotPoint = true
970                 };
971                 if (slidedTrackImage != null)
972                 {
973                     slidedTrackImage.Add(thumbImage);
974                 }
975                 thumbImage.TouchEvent += OnTouchEventForThumb;
976
977                 panGestureDetector = new PanGestureDetector();
978                 panGestureDetector.Attach(thumbImage);
979                 panGestureDetector.Detected += OnPanGestureDetected;
980             }
981
982             if (null == Style.Thumb)
983             {
984                 Style.Thumb= new ImageViewStyle();
985             }
986
987             thumbImage.ApplyStyle(Style.Thumb);
988         }
989
990         private void OnPanGestureDetected(object source, PanGestureDetector.DetectedEventArgs e)
991         {
992             if (e.PanGesture.State == Gesture.StateType.Started)
993             {
994                 if (direction == DirectionType.Horizontal)
995                 {
996                     currentSlidedOffset = slidedTrackImage.SizeWidth;
997                 }
998                 else if (direction == DirectionType.Vertical)
999                 {
1000                     currentSlidedOffset = slidedTrackImage.SizeHeight;
1001                 }
1002                 UpdateState(isFocused, true);
1003             }
1004
1005             if (e.PanGesture.State == Gesture.StateType.Continuing || e.PanGesture.State == Gesture.StateType.Started)
1006             {
1007                 if (direction == DirectionType.Horizontal)
1008                 {
1009                     CalculateCurrentValueByGesture(e.PanGesture.Displacement.X);
1010                 }
1011                 else if (direction == DirectionType.Vertical)
1012                 {
1013                     CalculateCurrentValueByGesture(-e.PanGesture.Displacement.Y);
1014                 }
1015                 UpdateValue();
1016             }
1017
1018             if (e.PanGesture.State == Gesture.StateType.Finished)
1019             {
1020                 if (null != slidingFinishedHandler)
1021                 {
1022                     SlidingFinishedArgs args = new SlidingFinishedArgs();
1023                     args.CurrentValue = curValue.Value;
1024                     slidingFinishedHandler(this, args);
1025                 }
1026
1027                 UpdateState(isFocused, false);
1028             }
1029         }
1030
1031         // Relayout basic component: track, thumb and indicator
1032         private void RelayoutBaseComponent(bool isInitial = true)
1033         {
1034             if (direction == DirectionType.Horizontal)
1035             {
1036                 if (slidedTrackImage != null)
1037                 {
1038                     slidedTrackImage.ParentOrigin = NUI.ParentOrigin.CenterLeft;
1039                     slidedTrackImage.PivotPoint = NUI.PivotPoint.CenterLeft;
1040                     slidedTrackImage.PositionUsesPivotPoint = true;
1041                 }
1042                 if (thumbImage != null)
1043                 {
1044                     thumbImage.ParentOrigin = NUI.ParentOrigin.CenterRight;
1045                     thumbImage.PivotPoint = NUI.PivotPoint.Center;
1046                     thumbImage.PositionUsesPivotPoint = true;
1047                 }
1048                 if (lowIndicatorImage != null)
1049                 {
1050                     lowIndicatorImage.ParentOrigin = NUI.ParentOrigin.CenterLeft;
1051                     lowIndicatorImage.PivotPoint = NUI.PivotPoint.CenterLeft;
1052                     lowIndicatorImage.PositionUsesPivotPoint = true;
1053                 }
1054                 if (highIndicatorImage != null)
1055                 {
1056                     highIndicatorImage.ParentOrigin = NUI.ParentOrigin.CenterRight;
1057                     highIndicatorImage.PivotPoint = NUI.PivotPoint.CenterRight;
1058                     highIndicatorImage.PositionUsesPivotPoint = true;
1059                 }
1060                 if (lowIndicatorText != null)
1061                 {
1062                     lowIndicatorText.ParentOrigin = NUI.ParentOrigin.CenterLeft;
1063                     lowIndicatorText.PivotPoint = NUI.PivotPoint.CenterLeft;
1064                     lowIndicatorText.PositionUsesPivotPoint = true;
1065                 }
1066                 if (highIndicatorText != null)
1067                 {
1068                     highIndicatorText.ParentOrigin = NUI.ParentOrigin.CenterRight;
1069                     highIndicatorText.PivotPoint = NUI.PivotPoint.CenterRight;
1070                     highIndicatorText.PositionUsesPivotPoint = true;
1071                 }
1072                 if (panGestureDetector != null)
1073                 {
1074                     if (!isInitial)
1075                     {
1076                         panGestureDetector.RemoveDirection(PanGestureDetector.DirectionVertical);
1077                     }
1078                     panGestureDetector.AddDirection(PanGestureDetector.DirectionHorizontal);
1079                 }
1080             }
1081             else if (direction == DirectionType.Vertical)
1082             {
1083                 if (slidedTrackImage != null)
1084                 {
1085                     slidedTrackImage.ParentOrigin = NUI.ParentOrigin.BottomCenter;
1086                     slidedTrackImage.PivotPoint = NUI.PivotPoint.BottomCenter;
1087                     slidedTrackImage.PositionUsesPivotPoint = true;
1088                 }
1089                 if (thumbImage != null)
1090                 {
1091                     thumbImage.ParentOrigin = NUI.ParentOrigin.TopCenter;
1092                     thumbImage.PivotPoint = NUI.PivotPoint.Center;
1093                     thumbImage.PositionUsesPivotPoint = true;
1094                 }
1095                 if (lowIndicatorImage != null)
1096                 {
1097                     lowIndicatorImage.ParentOrigin = NUI.ParentOrigin.BottomCenter;
1098                     lowIndicatorImage.PivotPoint = NUI.PivotPoint.BottomCenter;
1099                     lowIndicatorImage.PositionUsesPivotPoint = true;
1100                 }
1101                 if (highIndicatorImage != null)
1102                 {
1103                     highIndicatorImage.ParentOrigin = NUI.ParentOrigin.TopCenter;
1104                     highIndicatorImage.PivotPoint = NUI.PivotPoint.TopCenter;
1105                     highIndicatorImage.PositionUsesPivotPoint = true;
1106                 }
1107                 if (lowIndicatorText != null)
1108                 {
1109                     lowIndicatorText.ParentOrigin = NUI.ParentOrigin.BottomCenter;
1110                     lowIndicatorText.PivotPoint = NUI.PivotPoint.BottomCenter;
1111                     lowIndicatorText.PositionUsesPivotPoint = true;
1112                 }
1113                 if (highIndicatorText != null)
1114                 {
1115                     highIndicatorText.ParentOrigin = NUI.ParentOrigin.TopCenter;
1116                     highIndicatorText.PivotPoint = NUI.PivotPoint.TopCenter;
1117                     highIndicatorText.PositionUsesPivotPoint = true;
1118                 }
1119                 if (panGestureDetector != null)
1120                 {
1121                     if (!isInitial)
1122                     {
1123                         panGestureDetector.RemoveDirection(PanGestureDetector.DirectionHorizontal);
1124                     }
1125                     panGestureDetector.AddDirection(PanGestureDetector.DirectionVertical);
1126                 }
1127             }
1128         }
1129
1130         private int BgTrackLength()
1131         {
1132             int bgTrackLength = 0;
1133             IndicatorType type = CurrentIndicatorType();
1134
1135             if (type == IndicatorType.None)
1136             {
1137                 if (direction == DirectionType.Horizontal)
1138                 {
1139                     bgTrackLength = this.Size2D.Width;
1140                 }
1141                 else if (direction == DirectionType.Vertical)
1142                 {
1143                     bgTrackLength = this.Size2D.Height;
1144                 }
1145             }
1146             else if (type == IndicatorType.Image)
1147             {// <lowIndicatorImage> <spaceBetweenTrackAndIndicator> <bgTrack> <spaceBetweenTrackAndIndicator> <highIndicatorImage>
1148                 Size lowIndicatorImageSize = LowIndicatorImageSize();
1149                 Size highIndicatorImageSize = HighIndicatorImageSize();
1150                 int curSpace = (int)CurrentSpaceBetweenTrackAndIndicator();
1151                 if (direction == DirectionType.Horizontal)
1152                 {
1153                     int lowIndicatorSpace = ((lowIndicatorImageSize.Width == 0) ? (0) : ((int)(curSpace + lowIndicatorImageSize.Width)));
1154                     int highIndicatorSpace = ((highIndicatorImageSize.Width == 0) ? (0) : ((int)(curSpace + highIndicatorImageSize.Width)));
1155                     bgTrackLength = this.Size2D.Width - lowIndicatorSpace - highIndicatorSpace;
1156                 }
1157                 else if (direction == DirectionType.Vertical)
1158                 {
1159                     int lowIndicatorSpace = ((lowIndicatorImageSize.Height == 0) ? (0) : ((int)(curSpace + lowIndicatorImageSize.Height)));
1160                     int highIndicatorSpace = ((highIndicatorImageSize.Height == 0) ? (0) : ((int)(curSpace + highIndicatorImageSize.Height)));
1161                     bgTrackLength = this.Size2D.Height - lowIndicatorSpace - highIndicatorSpace;
1162                 }
1163             }
1164             else if (type == IndicatorType.Text)
1165             {// <lowIndicatorText> <spaceBetweenTrackAndIndicator> <bgTrack> <spaceBetweenTrackAndIndicator> <highIndicatorText>
1166                 Size lowIndicatorTextSize = LowIndicatorTextSize();
1167                 Size highIndicatorTextSize = HighIndicatorTextSize();
1168                 int curSpace = (int)CurrentSpaceBetweenTrackAndIndicator();
1169                 if (direction == DirectionType.Horizontal)
1170                 {
1171                     int lowIndicatorSpace = ((lowIndicatorTextSize.Width == 0) ? (0) : ((int)(curSpace + lowIndicatorTextSize.Width)));
1172                     int highIndicatorSpace = ((highIndicatorTextSize.Width == 0) ? (0) : ((int)(curSpace + highIndicatorTextSize.Width)));
1173                     bgTrackLength = this.Size2D.Width - lowIndicatorSpace - highIndicatorSpace;
1174                 }
1175                 else if (direction == DirectionType.Vertical)
1176                 {
1177                     int lowIndicatorSpace = ((lowIndicatorTextSize.Height == 0) ? (0) : ((int)(curSpace + lowIndicatorTextSize.Height)));
1178                     int highIndicatorSpace = ((highIndicatorTextSize.Height == 0) ? (0) : ((int)(curSpace + highIndicatorTextSize.Height)));
1179                     bgTrackLength = this.Size2D.Height - lowIndicatorSpace - highIndicatorSpace;
1180                 }
1181             }
1182             return bgTrackLength;
1183         }
1184
1185         private void UpdateLowIndicatorSize()
1186         {
1187             if (lowIndicatorSize != null)
1188             {
1189                 if (lowIndicatorImage != null)
1190                 {
1191                     lowIndicatorImage.Size = lowIndicatorSize;
1192                 }
1193                 if (lowIndicatorText != null)
1194                 {
1195                     lowIndicatorText.Size = lowIndicatorSize;
1196                 }
1197             }
1198             else
1199             {
1200                 if (lowIndicatorImage != null && Style != null && Style.LowIndicatorImage!= null && Style.LowIndicatorImage.Size != null)
1201                 {
1202                     lowIndicatorImage.Size = Style.LowIndicatorImage.Size;
1203                 }
1204                 if (lowIndicatorText != null && Style != null && Style.LowIndicator!= null && Style.LowIndicator.Size != null)
1205                 {
1206                     lowIndicatorText.Size = Style.LowIndicator.Size;
1207                 }
1208             }
1209         }
1210
1211         private void UpdateBgTrackSize()
1212         {
1213             if(bgTrackImage == null)
1214             {
1215                 return;
1216             }
1217             int curTrackThickness = (int)CurrentTrackThickness();
1218             int bgTrackLength = BgTrackLength();
1219             if (direction == DirectionType.Horizontal)
1220             {
1221                 bgTrackImage.Size2D = new Size2D(bgTrackLength, curTrackThickness);
1222             }
1223             else if (direction == DirectionType.Vertical)
1224             {
1225                 bgTrackImage.Size2D = new Size2D(curTrackThickness, bgTrackLength);
1226             }
1227         }
1228
1229         private void UpdateBgTrackPosition()
1230         {
1231             if (bgTrackImage == null)
1232             {
1233                 return;
1234             }
1235             IndicatorType type = CurrentIndicatorType();
1236
1237             if (type == IndicatorType.None)
1238             {
1239                 bgTrackImage.Position2D = new Position2D(0, 0);
1240             }
1241             else if (type == IndicatorType.Image)
1242             {
1243                 Size lowIndicatorImageSize = LowIndicatorImageSize();
1244                 Size highIndicatorImageSize = HighIndicatorImageSize();
1245                 int curSpace = (int)CurrentSpaceBetweenTrackAndIndicator();
1246                 if (direction == DirectionType.Horizontal)
1247                 {
1248                     int lowIndicatorSpace = ((lowIndicatorImageSize.Width == 0) ? (0) : ((int)(curSpace + lowIndicatorImageSize.Width)));
1249                     int highIndicatorSpace = ((highIndicatorImageSize.Width == 0) ? (0) : ((int)(curSpace + highIndicatorImageSize.Width)));
1250                     bgTrackImage.Position2D = new Position2D(lowIndicatorSpace - (lowIndicatorSpace + highIndicatorSpace) / 2, 0);
1251                 }
1252                 else if (direction == DirectionType.Vertical)
1253                 {
1254                     int lowIndicatorSpace = ((lowIndicatorImageSize.Height == 0) ? (0) : ((int)(curSpace + lowIndicatorImageSize.Height)));
1255                     int highIndicatorSpace = ((highIndicatorImageSize.Height == 0) ? (0) : ((int)(curSpace + highIndicatorImageSize.Height)));
1256                     bgTrackImage.Position2D = new Position2D(0, lowIndicatorSpace - (lowIndicatorSpace + highIndicatorSpace) / 2);
1257                 }
1258             }
1259             else if (type == IndicatorType.Text)
1260             {
1261                 Size lowIndicatorTextSize = LowIndicatorTextSize();
1262                 Size highIndicatorTextSize = HighIndicatorTextSize();
1263                 int curSpace = (int)CurrentSpaceBetweenTrackAndIndicator();
1264                 if (direction == DirectionType.Horizontal)
1265                 {
1266                     int lowIndicatorSpace = ((lowIndicatorTextSize.Width == 0) ? (0) : ((int)(curSpace + lowIndicatorTextSize.Width)));
1267                     int highIndicatorSpace = ((highIndicatorTextSize.Width == 0) ? (0) : ((int)(curSpace + highIndicatorTextSize.Width)));
1268                     bgTrackImage.Position2D = new Position2D(lowIndicatorSpace - (lowIndicatorSpace + highIndicatorSpace) / 2, 0);
1269                 }
1270                 else if (direction == DirectionType.Vertical)
1271                 {
1272                     int lowIndicatorSpace = ((lowIndicatorTextSize.Height == 0) ? (0) : ((int)(curSpace + lowIndicatorTextSize.Height)));
1273                     int highIndicatorSpace = ((highIndicatorTextSize.Height == 0) ? (0) : ((int)(curSpace + highIndicatorTextSize.Height)));
1274                     bgTrackImage.Position2D = new Position2D(0, -(lowIndicatorSpace - (lowIndicatorSpace + highIndicatorSpace) / 2));
1275                 }
1276             }
1277         }
1278
1279         private void UpdateValue()
1280         {
1281             if (slidedTrackImage == null || curValue == null || minValue == null || maxValue == null)
1282             {
1283                 return;
1284             }
1285             if (curValue < minValue || curValue > maxValue || minValue >= maxValue)
1286             {
1287                 return;
1288             }
1289             
1290             float ratio = 0;
1291             ratio = (float)(curValue - minValue) / (float)(maxValue - minValue);
1292
1293             uint curTrackThickness = CurrentTrackThickness();
1294
1295             if (direction == DirectionType.Horizontal)
1296             {
1297                 if (LayoutDirection == ViewLayoutDirectionType.RTL)
1298                 {
1299                     ratio = 1.0f - ratio;
1300                 }
1301                 float slidedTrackLength = (float)BgTrackLength() * ratio;
1302                 slidedTrackImage.Size2D = new Size2D((int)(slidedTrackLength + round), (int)curTrackThickness); //Add const round to reach Math.Round function.
1303             }
1304             else if (direction == DirectionType.Vertical)
1305             {
1306                 float slidedTrackLength = (float)BgTrackLength() * ratio;
1307                 slidedTrackImage.Size2D = new Size2D((int)(curTrackThickness + round), (int)slidedTrackLength); //Add const round to reach Math.Round function.
1308             }
1309         }
1310
1311         private uint CurrentTrackThickness()
1312         {
1313             uint curTrackThickness = 0;
1314             if (trackThickness != null)
1315             {
1316                 curTrackThickness = trackThickness.Value;
1317             }
1318             else
1319             {
1320                 if (Style != null && Style.TrackThickness != null)
1321                 {
1322                     curTrackThickness = Style.TrackThickness.Value;
1323                 }
1324             }
1325             return curTrackThickness;
1326         }
1327
1328         private uint CurrentSpaceBetweenTrackAndIndicator()
1329         {
1330             uint curSpace = 0;
1331             if (spaceBetweenTrackAndIndicator != null)
1332             {
1333                 curSpace = spaceBetweenTrackAndIndicator.Start;
1334             }
1335             else
1336             {
1337                 if (Style != null && Style.TrackPadding != null)
1338                 {
1339                     curSpace = Style.TrackPadding.Start;
1340                 }
1341             }
1342             return curSpace;
1343         }
1344
1345         private IndicatorType CurrentIndicatorType()
1346         {
1347             IndicatorType type = IndicatorType.None;
1348             if (Style != null)
1349             {
1350                 type = (IndicatorType)Style.IndicatorType;
1351             }
1352             return type;
1353         }
1354
1355         private Size LowIndicatorImageSize()
1356         {
1357             Size size = new Size(0, 0);
1358             if (lowIndicatorSize != null)
1359             {
1360                 size = lowIndicatorSize;
1361             }
1362             else
1363             {
1364                 if (Style != null && Style.LowIndicatorImage!= null && Style.LowIndicatorImage.Size != null)
1365                 {
1366                     size = Style.LowIndicatorImage.Size;
1367                 }
1368             }
1369             return size;
1370         }
1371
1372         private Size HighIndicatorImageSize()
1373         {
1374             Size size = new Size(0, 0);
1375             if (highIndicatorSize != null)
1376             {
1377                 size = highIndicatorSize;
1378             }
1379             else
1380             {
1381                 if (Style != null && Style.HighIndicatorImage!= null && Style.HighIndicatorImage.Size != null)
1382                 {
1383                     size = Style.HighIndicatorImage.Size;
1384                 }
1385             }
1386             return size;
1387         }
1388
1389         private Size LowIndicatorTextSize()
1390         {
1391             Size size = new Size(0, 0);
1392             if (lowIndicatorSize != null)
1393             {
1394                 size = lowIndicatorSize;
1395             }
1396             else
1397             {
1398                 if (Style != null && Style.LowIndicator!= null && Style.LowIndicator.Size != null)
1399                 {
1400                     size = Style.LowIndicator.Size;
1401                 }
1402             }
1403             return size;
1404         }
1405
1406         private Size HighIndicatorTextSize()
1407         {
1408             Size size = new Size(0, 0);
1409             if (highIndicatorSize != null)
1410             {
1411                 size = highIndicatorSize;
1412             }
1413             else
1414             {
1415                 if (Style != null && Style.HighIndicator!= null && Style.HighIndicator.Size != null)
1416                 {
1417                     size = Style.HighIndicator.Size;
1418                 }
1419             }
1420             return size;
1421         }
1422
1423         private void CalculateCurrentValueByGesture(float offset)
1424         {
1425             currentSlidedOffset += offset;
1426
1427             if (currentSlidedOffset <= 0)
1428             {
1429                 curValue = minValue;
1430             }
1431             else if (currentSlidedOffset >= BgTrackLength())
1432             {
1433                 curValue = maxValue;
1434             }
1435             else
1436             {
1437                 int bgTrackLength = BgTrackLength();
1438                 if (bgTrackLength != 0)
1439                 {
1440                     curValue = ((currentSlidedOffset / (float)bgTrackLength) * (float)(maxValue - minValue)) + minValue;
1441                 }
1442             }
1443             if (valueChangedHandler != null)
1444             {
1445                 ValueChangedArgs args = new ValueChangedArgs();
1446                 args.CurrentValue = curValue.Value;
1447                 valueChangedHandler(this, args);
1448             }
1449         }
1450
1451         private bool OnTouchEventForBgTrack(object source, TouchEventArgs e)
1452         {
1453             PointStateType state = e.Touch.GetState(0);
1454             if (state == PointStateType.Down)
1455             {
1456                 Vector2 pos = e.Touch.GetLocalPosition(0);
1457                 CalculateCurrentValueByTouch(pos);
1458                 UpdateValue();
1459                 if (null != slidingFinishedHandler)
1460                 {
1461                     SlidingFinishedArgs args = new SlidingFinishedArgs();
1462                     args.CurrentValue = curValue.Value;
1463                     slidingFinishedHandler(this, args);
1464                 }
1465             }
1466             return false;
1467         }
1468
1469         private bool OnTouchEventForThumb(object source, TouchEventArgs e)
1470         {
1471             PointStateType state = e.Touch.GetState(0);
1472             if (state == PointStateType.Down)
1473             {
1474                 UpdateState(isFocused, true);
1475             }
1476             else if (state == PointStateType.Up)
1477             {
1478                 UpdateState(isFocused, false);
1479             }
1480             return true;
1481         }
1482
1483         private void CalculateCurrentValueByTouch(Vector2 pos)
1484         {
1485             int bgTrackLength = BgTrackLength();
1486             if (direction == DirectionType.Horizontal)
1487             {
1488                 currentSlidedOffset = pos.X;
1489             }
1490             else if (direction == DirectionType.Vertical)
1491             {
1492                 currentSlidedOffset = bgTrackLength - pos.Y;
1493             }
1494             if (bgTrackLength != 0)
1495             {
1496                 curValue = ((currentSlidedOffset / (float)bgTrackLength) * (maxValue - minValue)) + minValue;
1497                 if (null != valueChangedHandler)
1498                 {
1499                     ValueChangedArgs args = new ValueChangedArgs();
1500                     args.CurrentValue = curValue.Value;
1501                     valueChangedHandler(this, args);
1502                 }
1503             }
1504         }
1505
1506         private void UpdateState(bool isFocusedNew, bool isPressedNew)
1507         {
1508             if (isFocused == isFocusedNew && isPressed == isPressedNew)
1509             {
1510                 return;
1511             }
1512             if (thumbImage == null || Style == null)
1513             {
1514                 return;
1515             }
1516             isFocused = isFocusedNew;
1517             isPressed = isPressedNew;
1518
1519             if (!isFocused && !isPressed)
1520             {
1521                 ControlState = ControlStates.Normal;
1522                 if (stateChangedHandler != null)
1523                 {
1524                     StateChangedArgs args = new StateChangedArgs();
1525                     args.CurrentState = (ControlStates)ControlStates.Normal;
1526                     stateChangedHandler(this, args);
1527                 }
1528             }
1529             else if (isPressed)
1530             {
1531                 ControlState = ControlStates.Pressed;
1532
1533                 if (stateChangedHandler != null)
1534                 {
1535                     StateChangedArgs args = new StateChangedArgs();
1536                     args.CurrentState = (ControlStates)ControlStates.Pressed;
1537                     stateChangedHandler(this, args);
1538                 }
1539             }
1540             else if (!isPressed && isFocused)
1541             {
1542                 ControlState = ControlStates.Focused;
1543
1544                 if (stateChangedHandler != null)
1545                 {
1546                     StateChangedArgs args = new StateChangedArgs();
1547                     args.CurrentState = (ControlStates)ControlStates.Focused;
1548                     stateChangedHandler(this, args);
1549                 }
1550             }
1551         }
1552
1553         private void UpdateComponentByIndicatorTypeChanged()
1554         {
1555             IndicatorType type = CurrentIndicatorType();
1556             if (type == IndicatorType.None)
1557             {
1558                 if (lowIndicatorImage != null)
1559                 {
1560                     lowIndicatorImage.Hide();
1561                 }
1562                 if (highIndicatorImage != null)
1563                 {
1564                     highIndicatorImage.Hide();
1565                 }
1566                 if (lowIndicatorText != null)
1567                 {
1568                     lowIndicatorText.Hide();
1569                 }
1570                 if (highIndicatorText != null)
1571                 {
1572                     highIndicatorText.Hide();
1573                 }
1574             }
1575             else if (type == IndicatorType.Image)
1576             {
1577                 if (lowIndicatorImage != null)
1578                 {
1579                     lowIndicatorImage.Show();
1580                 }
1581                 if (highIndicatorImage != null)
1582                 {
1583                     highIndicatorImage.Show();
1584                 }
1585                 if (lowIndicatorText != null)
1586                 {
1587                     lowIndicatorText.Hide();
1588                 }
1589                 if (highIndicatorText != null)
1590                 {
1591                     highIndicatorText.Hide();
1592                 }
1593             }
1594             else if (type == IndicatorType.Text)
1595             {
1596                 if (lowIndicatorText != null)
1597                 {
1598                     lowIndicatorText.Show();
1599                 }
1600                 if (highIndicatorText != null)
1601                 {
1602                     highIndicatorText.Show();
1603                 }
1604                 if (lowIndicatorImage != null)
1605                 {
1606                     lowIndicatorImage.Hide();
1607                 }
1608                 if (highIndicatorImage != null)
1609                 {
1610                     highIndicatorImage.Hide();
1611                 }
1612             }
1613         }
1614
1615         /// <summary>
1616         /// Value Changed event data.
1617         /// </summary>
1618         /// <since_tizen> 6 </since_tizen>
1619         public class ValueChangedArgs : EventArgs
1620         {
1621             /// <summary>
1622             /// Curren value
1623             /// </summary>
1624             /// <since_tizen> 6 </since_tizen>
1625             public float CurrentValue;
1626         }
1627
1628         /// <summary>
1629         /// Value Changed event data.
1630         /// </summary>
1631         /// <since_tizen> 6 </since_tizen>
1632         public class SlidingFinishedArgs : EventArgs
1633         {
1634             /// <summary>
1635             /// Curren value
1636             /// </summary>
1637             /// <since_tizen> 6 </since_tizen>
1638             public float CurrentValue;
1639         }
1640
1641         /// <summary>
1642         /// State Changed event data.
1643         /// </summary>
1644         /// <since_tizen> 6 </since_tizen>
1645         public class StateChangedArgs : EventArgs
1646         {
1647             /// <summary>
1648             /// Curent state
1649             /// </summary>
1650             /// <since_tizen> 6 </since_tizen>
1651             public ControlStates CurrentState;
1652         }
1653     }
1654 }