}
}
- private int BgTrackLength()
+ private int GetBgTrackLength()
{
int bgTrackLength = 0;
+
+ int lowIndicatorOffset = GetBgTrackLowIndicatorOffset();
+ int highIndicatorOffet = GetBgTrackHighIndicatorOffset();
+
+ if (direction == DirectionType.Horizontal)
+ {
+ bgTrackLength = this.Size2D.Width - lowIndicatorOffset - highIndicatorOffet;
+ }
+ else if (direction == DirectionType.Vertical)
+ {
+ bgTrackLength = this.Size2D.Height - lowIndicatorOffset - highIndicatorOffet;
+ }
+
+ return bgTrackLength;
+ }
+
+ /// <summary>
+ /// Get offset value of bgtrack's low indicator side.
+ /// </summary>
+ private int GetBgTrackLowIndicatorOffset()
+ {
+ int bgTrackLowIndicatorOffset = 0;
IndicatorType type = CurrentIndicatorType();
if (type == IndicatorType.None)
{
if (direction == DirectionType.Horizontal)
{
- bgTrackLength = this.Size2D.Width - thumbImage.Size2D.Width;
+ bgTrackLowIndicatorOffset = (int)(thumbImage.Size.Width * 0.5f);
}
else if (direction == DirectionType.Vertical)
{
- bgTrackLength = this.Size2D.Height - thumbImage.Size2D.Height;
+ bgTrackLowIndicatorOffset = (int)(thumbImage.Size.Height * 0.5f);
}
}
- else if (type == IndicatorType.Image)
- {// <lowIndicatorImage> <spaceBetweenTrackAndIndicator> <bgTrack> <spaceBetweenTrackAndIndicator> <highIndicatorImage>
- Size lowIndicatorImageSize = LowIndicatorImageSize();
- Size highIndicatorImageSize = HighIndicatorImageSize();
+ else if (type == IndicatorType.Image || type == IndicatorType.Text)
+ {// <lowIndicatorImage or Text> <spaceBetweenTrackAndIndicator> <bgTrack>
+ Size lowIndicatorSize = (type == IndicatorType.Image) ? LowIndicatorImageSize() : LowIndicatorTextSize();
int curSpace = (int)CurrentSpaceBetweenTrackAndIndicator();
if (direction == DirectionType.Horizontal)
{
- int lowIndicatorSpace = ((lowIndicatorImageSize.Width == 0) ? (0) : ((int)(curSpace + lowIndicatorImageSize.Width)));
- int highIndicatorSpace = ((highIndicatorImageSize.Width == 0) ? (0) : ((int)(curSpace + highIndicatorImageSize.Width)));
- bgTrackLength = this.Size2D.Width - lowIndicatorSpace - highIndicatorSpace;
+ bgTrackLowIndicatorOffset = ((lowIndicatorSize.Width == 0) ? (0) : ((int)(curSpace + lowIndicatorSize.Width)));
+ }
+ else if (direction == DirectionType.Vertical)
+ {
+ bgTrackLowIndicatorOffset = ((lowIndicatorSize.Height == 0) ? (0) : ((int)(curSpace + lowIndicatorSize.Height)));
+ }
+ }
+ return bgTrackLowIndicatorOffset;
+ }
+
+ /// <summary>
+ /// Get offset value of bgtrack's high indicator side.
+ /// </summary>
+ private int GetBgTrackHighIndicatorOffset()
+ {
+ int bgTrackHighIndicatorOffset = 0;
+ IndicatorType type = CurrentIndicatorType();
+
+ if (type == IndicatorType.None)
+ {
+ if (direction == DirectionType.Horizontal)
+ {
+ bgTrackHighIndicatorOffset = (int)(thumbImage.Size.Width * 0.5f);
}
else if (direction == DirectionType.Vertical)
{
- int lowIndicatorSpace = ((lowIndicatorImageSize.Height == 0) ? (0) : ((int)(curSpace + lowIndicatorImageSize.Height)));
- int highIndicatorSpace = ((highIndicatorImageSize.Height == 0) ? (0) : ((int)(curSpace + highIndicatorImageSize.Height)));
- bgTrackLength = this.Size2D.Height - lowIndicatorSpace - highIndicatorSpace;
+ bgTrackHighIndicatorOffset = (int)(thumbImage.Size.Height * 0.5f);
}
}
- else if (type == IndicatorType.Text)
- {// <lowIndicatorText> <spaceBetweenTrackAndIndicator> <bgTrack> <spaceBetweenTrackAndIndicator> <highIndicatorText>
- Size lowIndicatorTextSize = LowIndicatorTextSize();
- Size highIndicatorTextSize = HighIndicatorTextSize();
+ else if (type == IndicatorType.Image || type == IndicatorType.Text)
+ {// <bgTrack> <spaceBetweenTrackAndIndicator> <highIndicatorImage or Text>
+ Size highIndicatorSize = (type == IndicatorType.Image) ? HighIndicatorImageSize() : HighIndicatorTextSize();
int curSpace = (int)CurrentSpaceBetweenTrackAndIndicator();
if (direction == DirectionType.Horizontal)
{
- int lowIndicatorSpace = ((lowIndicatorTextSize.Width == 0) ? (0) : ((int)(curSpace + lowIndicatorTextSize.Width)));
- int highIndicatorSpace = ((highIndicatorTextSize.Width == 0) ? (0) : ((int)(curSpace + highIndicatorTextSize.Width)));
- bgTrackLength = this.Size2D.Width - lowIndicatorSpace - highIndicatorSpace;
+ bgTrackHighIndicatorOffset = ((highIndicatorSize.Width == 0) ? (0) : ((int)(curSpace + highIndicatorSize.Width)));
}
else if (direction == DirectionType.Vertical)
{
- int lowIndicatorSpace = ((lowIndicatorTextSize.Height == 0) ? (0) : ((int)(curSpace + lowIndicatorTextSize.Height)));
- int highIndicatorSpace = ((highIndicatorTextSize.Height == 0) ? (0) : ((int)(curSpace + highIndicatorTextSize.Height)));
- bgTrackLength = this.Size2D.Height - lowIndicatorSpace - highIndicatorSpace;
+ bgTrackHighIndicatorOffset = ((highIndicatorSize.Height == 0) ? (0) : ((int)(curSpace + highIndicatorSize.Height)));
}
}
- return bgTrackLength;
+ return bgTrackHighIndicatorOffset;
}
private void UpdateLowIndicatorSize()
}
else
{
- if (lowIndicatorImage != null && lowIndicatorImage != null && lowIndicatorImage.Size != null)
+ if (lowIndicatorImage != null && lowIndicatorImage.Size != null)
{
lowIndicatorImage.Size = lowIndicatorSize ?? (ViewStyle as SliderStyle)?.LowIndicatorImage.Size;
}
- if (lowIndicatorText != null && lowIndicatorText != null && lowIndicatorText.Size != null)
+ if (lowIndicatorText != null && lowIndicatorText.Size != null)
{
lowIndicatorText.Size = lowIndicatorSize ?? (ViewStyle as SliderStyle)?.LowIndicator.Size;
}
}
}
+ private void UpdateHighIndicatorSize()
+ {
+ if (highIndicatorSize != null)
+ {
+ if (highIndicatorImage != null)
+ {
+ highIndicatorImage.Size = highIndicatorSize;
+ }
+ if (highIndicatorText != null)
+ {
+ highIndicatorText.Size = highIndicatorSize;
+ }
+ }
+ else
+ {
+ if (highIndicatorImage != null && highIndicatorImage.Size != null)
+ {
+ highIndicatorImage.Size = highIndicatorSize ?? (ViewStyle as SliderStyle)?.HighIndicatorImage.Size;
+ }
+ if (highIndicatorText != null && highIndicatorText.Size != null)
+ {
+ highIndicatorText.Size = highIndicatorSize ?? (ViewStyle as SliderStyle)?.HighIndicator.Size;
+ }
+ }
+ }
+
private void UpdateBgTrackSize()
{
if (bgTrackImage == null)
return;
}
int curTrackThickness = (int)CurrentTrackThickness();
- int bgTrackLength = BgTrackLength();
+ int bgTrackLength = GetBgTrackLength();
if (direction == DirectionType.Horizontal)
{
bgTrackImage.Size2D = new Size2D(bgTrackLength, curTrackThickness);
{
return;
}
- IndicatorType type = CurrentIndicatorType();
- if (type == IndicatorType.None)
- {
- bgTrackImage.Position2D = new Position2D(0, 0);
- }
- else if (type == IndicatorType.Image)
+ int lowIndicatorOffset = GetBgTrackLowIndicatorOffset();
+ int highIndicatorOffet = GetBgTrackHighIndicatorOffset();
+
+ if (direction == DirectionType.Horizontal)
{
- Size lowIndicatorImageSize = LowIndicatorImageSize();
- Size highIndicatorImageSize = HighIndicatorImageSize();
- int curSpace = (int)CurrentSpaceBetweenTrackAndIndicator();
- if (direction == DirectionType.Horizontal)
- {
- int lowIndicatorSpace = ((lowIndicatorImageSize.Width == 0) ? (0) : ((int)(curSpace + lowIndicatorImageSize.Width)));
- int highIndicatorSpace = ((highIndicatorImageSize.Width == 0) ? (0) : ((int)(curSpace + highIndicatorImageSize.Width)));
- bgTrackImage.Position2D = new Position2D(lowIndicatorSpace - (lowIndicatorSpace + highIndicatorSpace) / 2, 0);
- }
- else if (direction == DirectionType.Vertical)
- {
- int lowIndicatorSpace = ((lowIndicatorImageSize.Height == 0) ? (0) : ((int)(curSpace + lowIndicatorImageSize.Height)));
- int highIndicatorSpace = ((highIndicatorImageSize.Height == 0) ? (0) : ((int)(curSpace + highIndicatorImageSize.Height)));
- bgTrackImage.Position2D = new Position2D(0, lowIndicatorSpace - (lowIndicatorSpace + highIndicatorSpace) / 2);
- }
+ bgTrackImage.Position2D = new Position2D((lowIndicatorOffset - highIndicatorOffet) / 2, 0);
}
- else if (type == IndicatorType.Text)
+ else if (direction == DirectionType.Vertical)
{
- Size lowIndicatorTextSize = LowIndicatorTextSize();
- Size highIndicatorTextSize = HighIndicatorTextSize();
- int curSpace = (int)CurrentSpaceBetweenTrackAndIndicator();
- if (direction == DirectionType.Horizontal)
- {
- int lowIndicatorSpace = ((lowIndicatorTextSize.Width == 0) ? (0) : ((int)(curSpace + lowIndicatorTextSize.Width)));
- int highIndicatorSpace = ((highIndicatorTextSize.Width == 0) ? (0) : ((int)(curSpace + highIndicatorTextSize.Width)));
- bgTrackImage.Position2D = new Position2D(lowIndicatorSpace - (lowIndicatorSpace + highIndicatorSpace) / 2, 0);
- }
- else if (direction == DirectionType.Vertical)
- {
- int lowIndicatorSpace = ((lowIndicatorTextSize.Height == 0) ? (0) : ((int)(curSpace + lowIndicatorTextSize.Height)));
- int highIndicatorSpace = ((highIndicatorTextSize.Height == 0) ? (0) : ((int)(curSpace + highIndicatorTextSize.Height)));
- bgTrackImage.Position2D = new Position2D(0, -(lowIndicatorSpace - (lowIndicatorSpace + highIndicatorSpace) / 2));
- }
+ bgTrackImage.Position2D = new Position2D(0, (highIndicatorOffet - lowIndicatorOffset) / 2);
}
}
{
ratio = 1.0f - ratio;
}
- float slidedTrackLength = (float)BgTrackLength() * ratio;
+ float slidedTrackLength = (float)GetBgTrackLength() * 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();
}
else if (direction == DirectionType.Vertical)
{
- float slidedTrackLength = (float)BgTrackLength() * ratio;
+ float slidedTrackLength = (float)GetBgTrackLength() * ratio;
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();