private ImageView bgTrackImage = null;
// the slided track image object
private ImageView slidedTrackImage = null;
+ // the warning track image object
+ private ImageView warningTrackImage = null;
+ // the warning slided track image object
+ private ImageView warningSlidedTrackImage = null;
// the thumb image object
private ImageView thumbImage = null;
// the low indicator image object
private float maxValue = 100;
// the current value
private float curValue = 0;
+ // the warning start value
+ private float warningStartValue = 100;
// the size of the low indicator
private Size lowIndicatorSize = null;
// the size of the high indicator
// the value indicator image object
private ImageView valueIndicatorImage = null;
+ // To store the thumb size of normal state
+ private Size thumbSize = null;
+ // To store the thumb image url of normal state
+ private string thumbImageUrl = null;
+ // To store the thumb image url selector of normal state
+ private Selector<string> thumbImageUrlSelector = null;
+ // To store the thumb color of normal state
+ private Color thumbColor = Color.White;
+ // To store the thumb image url of warning state
+ private string warningThumbImageUrl = null;
+ // To store the thumb image url selector of warning state
+ private Selector<string> warningThumbImageUrlSelector = null;
+ // To store the thumb color of warning state
+ private Color warningThumbColor = null;
+
private PanGestureDetector panGestureDetector = null;
private float currentSlidedOffset;
private EventHandler<ValueChangedArgs> valueChangedHandler;
{
bgTrackImage.Add(slidedTrackImage);
}
+ }
- if (null != thumbImage)
+ return slidedTrackImage;
+ }
+
+ private ImageView CreateWarningTrack()
+ {
+ if (null == warningTrackImage)
+ {
+ warningTrackImage = new ImageView()
+ {
+ WidthResizePolicy = ResizePolicyType.Fixed,
+ HeightResizePolicy = ResizePolicyType.Fixed
+ };
+
+ if (bgTrackImage != null)
+ {
+ bgTrackImage.Add(warningTrackImage);
+ }
+
+ if (warningSlidedTrackImage != null)
{
- slidedTrackImage.Add(thumbImage);
+ warningTrackImage.Add(warningSlidedTrackImage);
+ }
+
+ if (slidedTrackImage != null)
+ {
+ warningTrackImage.RaiseAbove(slidedTrackImage);
}
}
- return slidedTrackImage;
+ return warningTrackImage;
+ }
+
+ private ImageView CreateWarningSlidedTrack()
+ {
+ if (null == warningSlidedTrackImage)
+ {
+ warningSlidedTrackImage = new ImageView()
+ {
+ WidthResizePolicy = ResizePolicyType.Fixed,
+ HeightResizePolicy = ResizePolicyType.Fixed
+ };
+
+ if (warningTrackImage != null)
+ {
+ warningTrackImage.Add(warningSlidedTrackImage);
+ }
+ }
+
+ return warningSlidedTrackImage;
}
private TextLabel CreateLowIndicatorText()
{
bgTrackImage.Add(slidedTrackImage);
}
+ if (null != warningTrackImage)
+ {
+ bgTrackImage.Add(warningTrackImage);
+ }
+ if (null != thumbImage)
+ {
+ bgTrackImage.Add(thumbImage);
+ thumbImage.RaiseToTop();
+ }
bgTrackImage.TouchEvent += OnTouchEventForBgTrack;
}
PivotPoint = NUI.PivotPoint.Center,
PositionUsesPivotPoint = true
};
- if (slidedTrackImage != null)
+ if (bgTrackImage != null)
{
- slidedTrackImage.Add(thumbImage);
+ bgTrackImage.Add(thumbImage);
}
+ thumbImage.RaiseToTop();
thumbImage.TouchEvent += OnTouchEventForThumb;
}
private ImageView CreateValueIndicator()
{
- if (null == valueIndicatorImage)
+ if (valueIndicatorImage == null)
{
valueIndicatorImage = new ImageView()
{
slidedTrackImage.PivotPoint = NUI.PivotPoint.CenterLeft;
slidedTrackImage.PositionUsesPivotPoint = true;
}
+ if (warningTrackImage != null)
+ {
+ warningTrackImage.ParentOrigin = NUI.ParentOrigin.CenterRight;
+ warningTrackImage.PivotPoint = NUI.PivotPoint.CenterRight;
+ warningTrackImage.PositionUsesPivotPoint = true;
+ }
+ if (warningSlidedTrackImage != null)
+ {
+ warningSlidedTrackImage.ParentOrigin = NUI.ParentOrigin.CenterLeft;
+ warningSlidedTrackImage.PivotPoint = NUI.PivotPoint.CenterLeft;
+ warningSlidedTrackImage.PositionUsesPivotPoint = true;
+ }
if (thumbImage != null)
{
- thumbImage.ParentOrigin = NUI.ParentOrigin.CenterRight;
+ thumbImage.ParentOrigin = NUI.ParentOrigin.CenterLeft;
thumbImage.PivotPoint = NUI.PivotPoint.Center;
thumbImage.PositionUsesPivotPoint = true;
}
slidedTrackImage.PivotPoint = NUI.PivotPoint.BottomCenter;
slidedTrackImage.PositionUsesPivotPoint = true;
}
+ if (warningTrackImage != null)
+ {
+ warningTrackImage.ParentOrigin = NUI.ParentOrigin.TopCenter;
+ warningTrackImage.PivotPoint = NUI.PivotPoint.TopCenter;
+ warningTrackImage.PositionUsesPivotPoint = true;
+ }
+ if (warningSlidedTrackImage != null)
+ {
+ warningSlidedTrackImage.ParentOrigin = NUI.ParentOrigin.BottomCenter;
+ warningSlidedTrackImage.PivotPoint = NUI.PivotPoint.BottomCenter;
+ warningSlidedTrackImage.PositionUsesPivotPoint = true;
+ }
if (thumbImage != null)
{
- thumbImage.ParentOrigin = NUI.ParentOrigin.TopCenter;
+ thumbImage.ParentOrigin = NUI.ParentOrigin.BottomCenter;
thumbImage.PivotPoint = NUI.PivotPoint.Center;
thumbImage.PositionUsesPivotPoint = true;
}
}
float slidedTrackLength = (float)BgTrackLength() * ratio;
slidedTrackImage.Size2D = new Size2D((int)(slidedTrackLength + round), (int)curTrackThickness); //Add const round to reach Math.Round function.
+ thumbImage.Position = new Position(slidedTrackImage.Size2D.Width, 0);
+ thumbImage.RaiseToTop();
if (isValueShown)
{
else if (direction == DirectionType.Vertical)
{
float slidedTrackLength = (float)BgTrackLength() * ratio;
- slidedTrackImage.Size2D = new Size2D((int)(curTrackThickness + round), (int)slidedTrackLength); //Add const round to reach Math.Round function.
+ slidedTrackImage.Size2D = new Size2D((int)curTrackThickness, (int)(slidedTrackLength + round)); //Add const round to reach Math.Round function.
+ thumbImage.Position = new Position(0, -slidedTrackImage.Size2D.Height);
+ thumbImage.RaiseToTop();
if (isValueShown)
{
valueIndicatorImage.Position = new Position(0, -(slidedTrackImage.Size2D.Height + thumbImage.Size.Height / 2));
}
}
+
+ // Update the track and thumb when the value is over warning value.
+ if (curValue >= warningStartValue)
+ {
+ if (direction == DirectionType.Horizontal)
+ {
+ warningSlidedTrackImage.Size2D = new Size2D((int)(((curValue - warningStartValue) / 100) * this.Size2D.Width), (int)curTrackThickness);
+ }
+ else if (direction == DirectionType.Vertical)
+ {
+ warningSlidedTrackImage.Size2D = new Size2D((int)curTrackThickness, (int)(((curValue - warningStartValue) / 100) * this.Size2D.Height));
+ }
+
+ if (warningThumbColor != null && thumbImage.Color.NotEqualTo(warningThumbColor))
+ {
+ thumbImage.Color = warningThumbColor;
+ }
+ if (warningThumbImageUrl != null && !thumbImage.ResourceUrl.Equals(warningThumbImageUrl))
+ {
+ thumbImage.ResourceUrl = warningThumbImageUrl;
+ }
+ }
+ else
+ {
+ warningSlidedTrackImage.Size2D = new Size2D(0, 0);
+ if (warningThumbColor != null && thumbImage.Color.EqualTo(warningThumbColor))
+ {
+ thumbImage.Color = thumbColor;
+ }
+ if (warningThumbImageUrl != null && thumbImage.ResourceUrl.Equals(warningThumbImageUrl))
+ {
+ thumbImage.ResourceUrl = thumbImageUrl;
+ }
+ }
}
private uint CurrentTrackThickness()
return curSpace;
}
+ private void UpdateWarningTrackSize()
+ {
+ if (warningTrackImage == null)
+ {
+ return;
+ }
+
+ int curTrackThickness = (int)CurrentTrackThickness();
+ float warningTrackLength = maxValue - warningStartValue;
+ if (direction == DirectionType.Horizontal)
+ {
+ warningTrackLength = (warningTrackLength / 100) * this.Size2D.Width;
+ warningTrackImage.Size2D = new Size2D((int)warningTrackLength, curTrackThickness);
+ }
+ else if (direction == DirectionType.Vertical)
+ {
+ warningTrackLength = (warningTrackLength / 100) * this.Size2D.Height;
+ warningTrackImage.Size2D = new Size2D(curTrackThickness, (int)warningTrackLength);
+ }
+ }
+
private IndicatorType CurrentIndicatorType()
{
IndicatorType type = IndicatorType.None;
/// <since_tizen> 6 </since_tizen>
public partial class Slider : Control
{
+ /// <summary>
+ /// IndicatorTypeProperty
+ /// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty IndicatorTypeProperty = BindableProperty.Create("IndicatorType", typeof(IndicatorType), typeof(Slider), IndicatorType.None, propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Slider)bindable;
return instance.privateIndicatorType;
});
+
+ /// <summary>
+ /// SpaceBetweenTrackAndIndicatorProperty
+ /// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty SpaceBetweenTrackAndIndicatorProperty = BindableProperty.Create(nameof(SpaceBetweenTrackAndIndicator), typeof(uint), typeof(Slider), (uint)0, propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Slider)bindable;
return instance.privateSpaceBetweenTrackAndIndicator;
});
+
+ /// <summary>
+ /// TrackThicknessProperty
+ /// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty TrackThicknessProperty = BindableProperty.Create(nameof(TrackThickness), typeof(uint), typeof(Slider), (uint)0, propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Slider)bindable;
return instance.privateTrackThickness;
});
+
+ /// <summary>
+ /// IsValueShownProperty
+ /// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty IsValueShownProperty = BindableProperty.Create(nameof(IsValueShown), typeof(bool), typeof(Slider), true, propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Slider)bindable;
return instance.isValueShown;
});
+
+ /// <summary>
+ /// ValueIndicatorTextProperty
+ /// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty ValueIndicatorTextProperty = BindableProperty.Create(nameof(ValueIndicatorText), typeof(string), typeof(Slider), string.Empty, propertyChanged: (bindable, oldValue, newValue) =>
{
RelayoutBaseComponent(false);
UpdateBgTrackSize();
UpdateBgTrackPosition();
+ UpdateWarningTrackSize();
UpdateValue();
}
}
if (null != thumbImage)
{
thumbImage.Size = value;
+ thumbSize = value;
sliderStyle.Thumb.Size = value;
}
}
/// <summary>
/// Gets or sets the resource url of the thumb image object.
+ ///
+ /// Please use ThumbImageUri property.
/// </summary>
/// <since_tizen> 6 </since_tizen>
public string ThumbImageURL
if (null != thumbImage)
{
thumbImage.ResourceUrl = value;
+ thumbImageUrl = value;
sliderStyle.Thumb.ResourceUrl = value;
}
}
/// <summary>
/// Gets or sets the resource url selector of the thumb image object.
/// Getter returns copied selector value if exist, null otherwise.
+ ///
+ /// Please use ThumbImageUri property.
/// </summary>
/// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
/// <since_tizen> 6 </since_tizen>
else
{
thumbImage.SetValue(ImageView.ResourceUrlSelectorProperty, value);
+ thumbImageUrlSelector = value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the Uri of the thumb image.
+ /// </summary>
+ /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
+ /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Selector<Uri> ThumbImageUri
+ {
+ get
+ {
+ if (thumbImage == null)
+ {
+ return null;
+ }
+ else
+ {
+ return ((Selector<string>)thumbImage.GetValue(ImageView.ResourceUrlSelectorProperty)).Clone<Uri>(str => { return new Uri(str); });
+ }
+ }
+ set
+ {
+ if (value == null || thumbImage == null)
+ {
+ throw new NullReferenceException("Slider.ThumbImageUri is null");
+ }
+ else
+ {
+ Selector<string> stringValue = value.Clone<string>(m => m?.AbsoluteUri);
+ thumbImage.SetValue(ImageView.ResourceUrlSelectorProperty, stringValue);
+ thumbImageUrlSelector = stringValue;
}
}
}
if (null != thumbImage)
{
thumbImage.Color = value;
+ thumbColor = value;
sliderStyle.Thumb.Color = value;
}
}
}
}
+ /// <summary>
+ /// Gets or sets the warning start value between minimum value and maximum value of slider.
+ /// </summary>
+ /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public float WarningStartValue
+ {
+ get
+ {
+ return warningStartValue;
+ }
+ set
+ {
+ warningStartValue = value;
+ UpdateValue();
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the color of the warning track image object.
+ /// </summary>
+ /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Color WarningTrackColor
+ {
+ get
+ {
+ return warningTrackImage?.BackgroundColor;
+ }
+ set
+ {
+ if (null != warningTrackImage)
+ {
+ warningTrackImage.BackgroundColor = value;
+ sliderStyle.WarningTrack.BackgroundColor = value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the color of the warning slided track image object.
+ /// </summary>
+ /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Color WarningSlidedTrackColor
+ {
+ get
+ {
+ return warningSlidedTrackImage?.BackgroundColor;
+ }
+ set
+ {
+ if (null != warningSlidedTrackImage)
+ {
+ warningSlidedTrackImage.BackgroundColor = value;
+ sliderStyle.WarningProgress.BackgroundColor = value;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the resource url of the warning thumb image object.
+ /// </summary>
+ /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string WarningThumbImageUrl
+ {
+ get
+ {
+ return warningThumbImageUrl;
+ }
+ set
+ {
+ warningThumbImageUrl = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the Uri of the warning thumb image.
+ /// </summary>
+ /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
+ /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Selector<Uri> WarningThumbImageUri
+ {
+ get
+ {
+ return warningThumbImageUrlSelector?.Clone<Uri>(str => { return new Uri(str); });
+ }
+ set
+ {
+ if (value == null || thumbImage == null)
+ {
+ throw new NullReferenceException("Slider.WarningThumbImageUri is null");
+ }
+ else
+ {
+ warningThumbImageUrlSelector = value.Clone<string>(m => m?.AbsoluteUri);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the color of the warning thumb image object.
+ /// </summary>
+ /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Color WarningThumbColor
+ {
+ get
+ {
+ return warningThumbColor;
+ }
+ set
+ {
+ warningThumbColor = value;
+ }
+ }
+
/// <summary>
/// Gets or sets the resource url of the low indicator image object.
/// </summary>
slidedTrackImage.SizeWidth = (float)trackThickness.Value;
}
}
+ if (warningTrackImage != null)
+ {
+ if (direction == DirectionType.Horizontal)
+ {
+ warningTrackImage.SizeHeight = (float)trackThickness.Value;
+ }
+ else if (direction == DirectionType.Vertical)
+ {
+ warningTrackImage.SizeWidth = (float)trackThickness.Value;
+ }
+ }
+ if (warningSlidedTrackImage != null)
+ {
+ if (direction == DirectionType.Horizontal)
+ {
+ warningSlidedTrackImage.SizeHeight = (float)trackThickness.Value;
+ }
+ else if (direction == DirectionType.Vertical)
+ {
+ warningSlidedTrackImage.SizeWidth = (float)trackThickness.Value;
+ }
+ }
}
}
CreateValueIndicator().ApplyStyle(sliderStyle.ValueIndicatorImage);
}
+ if (null != sliderStyle?.WarningTrack)
+ {
+ CreateWarningTrack().ApplyStyle(sliderStyle.WarningTrack);
+ }
+
+ if (null != sliderStyle?.WarningProgress)
+ {
+ CreateWarningSlidedTrack().ApplyStyle(sliderStyle.WarningProgress);
+ }
+
EnableControlStatePropagation = true;
}
thumbImage.TouchEvent -= OnTouchEventForThumb;
Utility.Dispose(thumbImage);
}
+ Utility.Dispose(warningSlidedTrackImage);
+ Utility.Dispose(warningTrackImage);
Utility.Dispose(slidedTrackImage);
if (null != bgTrackImage)
{
UpdateComponentByIndicatorTypeChanged();
UpdateBgTrackSize();
UpdateBgTrackPosition();
+ UpdateWarningTrackSize();
UpdateLowIndicatorSize();
UpdateValue();
}
if (!isFocused && !isPressed)
{
ControlState = ControlState.Normal;
+ thumbImage.ResourceUrl = thumbImageUrlSelector?.Normal;
+
if (stateChangedHandler != null)
{
StateChangedArgs args = new StateChangedArgs();
else if (isPressed)
{
ControlState = ControlState.Pressed;
+ thumbImage.ResourceUrl = thumbImageUrlSelector?.Pressed;
if (stateChangedHandler != null)
{
else if (!isPressed && isFocused)
{
ControlState = ControlState.Focused;
+ thumbImage.ResourceUrl = thumbImageUrlSelector?.Focused;
if (stateChangedHandler != null)
{
/// <since_tizen> 8 </since_tizen>
public class SliderStyle : ControlStyle
{
+ /// <summary>
+ /// IndicatorTypeProperty
+ /// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty IndicatorTypeProperty = BindableProperty.Create(nameof(IndicatorType), typeof(IndicatorType?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (SliderStyle)bindable;
return instance.privateIndicatorType;
});
+
+ /// <summary>
+ /// SpaceBetweenTrackAndIndicatorProperty
+ /// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty SpaceBetweenTrackAndIndicatorProperty = BindableProperty.Create(nameof(SpaceBetweenTrackAndIndicator), typeof(uint?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (SliderStyle)bindable;
return instance.privateSpaceBetweenTrackAndIndicator;
});
+
+ /// <summary>
+ /// TrackThicknessProperty
+ /// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty TrackThicknessProperty = BindableProperty.Create(nameof(TrackThickness), typeof(uint?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (SliderStyle)bindable;
return instance.privateTrackThickness;
});
+
+ /// <summary>
+ /// TrackPaddingProperty
+ /// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty TrackPaddingProperty = BindableProperty.Create(nameof(TrackPadding), typeof(Extents), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
{
/// <since_tizen> 8 </since_tizen>
public ImageViewStyle Thumb { get; set; } = new ImageViewStyle();
+ /// <summary>
+ /// Get or set background warning track.
+ /// </summary>
+ /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ImageViewStyle WarningTrack { get; set; } = new ImageViewStyle();
+
+ /// <summary>
+ /// Get or set slided warning track.
+ /// </summary>
+ /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ImageViewStyle WarningProgress { get; set; } = new ImageViewStyle();
+
/// <summary>
/// Get or set low indicator image.
/// </summary>
Track.CopyFrom(sliderStyle.Track);
Progress.CopyFrom(sliderStyle.Progress);
Thumb.CopyFrom(sliderStyle.Thumb);
+ WarningTrack.CopyFrom(sliderStyle.WarningTrack);
+ WarningProgress.CopyFrom(sliderStyle.WarningProgress);
LowIndicatorImage.CopyFrom(sliderStyle.LowIndicatorImage);
HighIndicatorImage.CopyFrom(sliderStyle.HighIndicatorImage);
LowIndicator.CopyFrom(sliderStyle.LowIndicator);