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