2 * Copyright(c) 2020 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 using System.ComponentModel;
18 using Tizen.NUI.BaseComponents;
19 using Tizen.NUI.Binding;
20 using Tizen.NUI.Components;
22 namespace Tizen.NUI.Wearable
25 /// CircularSliderStyle is a class which saves CircularSlider's ux data.
27 [EditorBrowsable(EditorBrowsableState.Never)]
28 public class CircularSliderStyle : ControlStyle
30 /// <summary>Bindable property of Thickness</summary>
31 [EditorBrowsable(EditorBrowsableState.Never)]
32 public static readonly BindableProperty ThicknessProperty = BindableProperty.Create(nameof(Thickness), typeof(float?), typeof(CircularSliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
34 ((CircularSliderStyle)bindable).thickness = (float?)newValue;
36 defaultValueCreator: (bindable) =>
38 return ((CircularSliderStyle)bindable).thickness;
41 /// <summary>Bindable property of MaxValue</summary>
42 [EditorBrowsable(EditorBrowsableState.Never)]
43 public static readonly BindableProperty MaxValueProperty = BindableProperty.Create(nameof(MaxValue), typeof(float), typeof(CircularSliderStyle), default(float), propertyChanged: (bindable, oldValue, newValue) =>
45 ((CircularSliderStyle)bindable).maxValue = (float)newValue;
47 defaultValueCreator: (bindable) =>
49 return ((CircularSliderStyle)bindable).maxValue;
52 /// <summary>Bindable property of MinValue</summary>
53 [EditorBrowsable(EditorBrowsableState.Never)]
54 public static readonly BindableProperty MinValueProperty = BindableProperty.Create(nameof(MinValue), typeof(float), typeof(CircularSliderStyle), default(float), propertyChanged: (bindable, oldValue, newValue) =>
56 ((CircularSliderStyle)bindable).minValue = (float)newValue;
58 defaultValueCreator: (bindable) =>
60 return ((CircularSliderStyle)bindable).minValue;
63 /// <summary>Bindable property of CurrentValue</summary>
64 [EditorBrowsable(EditorBrowsableState.Never)]
65 public static readonly BindableProperty CurrentValueProperty = BindableProperty.Create(nameof(CurrentValue), typeof(float), typeof(CircularSliderStyle), default(float), propertyChanged: (bindable, oldValue, newValue) =>
67 ((CircularSliderStyle)bindable).currentValue = (float)newValue;
69 defaultValueCreator: (bindable) =>
71 return ((CircularSliderStyle)bindable).currentValue;
74 /// <summary>Bindable property of TrackColor</summary>
75 [EditorBrowsable(EditorBrowsableState.Never)]
76 public static readonly BindableProperty TrackColorProperty = BindableProperty.Create(nameof(TrackColor), typeof(Color), typeof(CircularSliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
78 ((CircularSliderStyle)bindable).trackColor = newValue == null ? null : new Color((Color)newValue);
80 defaultValueCreator: (bindable) =>
82 return ((CircularSliderStyle)bindable).trackColor;
85 /// <summary>Bindable property of ProgressColor</summary>
86 [EditorBrowsable(EditorBrowsableState.Never)]
87 public static readonly BindableProperty ProgressColorProperty = BindableProperty.Create(nameof(ProgressColor), typeof(Color), typeof(CircularSliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
89 ((CircularSliderStyle)bindable).progressColor = newValue == null ? null : new Color((Color)newValue);
91 defaultValueCreator: (bindable) =>
93 return ((CircularSliderStyle)bindable).progressColor;
96 /// <summary>Bindable property of ThumbSize</summary>
97 [EditorBrowsable(EditorBrowsableState.Never)]
98 public static readonly BindableProperty ThumbSizeProperty = BindableProperty.Create(nameof(ThumbSize), typeof(Size), typeof(CircularSliderStyle), new Size(0,0), propertyChanged: (bindable, oldValue, newValue) =>
100 ((CircularSliderStyle)bindable).thumbSize = (Size)newValue;
102 defaultValueCreator: (bindable) =>
104 return ((CircularSliderStyle)bindable).thumbSize;
107 /// <summary>Bindable property of ThumbColor</summary>
108 [EditorBrowsable(EditorBrowsableState.Never)]
109 public static readonly BindableProperty ThumbColorProperty = BindableProperty.Create(nameof(ThumbColor), typeof(Color), typeof(CircularSliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
111 ((CircularSliderStyle)bindable).thumbColor = newValue == null ? null : new Color((Color)newValue);
113 defaultValueCreator: (bindable) =>
115 return ((CircularSliderStyle)bindable).thumbColor;
118 /// <summary>Bindable property of IsEnabled</summary>
119 [EditorBrowsable(EditorBrowsableState.Never)]
120 public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool?), typeof(CircularSliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
122 ((CircularSliderStyle)bindable).isEnabled = (bool?)newValue;
124 defaultValueCreator: (bindable) =>
126 return ((CircularSliderStyle)bindable).isEnabled;
129 private float? thickness;
130 private float maxValue;
131 private float minValue;
132 private float currentValue;
133 private Color trackColor;
134 private Color progressColor;
135 private Color thumbColor;
136 private Size thumbSize;
137 private bool? isEnabled;
139 static CircularSliderStyle() { }
142 /// Creates a new instance of a CircularSliderStyle.
144 [EditorBrowsable(EditorBrowsableState.Never)]
145 public CircularSliderStyle() : base()
151 /// Creates a new instance of a CircularSliderStyle with style.
153 /// <param name="style">Create CircularSliderStyle by style customized by user.</param>
154 [EditorBrowsable(EditorBrowsableState.Never)]
155 public CircularSliderStyle(CircularSliderStyle style) : base(style)
160 /// The thickness of the track and progress.
162 [EditorBrowsable(EditorBrowsableState.Never)]
163 public float? Thickness
167 return (float?)GetValue(ThicknessProperty);
171 SetValue(ThicknessProperty, value);
176 /// The property to get/set the maximum value of the CircularSlider.
178 [EditorBrowsable(EditorBrowsableState.Never)]
179 public float MaxValue
183 return (float)GetValue(MaxValueProperty);
187 SetValue(MaxValueProperty, value);
192 /// The property to get/set the minim value of the CircularSlider.
194 [EditorBrowsable(EditorBrowsableState.Never)]
195 public float MinValue
199 return (float)GetValue(MinValueProperty);
203 SetValue(MinValueProperty, value);
208 /// The property to get/set the current value of the CircularSlider.
210 [EditorBrowsable(EditorBrowsableState.Never)]
211 public float CurrentValue
215 return (float)GetValue(CurrentValueProperty);
219 SetValue(CurrentValueProperty, value);
224 /// The property to get/set Track object color of the CircularSlider.
226 [EditorBrowsable(EditorBrowsableState.Never)]
227 public Color TrackColor
231 return (Color)GetValue(TrackColorProperty);
235 SetValue(TrackColorProperty, value);
240 /// The property to get/set Progress object color of the CircularSlider.
242 [EditorBrowsable(EditorBrowsableState.Never)]
243 public Color ProgressColor
247 return (Color)GetValue(ProgressColorProperty);
251 SetValue(ProgressColorProperty, value);
256 /// Gets or sets the size of the thumb of Slider.
258 [EditorBrowsable(EditorBrowsableState.Never)]
259 public Size ThumbSize
263 return (Size)GetValue(ThumbSizeProperty);
267 SetValue(ThumbSizeProperty, value);
272 /// The property to get/set Thumb object color of the CircularSlider.
274 [EditorBrowsable(EditorBrowsableState.Never)]
275 public Color ThumbColor
279 return (Color)GetValue(ThumbColorProperty);
283 SetValue(ThumbColorProperty, value);
288 /// Flag to be enabled or disabled in CircularSlider.
290 /// <since_tizen> 8 </since_tizen>
291 public bool? IsEnabled
295 return (bool?)GetValue(IsEnabledProperty);
299 SetValue(IsEnabledProperty, value);
303 private void Initialize()
310 trackColor = new Color(0.0f, 0.16f, 0.30f, 1.0f); // #002A4D
311 progressColor = new Color(0.0f, 0.55f, 1.0f, 1.0f); // #008CFF
312 thumbSize = new Size(19, 19);
313 thumbColor = new Color(0.0f, 0.55f, 1.0f, 1.0f); // #008CFF