2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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.
22 /// The ProgressBar is a widget for visually representing the progress status of a given job or task.
24 /// <since_tizen> preview </since_tizen>
25 public class ProgressBar : Layout
30 /// Creates and initializes a new instance of the ProgressBar class.
32 /// <param name="parent">The EvasObject to which the new ProgressBar will be attached as a child.</param>
33 /// <since_tizen> preview </since_tizen>
34 public ProgressBar(EvasObject parent) : base(parent)
36 _changed = new SmartEvent(this, this.RealHandle, "changed");
37 _changed.On += (s, e) =>
39 ValueChanged?.Invoke(this, EventArgs.Empty);
44 /// ValueChanged will be triggered when the value of the ProgressBar changes.
46 /// <since_tizen> preview </since_tizen>
47 public event EventHandler ValueChanged;
50 /// Sets or gets the value whether a given ProgressBar widget is at the "pulsing mode".
53 /// By default, progress bars display values from low to high value boundaries.
54 /// There are, though, contexts in which the progress of a given task is unknown.
55 /// For such cases, one can set the progress bar widget to a "pulsing state",
56 /// to give the user an idea that some computation is being held,
57 /// but without the exact progress values. In the default theme,
58 /// it animates its bar with the contents filling in constantly and back to non-filled, in a loop.
60 /// <since_tizen> preview </since_tizen>
61 public bool IsPulseMode
65 return Interop.Elementary.elm_progressbar_pulse_get(RealHandle);
69 Interop.Elementary.elm_progressbar_pulse_set(RealHandle, value);
74 /// Sets or gets the value of the ProgressBar.
77 /// Use this property to set the progress bar levels.
78 /// If you pass a value out of the specified range (0.0~1.0),
79 /// it is interpreted as the closest of the boundary values in the range.
81 /// <since_tizen> preview </since_tizen>
86 return Interop.Elementary.elm_progressbar_value_get(RealHandle);
90 Interop.Elementary.elm_progressbar_value_set(RealHandle, value);
95 /// Sets or gets the span value of the ProgressBar.
97 /// <since_tizen> preview </since_tizen>
102 return Interop.Elementary.elm_progressbar_span_size_get(RealHandle);
106 Interop.Elementary.elm_progressbar_span_size_set(RealHandle, value);
111 /// Sets or gets the value whether a given ProgressBar widget is horizontal.
113 /// <since_tizen> preview </since_tizen>
114 public bool IsHorizontal
118 return Interop.Elementary.elm_progressbar_horizontal_get(RealHandle);
122 Interop.Elementary.elm_progressbar_horizontal_set(RealHandle, value);
127 /// Sets or gets the value whether a given progress bar widget's displaying values are inverted.
129 /// <since_tizen> preview </since_tizen>
130 public bool IsInverted
134 return Interop.Elementary.elm_progressbar_inverted_get(RealHandle);
138 Interop.Elementary.elm_progressbar_inverted_set(RealHandle, value);
143 /// Sets or gets the format string for a given progress bar widget's units label.
146 /// If null is passed on format, it makes the object units area to be hidden completely.
147 /// If not, it sets the format string for the units label's text.
148 /// The units label are provided with a floating point value, so the units text displays at the most one floating point value.
149 /// Note that the units label is optional. Use a format string such as "%1.2f meters" for example.
151 /// <since_tizen> preview </since_tizen>
152 public string UnitFormat
156 return Interop.Elementary.elm_progressbar_unit_format_get(RealHandle);
160 Interop.Elementary.elm_progressbar_unit_format_set(RealHandle, value);
165 /// Starts a given progress bar "pulsing" animation, if its under that mode.
167 /// <since_tizen> preview </since_tizen>
168 public void PlayPulse()
170 Interop.Elementary.elm_progressbar_pulse(RealHandle, true);
174 /// Stops a given progress bar "pulsing" animation, if its under that mode.
176 /// <since_tizen> preview </since_tizen>
177 [Obsolete("use StopPulse instead")]
178 public void StopPluse()
180 Interop.Elementary.elm_progressbar_pulse(RealHandle, false);
184 /// Stops a given progress bar "pulsing" animation, if its under that mode.
186 /// <since_tizen> preview </since_tizen>
187 public void StopPulse()
189 Interop.Elementary.elm_progressbar_pulse(RealHandle, false);
193 /// Gets the part value of a given part of the Progressbar.
195 /// <param name="part">Part of the Progressbar.</param>
196 /// <returns>Value range is from 0.0 to 1.0.</returns>
197 /// <since_tizen> preview </since_tizen>
198 public double GetPartValue(string part)
200 return Interop.Elementary.elm_progressbar_part_value_get(RealHandle, part);
204 /// Sets or gets the general or main color of the given Progressbar.
206 /// <since_tizen> preview </since_tizen>
207 public override Color Color
211 return GetPartColor("bar");
215 SetPartColor("bar", value);
220 /// Sets the part value of a given part of the Progressbar.
222 /// <param name="part">Part of the Progressbar.</param>
223 /// <param name="value">Value range is from 0.0 to 1.0.</param>
224 /// <since_tizen> preview </since_tizen>
225 public void SetPartValue(string part, double value)
227 Interop.Elementary.elm_progressbar_part_value_set(RealHandle, part, value);
231 /// Creates a widget handle.
233 /// <param name="parent">Parent EvasObject.</param>
234 /// <returns>Handle IntPtr.</returns>
235 /// <since_tizen> preview </since_tizen>
236 protected override IntPtr CreateHandle(EvasObject parent)
238 IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
239 Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
241 RealHandle = Interop.Elementary.elm_progressbar_add(handle);
242 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);