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 /// CircularProgressStyle is a class which saves CircularProgress's ux data.
27 [EditorBrowsable(EditorBrowsableState.Never)]
28 public class CircularProgressStyle : 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(CircularProgressStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
34 ((CircularProgressStyle)bindable).thickness = (float?)newValue;
36 defaultValueCreator: (bindable) =>
38 return ((CircularProgressStyle)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(CircularProgressStyle), default(float), propertyChanged: (bindable, oldValue, newValue) =>
45 ((CircularProgressStyle)bindable).maxValue = (float)newValue;
47 defaultValueCreator: (bindable) =>
49 return ((CircularProgressStyle)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(CircularProgressStyle), default(float), propertyChanged: (bindable, oldValue, newValue) =>
56 ((CircularProgressStyle)bindable).minValue = (float)newValue;
58 defaultValueCreator: (bindable) =>
60 return ((CircularProgressStyle)bindable).minValue;
63 /// <summary>Bindable property of CurrentValue</summary>
64 [EditorBrowsable(EditorBrowsableState.Never)]
65 public static readonly BindableProperty CurrentValueProperty = BindableProperty.Create("currentValue", typeof(float), typeof(CircularProgressStyle), default(float), propertyChanged: (bindable, oldValue, newValue) =>
67 ((CircularProgressStyle)bindable).currentValue = (float)newValue;
69 defaultValueCreator: (bindable) =>
71 return ((CircularProgressStyle)bindable).currentValue;
74 /// <summary>Bindable property of TrackColor</summary>
75 [EditorBrowsable(EditorBrowsableState.Never)]
76 public static readonly BindableProperty TrackColorProperty = BindableProperty.Create("trackColor", typeof(Color), typeof(CircularProgressStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
78 ((CircularProgressStyle)bindable).trackColor = (Color)newValue;
80 defaultValueCreator: (bindable) =>
82 return ((CircularProgressStyle)bindable).trackColor;
85 /// <summary>Bindable property of ProgressColor</summary>
86 [EditorBrowsable(EditorBrowsableState.Never)]
87 public static readonly BindableProperty ProgressColorProperty = BindableProperty.Create("progressColor", typeof(Color), typeof(CircularProgressStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
89 ((CircularProgressStyle)bindable).progressColor = (Color)newValue;
91 defaultValueCreator: (bindable) =>
93 return ((CircularProgressStyle)bindable).progressColor;
96 /// <summary>Bindable property of IsEnabled</summary>
97 [EditorBrowsable(EditorBrowsableState.Never)]
98 public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool?), typeof(CircularProgressStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
100 ((CircularProgressStyle)bindable).isEnabled = (bool?)newValue;
102 defaultValueCreator: (bindable) =>
104 return ((CircularProgressStyle)bindable).isEnabled;
107 private float? thickness;
108 private float maxValue;
109 private float minValue;
110 private float currentValue;
111 private Color trackColor;
112 private Color progressColor;
113 private bool? isEnabled;
115 static CircularProgressStyle() { }
118 /// Creates a new instance of a CircularProgressStyle.
120 [EditorBrowsable(EditorBrowsableState.Never)]
121 public CircularProgressStyle() : base()
127 /// Creates a new instance of a CircularProgressStyle with style.
129 /// <param name="style">Create CircularProgressStyle by style customized by user.</param>
130 [EditorBrowsable(EditorBrowsableState.Never)]
131 public CircularProgressStyle(CircularProgressStyle style) : base(style)
133 if (null == style) return;
134 this.CopyFrom(style);
138 /// The thickness of the track and progress.
140 [EditorBrowsable(EditorBrowsableState.Never)]
141 public float? Thickness
145 return (float?)GetValue(ThicknessProperty);
149 SetValue(ThicknessProperty, value);
154 /// The property to get/set the maximum value of the CircularProgress.
156 [EditorBrowsable(EditorBrowsableState.Never)]
157 public float MaxValue
161 return (float)GetValue(MaxValueProperty);
165 SetValue(MaxValueProperty, value);
170 /// The property to get/set the minim value of the CircularProgress.
172 [EditorBrowsable(EditorBrowsableState.Never)]
173 public float MinValue
177 return (float)GetValue(MinValueProperty);
181 SetValue(MinValueProperty, value);
186 /// The property to get/set the current value of the CircularProgress.
188 [EditorBrowsable(EditorBrowsableState.Never)]
189 public float CurrentValue
193 return (float)GetValue(CurrentValueProperty);
197 SetValue(CurrentValueProperty, value);
202 /// The property to get/set Track object color of the CircularProgress.
204 [EditorBrowsable(EditorBrowsableState.Never)]
205 public Color TrackColor
209 return (Color)GetValue(TrackColorProperty);
213 SetValue(TrackColorProperty, value);
218 /// The property to get/set Progress object color of the CircularProgress.
220 [EditorBrowsable(EditorBrowsableState.Never)]
221 public Color ProgressColor
225 return (Color)GetValue(ProgressColorProperty);
229 SetValue(ProgressColorProperty, value);
234 /// Flag to be enabled or disabled in CircularProgress.
236 /// <since_tizen> 8 </since_tizen>
237 public bool? IsEnabled
241 return (bool?)GetValue(IsEnabledProperty);
245 SetValue(IsEnabledProperty, value);
250 /// Style's clone function.
252 /// <param name="bindableObject">The style that need to copy.</param>
253 [EditorBrowsable(EditorBrowsableState.Never)]
254 public override void CopyFrom(BindableObject bindableObject)
256 base.CopyFrom(bindableObject);
258 CircularProgressStyle progressStyle = bindableObject as CircularProgressStyle;
260 if (null != progressStyle)
262 isEnabled = progressStyle.isEnabled;
263 thickness = progressStyle.Thickness;
264 maxValue = progressStyle.maxValue;
265 minValue = progressStyle.minValue;
266 currentValue = progressStyle.currentValue;
267 trackColor = progressStyle.trackColor;
268 progressColor = progressStyle.progressColor;
272 private void Initialize()
279 trackColor = new Color(0.0f, 0.16f, 0.30f, 1.0f);
280 progressColor = new Color(0.0f, 0.55f, 1.0f, 1.0f);