return instance.state;
});
+ /// <summary>
+ /// IsEnabledProperty
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool), typeof(Progress), true, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var instance = (Progress)bindable;
+ if (newValue != null)
+ {
+ bool newEnabled = (bool)newValue;
+ if (instance.isEnabled != newEnabled)
+ {
+ instance.isEnabled = newEnabled;
+ instance.Sensitive = newEnabled;
+ instance.UpdateStates();
+ }
+ }
+ },
+ defaultValueCreator: (bindable) => ((Progress)bindable).isEnabled);
+
/// This needs to be considered more if public-open is necessary.
private ProgressStatusType state = ProgressStatusType.Determinate;
private float currentValue = 0;
private float bufferValue = 0;
private Animation indeterminateAnimation = null;
+ bool isEnabled = true;
static Progress() { }
/// <summary>
}
/// <summary>
- /// Prevents from showing child widgets in AT-SPI tree.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected override bool AccessibilityShouldReportZeroChildren()
- {
- return true;
- }
-
- /// <summary>
- /// Minimum value.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected override double AccessibilityGetMinimum()
- {
- if (this.ProgressState == Components.Progress.ProgressStatusType.Determinate)
- return (double)MinValue;
- else return 0.0;
- }
-
- /// <summary>
- /// Current value.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected override double AccessibilityGetCurrent()
- {
- if (this.ProgressState == Components.Progress.ProgressStatusType.Determinate)
- return (double)CurrentValue;
- else return 0.0;
- }
-
- /// <summary>
- /// Maximum value.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected override double AccessibilityGetMaximum()
- {
- if (this.ProgressState == Components.Progress.ProgressStatusType.Determinate)
- return (double)MaxValue;
- else return 0.0;
- }
-
- /// <summary>
/// The status type of the Progress.
/// </summary>
/// <since_tizen> 6 </since_tizen>
}
}
+ /// <summary>
+ /// Flag to decide enable or disable in Progress.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool IsEnabled
+ {
+ get
+ {
+ return (bool)GetValue(IsEnabledProperty);
+ }
+ set
+ {
+ SetValue(IsEnabledProperty, value);
+ }
+ }
+
/// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)]
public override void OnInitialize()
}
/// <summary>
+ /// Prevents from showing child widgets in AT-SPI tree.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override bool AccessibilityShouldReportZeroChildren()
+ {
+ return true;
+ }
+
+ /// <summary>
+ /// Gets minimum value for Accessibility.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override double AccessibilityGetMinimum()
+ {
+ if (this.ProgressState == Progress.ProgressStatusType.Determinate)
+ {
+ return (double)MinValue;
+ }
+ else
+ {
+ return 0.0;
+ }
+ }
+
+ /// <summary>
+ /// Gets the current value for Accessibility.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override double AccessibilityGetCurrent()
+ {
+ if (this.ProgressState == Progress.ProgressStatusType.Determinate)
+ {
+ return (double)CurrentValue;
+ }
+ else
+ {
+ return 0.0;
+ }
+ }
+
+ /// <summary>
+ /// Gets maximum value for Accessibility.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override double AccessibilityGetMaximum()
+ {
+ if (this.ProgressState == Progress.ProgressStatusType.Determinate)
+ {
+ return (double)MaxValue;
+ }
+ else
+ {
+ return 0.0;
+ }
+ }
+
+ /// <summary>
/// Dispose Progress and all children on it.
/// </summary>
/// <param name="type">Dispose type.</param>
/// <param name="statusType">New status type</param>
protected void ChangeImageState(ProgressStatusType statusType)
{
+ if (!IsEnabled)
+ {
+ ControlState = ControlState.Disabled;
+
+ indeterminateAnimation?.Stop();
+ indeterminateAnimation = null;
+
+ if (null != indeterminateImage)
+ {
+ indeterminateImage.Opacity = 0.0f;
+ }
+ progressImage.Hide();
+ bufferImage.Hide();
+ return;
+ }
+
if (statusType == ProgressStatusType.Buffering)
{
indeterminateAnimation?.Stop();
}
);
+ /// <summary>
+ /// IsEnabledProperty
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool), typeof(Slider), true, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var instance = (Slider)bindable;
+ if (newValue != null)
+ {
+ bool newEnabled = (bool)newValue;
+ if (instance.isEnabled != newEnabled)
+ {
+ instance.isEnabled = newEnabled;
+ instance.Sensitive = newEnabled;
+ instance.UpdateValue();
+ }
+ }
+ },
+ defaultValueCreator: (bindable) => ((Slider)bindable).isEnabled);
+
static Slider() { }
/// <summary>
}
}
+ /// <summary>
+ /// Flag to decide enable or disable in Slider.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool IsEnabled
+ {
+ get
+ {
+ return (bool)GetValue(IsEnabledProperty);
+ }
+ set
+ {
+ SetValue(IsEnabledProperty, value);
+ }
+ }
+
private Extents spaceBetweenTrackAndIndicator
{
get
[EditorBrowsable(EditorBrowsableState.Never)]
public override bool OnKey(Key key)
{
- // TODO : Add IsEnabled conditional later.
- if (null == key)
+ if (!IsEnabled || null == key)
{
return false;
}
private bool OnTouchEventForTrack(object source, TouchEventArgs e)
{
+ if (!IsEnabled)
+ {
+ return false;
+ }
+
PointStateType state = e.Touch.GetState(0);
if (state == PointStateType.Down)
{
isFocused = isFocusedNew;
isPressed = isPressedNew;
- if (!isFocused && !isPressed)
+ if(!IsEnabled) // Disabled
+ {
+ ControlState = ControlState.Disabled;
+
+ if (stateChangedHandler != null)
+ {
+ StateChangedArgs args = new StateChangedArgs();
+ args.CurrentState = (ControlStates)ControlStates.Disabled;
+ stateChangedHandler(this, args);
+ }
+ }
+ else if (!isFocused && !isPressed)
{
ControlState = ControlState.Normal;