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