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