2 * Copyright(c) 2018 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.
18 using System.ComponentModel;
19 using System.Runtime.InteropServices;
20 using Tizen.NUI.BaseComponents;
21 using Tizen.NUI.Binding;
23 namespace Tizen.NUI.UIComponents
26 /// The ProgressBar is a control to give the user an indication of the progress of an operation.
28 /// <since_tizen> 3 </since_tizen>
29 public class ProgressBar : View
31 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
32 [EditorBrowsable(EditorBrowsableState.Never)]
33 public static readonly BindableProperty ProgressValueProperty = BindableProperty.Create("ProgressValue", typeof(float), typeof(ProgressBar), default(float), propertyChanged: (bindable, oldValue, newValue) =>
35 var progressBar = (ProgressBar)bindable;
38 Tizen.NUI.Object.SetProperty(progressBar.swigCPtr, ProgressBar.Property.PROGRESS_VALUE, new Tizen.NUI.PropertyValue((float)newValue));
41 defaultValueCreator: (bindable) =>
43 var progressBar = (ProgressBar)bindable;
45 Tizen.NUI.Object.GetProperty(progressBar.swigCPtr, ProgressBar.Property.PROGRESS_VALUE).Get(out temp);
48 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
49 [EditorBrowsable(EditorBrowsableState.Never)]
50 public static readonly BindableProperty SecondaryProgressValueProperty = BindableProperty.Create("SecondaryProgressValue", typeof(float), typeof(ProgressBar), default(float), propertyChanged: (bindable, oldValue, newValue) =>
52 var progressBar = (ProgressBar)bindable;
55 Tizen.NUI.Object.SetProperty(progressBar.swigCPtr, ProgressBar.Property.SECONDARY_PROGRESS_VALUE, new Tizen.NUI.PropertyValue((float)newValue));
58 defaultValueCreator: (bindable) =>
60 var progressBar = (ProgressBar)bindable;
62 Tizen.NUI.Object.GetProperty(progressBar.swigCPtr, ProgressBar.Property.SECONDARY_PROGRESS_VALUE).Get(out temp);
65 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
66 [EditorBrowsable(EditorBrowsableState.Never)]
67 public static readonly BindableProperty IndeterminateProperty = BindableProperty.Create("Indeterminate", typeof(bool), typeof(ProgressBar), false, propertyChanged: (bindable, oldValue, newValue) =>
69 var progressBar = (ProgressBar)bindable;
72 Tizen.NUI.Object.SetProperty(progressBar.swigCPtr, ProgressBar.Property.INDETERMINATE, new Tizen.NUI.PropertyValue((bool)newValue));
75 defaultValueCreator: (bindable) =>
77 var progressBar = (ProgressBar)bindable;
79 Tizen.NUI.Object.GetProperty(progressBar.swigCPtr, ProgressBar.Property.INDETERMINATE).Get(out temp);
82 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
83 [EditorBrowsable(EditorBrowsableState.Never)]
84 public static readonly BindableProperty TrackVisualProperty = BindableProperty.Create("TrackVisual", typeof(PropertyMap), typeof(ProgressBar), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
86 var progressBar = (ProgressBar)bindable;
89 Tizen.NUI.Object.SetProperty(progressBar.swigCPtr, ProgressBar.Property.TRACK_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
92 defaultValueCreator: (bindable) =>
94 var progressBar = (ProgressBar)bindable;
95 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
96 Tizen.NUI.Object.GetProperty(progressBar.swigCPtr, ProgressBar.Property.TRACK_VISUAL).Get(temp);
99 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
100 [EditorBrowsable(EditorBrowsableState.Never)]
101 public static readonly BindableProperty ProgressVisualProperty = BindableProperty.Create("ProgressVisual", typeof(PropertyMap), typeof(ProgressBar), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
103 var progressBar = (ProgressBar)bindable;
104 if (newValue != null)
106 Tizen.NUI.Object.SetProperty(progressBar.swigCPtr, ProgressBar.Property.PROGRESS_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
109 defaultValueCreator: (bindable) =>
111 var progressBar = (ProgressBar)bindable;
112 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
113 Tizen.NUI.Object.GetProperty(progressBar.swigCPtr, ProgressBar.Property.PROGRESS_VISUAL).Get(temp);
116 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
117 [EditorBrowsable(EditorBrowsableState.Never)]
118 public static readonly BindableProperty SecondaryProgressVisualProperty = BindableProperty.Create("SecondaryProgressVisual", typeof(PropertyMap), typeof(ProgressBar), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
120 var progressBar = (ProgressBar)bindable;
121 if (newValue != null)
123 Tizen.NUI.Object.SetProperty(progressBar.swigCPtr, ProgressBar.Property.SECONDARY_PROGRESS_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
126 defaultValueCreator: (bindable) =>
128 var progressBar = (ProgressBar)bindable;
129 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
130 Tizen.NUI.Object.GetProperty(progressBar.swigCPtr, ProgressBar.Property.SECONDARY_PROGRESS_VISUAL).Get(temp);
133 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
134 [EditorBrowsable(EditorBrowsableState.Never)]
135 public static readonly BindableProperty IndeterminateVisualProperty = BindableProperty.Create("IndeterminateVisual", typeof(PropertyMap), typeof(ProgressBar), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
137 var progressBar = (ProgressBar)bindable;
138 if (newValue != null)
140 Tizen.NUI.Object.SetProperty(progressBar.swigCPtr, ProgressBar.Property.INDETERMINATE_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
143 defaultValueCreator: (bindable) =>
145 var progressBar = (ProgressBar)bindable;
146 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
147 Tizen.NUI.Object.GetProperty(progressBar.swigCPtr, ProgressBar.Property.INDETERMINATE_VISUAL).Get(temp);
150 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
151 [EditorBrowsable(EditorBrowsableState.Never)]
152 public static readonly BindableProperty IndeterminateVisualAnimationProperty = BindableProperty.Create("IndeterminateVisualAnimation", typeof(PropertyArray), typeof(ProgressBar), new PropertyArray(), propertyChanged: (bindable, oldValue, newValue) =>
154 var progressBar = (ProgressBar)bindable;
155 if (newValue != null)
157 Tizen.NUI.Object.SetProperty(progressBar.swigCPtr, ProgressBar.Property.INDETERMINATE_VISUAL_ANIMATION, new Tizen.NUI.PropertyValue((PropertyArray)newValue));
160 defaultValueCreator: (bindable) =>
162 var progressBar = (ProgressBar)bindable;
163 Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
164 Tizen.NUI.Object.GetProperty(progressBar.swigCPtr, ProgressBar.Property.INDETERMINATE_VISUAL_ANIMATION).Get(temp);
167 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
168 [EditorBrowsable(EditorBrowsableState.Never)]
169 public static readonly BindableProperty LabelVisualProperty = BindableProperty.Create("LabelVisual", typeof(PropertyMap), typeof(ProgressBar), new PropertyMap(), propertyChanged: (bindable, oldValue, newValue) =>
171 var progressBar = (ProgressBar)bindable;
172 if (newValue != null)
174 Tizen.NUI.Object.SetProperty(progressBar.swigCPtr, ProgressBar.Property.LABEL_VISUAL, new Tizen.NUI.PropertyValue((PropertyMap)newValue));
177 defaultValueCreator: (bindable) =>
179 var progressBar = (ProgressBar)bindable;
180 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
181 Tizen.NUI.Object.GetProperty(progressBar.swigCPtr, ProgressBar.Property.LABEL_VISUAL).Get(temp);
185 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
186 private EventHandler<ValueChangedEventArgs> _progressBarValueChangedEventHandler;
187 private ValueChangedCallbackDelegate _progressBarValueChangedCallbackDelegate;
190 /// Creates the ProgressBar.
192 /// <since_tizen> 3 </since_tizen>
193 public ProgressBar() : this(Interop.ProgressBar.ProgressBar_New(), true)
195 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
199 internal ProgressBar(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.ProgressBar.ProgressBar_SWIGUpcast(cPtr), cMemoryOwn)
201 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
204 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
205 private delegate void ValueChangedCallbackDelegate(IntPtr progressBar, float progressValue, float secondaryProgressValue);
208 /// The event is sent when the ProgressBar value changes.
210 /// <since_tizen> 3 </since_tizen>
211 public event EventHandler<ValueChangedEventArgs> ValueChanged
215 if (_progressBarValueChangedEventHandler == null)
217 _progressBarValueChangedCallbackDelegate = (OnValueChanged);
218 ValueChangedSignal().Connect(_progressBarValueChangedCallbackDelegate);
220 _progressBarValueChangedEventHandler += value;
224 _progressBarValueChangedEventHandler -= value;
225 if (_progressBarValueChangedEventHandler == null && ValueChangedSignal().Empty() == false)
227 ValueChangedSignal().Disconnect(_progressBarValueChangedCallbackDelegate);
233 /// The progress value of the progress bar, the progress runs from 0 to 1.<br />
234 /// If the value is set to 0, then the progress bar will be set to beginning.<br />
235 /// If the value is set to 1, then the progress bar will be set to end.<br />
236 /// Any value outside the range is ignored.<br />
238 /// <since_tizen> 3 </since_tizen>
239 public float ProgressValue
243 return (float)GetValue(ProgressValueProperty);
247 SetValue(ProgressValueProperty, value);
252 /// The secondary progress value of the progress bar, the secondary progress runs from 0 to 1.<br />
253 /// Optional. If not supplied, the default is 0.<br />
254 /// If the value is set to 0, then the progress bar will be set secondary progress to beginning.<br />
255 /// If the value is set to 1, then the progress bar will be set secondary progress to end.<br />
256 /// Any value outside of the range is ignored.<br />
258 /// <since_tizen> 3 </since_tizen>
259 public float SecondaryProgressValue
263 return (float)GetValue(SecondaryProgressValueProperty);
267 SetValue(SecondaryProgressValueProperty, value);
272 /// Sets the progress bar as \e indeterminate state.
274 /// <since_tizen> 3 </since_tizen>
275 public bool Indeterminate
279 return (bool)GetValue(IndeterminateProperty);
283 SetValue(IndeterminateProperty, value);
288 /// The track visual value of progress bar, it's full progress area, and it's shown behind the PROGRESS_VISUAL.<br />
289 /// Optional. If not supplied, the default track visual will be shown.<br />
291 /// <since_tizen> 3 </since_tizen>
292 public Tizen.NUI.PropertyMap TrackVisual
296 return (PropertyMap)GetValue(TrackVisualProperty);
300 SetValue(TrackVisualProperty, value);
305 /// The progress visual value of the progress bar, the size of the progress visual is changed based on the PROGRESS_VALUE.<br />
306 /// Optional. If not supplied, then the default progress visual will be shown.<br />
308 /// <since_tizen> 3 </since_tizen>
309 public Tizen.NUI.PropertyMap ProgressVisual
313 return (PropertyMap)GetValue(ProgressVisualProperty);
317 SetValue(ProgressVisualProperty, value);
322 /// The secondary progress visual of the progress bar, the size of the secondary progress visual is changed based on the SECONDARY_PROGRESS_VALUE.<br />
323 /// Optional. If not supplied, then the secondary progress visual will not be shown.<br />
325 /// <since_tizen> 3 </since_tizen>
326 public Tizen.NUI.PropertyMap SecondaryProgressVisual
330 return (PropertyMap)GetValue(SecondaryProgressVisualProperty);
334 SetValue(SecondaryProgressVisualProperty, value);
339 /// The indeterminate visual of the progress bar.<br />
340 /// Optional. If not supplied, then the default indeterminate visual will be shown.<br />
342 /// <since_tizen> 3 </since_tizen>
343 public Tizen.NUI.PropertyMap IndeterminateVisual
347 return (PropertyMap)GetValue(IndeterminateVisualProperty);
351 SetValue(IndeterminateVisualProperty, value);
356 /// The transition data for the indeterminate visual animation.<br />
357 /// Optional. If not supplied, then the default animation will be played.<br />
359 /// <since_tizen> 3 </since_tizen>
360 public Tizen.NUI.PropertyArray IndeterminateVisualAnimation
364 return (PropertyArray)GetValue(IndeterminateVisualAnimationProperty);
368 SetValue(IndeterminateVisualAnimationProperty, value);
373 /// The label visual of the progress bar.
375 /// <since_tizen> 3 </since_tizen>
376 public Tizen.NUI.PropertyMap LabelVisual
380 return (PropertyMap)GetValue(LabelVisualProperty);
384 SetValue(LabelVisualProperty, value);
388 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ProgressBar obj)
390 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
393 internal ProgressBarValueChangedSignal ValueChangedSignal()
395 ProgressBarValueChangedSignal ret = new ProgressBarValueChangedSignal(Interop.ProgressBar.ProgressBar_ValueChangedSignal(swigCPtr), false);
396 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
401 /// To dispose the ProgressBar instance.
403 /// <since_tizen> 3 </since_tizen>
404 protected override void Dispose(DisposeTypes type)
411 //Release your own unmanaged resources here.
412 //You should not access any managed member here except static instance.
413 //because the execution order of Finalizes is non-deterministic.
415 if (this != null && _progressBarValueChangedCallbackDelegate != null)
417 ValueChangedSignal().Disconnect(_progressBarValueChangedCallbackDelegate);
420 if (swigCPtr.Handle != global::System.IntPtr.Zero)
425 Interop.ProgressBar.delete_ProgressBar(swigCPtr);
427 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
433 // Callback for ProgressBar ValueChanged signal
434 private void OnValueChanged(IntPtr progressBar, float progressValue, float secondaryProgressValue)
436 ValueChangedEventArgs e = new ValueChangedEventArgs();
438 // Populate all members of "e" (ValueChangedEventArgs) with real page
439 e.ProgressBar = Registry.GetManagedBaseHandleFromNativePtr(progressBar) as ProgressBar;
440 e.ProgressValue = progressValue;
441 e.SecondaryProgressValue = secondaryProgressValue;
443 if (_progressBarValueChangedEventHandler != null)
445 _progressBarValueChangedEventHandler(this, e);
450 /// Event arguments that passed via the ValueChangedEventArgs.
452 /// <since_tizen> 3 </since_tizen>
453 public class ValueChangedEventArgs : EventArgs
455 private ProgressBar _progressBar;
456 private float _progressValue;
457 private float _secondaryProgressValue;
462 /// <since_tizen> 3 </since_tizen>
463 public ProgressBar ProgressBar
471 _progressBar = value;
476 /// The progress value of the progress bar, the progress runs from 0 to 1.
478 /// <since_tizen> 3 </since_tizen>
479 public float ProgressValue
483 return _progressValue;
487 _progressValue = value;
492 /// The secondary progress value of the progress bar, the secondary progress runs from 0 to 1.
494 /// <since_tizen> 3 </since_tizen>
495 public float SecondaryProgressValue
499 return _secondaryProgressValue;
503 _secondaryProgressValue = value;
509 internal new class Property
511 internal static readonly int PROGRESS_VALUE = Interop.ProgressBar.ProgressBar_Property_PROGRESS_VALUE_get();
512 internal static readonly int SECONDARY_PROGRESS_VALUE = Interop.ProgressBar.ProgressBar_Property_SECONDARY_PROGRESS_VALUE_get();
513 internal static readonly int INDETERMINATE = Interop.ProgressBar.ProgressBar_Property_INDETERMINATE_get();
514 internal static readonly int TRACK_VISUAL = Interop.ProgressBar.ProgressBar_Property_TRACK_VISUAL_get();
515 internal static readonly int PROGRESS_VISUAL = Interop.ProgressBar.ProgressBar_Property_PROGRESS_VISUAL_get();
516 internal static readonly int SECONDARY_PROGRESS_VISUAL = Interop.ProgressBar.ProgressBar_Property_SECONDARY_PROGRESS_VISUAL_get();
517 internal static readonly int INDETERMINATE_VISUAL = Interop.ProgressBar.ProgressBar_Property_INDETERMINATE_VISUAL_get();
518 internal static readonly int INDETERMINATE_VISUAL_ANIMATION = Interop.ProgressBar.ProgressBar_Property_INDETERMINATE_VISUAL_ANIMATION_get();
519 internal static readonly int LABEL_VISUAL = Interop.ProgressBar.ProgressBar_Property_LABEL_VISUAL_get();