1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 namespace Tizen.NUI.UIComponents
21 using System.Runtime.InteropServices;
22 using Tizen.NUI.BaseComponents;
25 /// ProgressBar is a control to give the user an indication of the progress of an operation.
27 public class ProgressBar : View
29 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
31 internal ProgressBar(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.ProgressBar_SWIGUpcast(cPtr), cMemoryOwn)
33 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
36 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ProgressBar obj)
38 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
42 /// To make ProgressBar instance be disposed.
44 protected override void Dispose(DisposeTypes type)
51 if (type == DisposeTypes.Explicit)
54 //Release your own managed resources here.
55 //You should release all of your own disposable objects here.
59 //Release your own unmanaged resources here.
60 //You should not access any managed member here except static instance.
61 //because the execution order of Finalizes is non-deterministic.
63 if (swigCPtr.Handle != global::System.IntPtr.Zero)
68 NDalicPINVOKE.delete_ProgressBar(swigCPtr);
70 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
78 /// Event arguments that passed via ValueChangedEventArgs
80 public class ValueChangedEventArgs : EventArgs
82 private ProgressBar _progressBar;
83 private float _progressValue;
84 private float _secondaryProgressValue;
86 public ProgressBar ProgressBar
98 public float ProgressValue
102 return _progressValue;
106 _progressValue = value;
110 public float SecondaryProgressValue
114 return _secondaryProgressValue;
118 _secondaryProgressValue = value;
124 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
125 private delegate void ValueChangedCallbackDelegate(IntPtr progressBar, float progressValue, float secondaryProgressValue);
126 private EventHandler<ValueChangedEventArgs> _progressBarValueChangedEventHandler;
127 private ValueChangedCallbackDelegate _progressBarValueChangedCallbackDelegate;
130 /// Event is sent when the ProgressBar value changes.
132 public event EventHandler<ValueChangedEventArgs> ValueChanged
136 if (_progressBarValueChangedEventHandler == null)
138 _progressBarValueChangedCallbackDelegate = (OnValueChanged);
139 ValueChangedSignal().Connect(_progressBarValueChangedCallbackDelegate);
141 _progressBarValueChangedEventHandler += value;
145 _progressBarValueChangedEventHandler -= value;
146 if (_progressBarValueChangedEventHandler == null && ValueChangedSignal().Empty() == false)
148 ValueChangedSignal().Disconnect(_progressBarValueChangedCallbackDelegate);
153 // Callback for ProgressBar ValueChanged signal
154 private void OnValueChanged(IntPtr progressBar, float progressValue, float secondaryProgressValue)
156 ValueChangedEventArgs e = new ValueChangedEventArgs();
158 // Populate all members of "e" (ValueChangedEventArgs) with real page
159 e.ProgressBar = Registry.GetManagedBaseHandleFromNativePtr(progressBar) as ProgressBar;
160 e.ProgressValue = progressValue;
161 e.SecondaryProgressValue = secondaryProgressValue;
163 if (_progressBarValueChangedEventHandler != null)
165 _progressBarValueChangedEventHandler(this, e);
169 internal class Property
171 internal static readonly int PROGRESS_VALUE = NDalicPINVOKE.ProgressBar_Property_PROGRESS_VALUE_get();
172 internal static readonly int SECONDARY_PROGRESS_VALUE = NDalicPINVOKE.ProgressBar_Property_SECONDARY_PROGRESS_VALUE_get();
173 internal static readonly int INDETERMINATE = NDalicPINVOKE.ProgressBar_Property_INDETERMINATE_get();
174 internal static readonly int TRACK_VISUAL = NDalicPINVOKE.ProgressBar_Property_TRACK_VISUAL_get();
175 internal static readonly int PROGRESS_VISUAL = NDalicPINVOKE.ProgressBar_Property_PROGRESS_VISUAL_get();
176 internal static readonly int SECONDARY_PROGRESS_VISUAL = NDalicPINVOKE.ProgressBar_Property_SECONDARY_PROGRESS_VISUAL_get();
177 internal static readonly int INDETERMINATE_VISUAL = NDalicPINVOKE.ProgressBar_Property_INDETERMINATE_VISUAL_get();
178 internal static readonly int INDETERMINATE_VISUAL_ANIMATION = NDalicPINVOKE.ProgressBar_Property_INDETERMINATE_VISUAL_ANIMATION_get();
179 internal static readonly int LABEL_VISUAL = NDalicPINVOKE.ProgressBar_Property_LABEL_VISUAL_get();
183 /// Creates the ProgressBar.
185 public ProgressBar() : this(NDalicPINVOKE.ProgressBar_New(), true)
187 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191 internal ProgressBarValueChangedSignal ValueChangedSignal()
193 ProgressBarValueChangedSignal ret = new ProgressBarValueChangedSignal(NDalicPINVOKE.ProgressBar_ValueChangedSignal(swigCPtr), false);
194 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
199 /// The progress value of progress bar, progress runs form 0 to 1.<br>
200 /// If Value is set to 0, progress bar will be set to beginning.<br>
201 /// If Value is set to 1, progress bar will be set to end.<br>
202 /// Any Value outside of the range is ignored.<br>
204 public float ProgressValue
209 GetProperty(ProgressBar.Property.PROGRESS_VALUE).Get(out temp);
214 SetProperty(ProgressBar.Property.PROGRESS_VALUE, new Tizen.NUI.PropertyValue(value));
218 /// The secondary progress value of progress bar, secondary progress runs form 0 to 1.<br>
219 /// Optional. If not supplied, the default is 0.<br>
220 /// If Value is set to 0, progress bar will be set secondary progress to beginning.<br>
221 /// If Value is set to 1, progress bar will be set secondary progress to end.<br>
222 /// Any Value outside of the range is ignored.<br>
224 public float SecondaryProgressValue
229 GetProperty(ProgressBar.Property.SECONDARY_PROGRESS_VALUE).Get(out temp);
234 SetProperty(ProgressBar.Property.SECONDARY_PROGRESS_VALUE, new Tizen.NUI.PropertyValue(value));
238 /// Sets the progress-bar as \e indeterminate state.
240 public bool Indeterminate
245 GetProperty(ProgressBar.Property.INDETERMINATE).Get(out temp);
250 SetProperty(ProgressBar.Property.INDETERMINATE, new Tizen.NUI.PropertyValue(value));
254 /// The track Visual value of progress bar, it's a full progress area and it's shown behind PROGRESS_VISUAL.<br>
255 /// Optional. If not supplied, the default track visual will be shown.<br>
257 public Tizen.NUI.PropertyMap TrackVisual
261 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
262 GetProperty(ProgressBar.Property.TRACK_VISUAL).Get(temp);
267 SetProperty(ProgressBar.Property.TRACK_VISUAL, new Tizen.NUI.PropertyValue(value));
271 /// The progress Visual value of progress bar, size of the progress visual is changed based on PROGRESS_VALUE.<br>
272 /// Optional. If not supplied, the default progress visual will be shown.<br>
274 public Tizen.NUI.PropertyMap ProgressVisual
278 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
279 GetProperty(ProgressBar.Property.PROGRESS_VISUAL).Get(temp);
284 SetProperty(ProgressBar.Property.PROGRESS_VISUAL, new Tizen.NUI.PropertyValue(value));
288 /// The secondary progress visual of progress bar, size of the secondary progress visual is changed based on SECONDARY_PROGRESS_VALUE.<br>
289 /// Optional. If not supplied, the secondary progress visual will not be shown.<br>
291 public Tizen.NUI.PropertyMap SecondaryProgressVisual
295 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
296 GetProperty(ProgressBar.Property.SECONDARY_PROGRESS_VISUAL).Get(temp);
301 SetProperty(ProgressBar.Property.SECONDARY_PROGRESS_VISUAL, new Tizen.NUI.PropertyValue(value));
305 /// The indeterminate visual of progress bar.<br>
306 /// Optional. If not supplied, the default inditerminate visual will be shown.<br>
308 public Tizen.NUI.PropertyMap IndeterminateVisual
312 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
313 GetProperty(ProgressBar.Property.INDETERMINATE_VISUAL).Get(temp);
318 SetProperty(ProgressBar.Property.INDETERMINATE_VISUAL, new Tizen.NUI.PropertyValue(value));
322 /// The transition data for indeterminate visual animation.<br>
323 /// Optional. If not supplied, default animation will be played.<br>
325 public Tizen.NUI.PropertyArray IndeterminateVisualAnimation
329 Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
330 GetProperty(ProgressBar.Property.INDETERMINATE_VISUAL_ANIMATION).Get(temp);
335 SetProperty(ProgressBar.Property.INDETERMINATE_VISUAL_ANIMATION, new Tizen.NUI.PropertyValue(value));
339 /// The Label visual of progress bar.
341 public Tizen.NUI.PropertyMap LabelVisual
345 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
346 GetProperty(ProgressBar.Property.LABEL_VISUAL).Get(temp);
351 SetProperty(ProgressBar.Property.LABEL_VISUAL, new Tizen.NUI.PropertyValue(value));