using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace CustomSlider
{
public class RangeSlider : View
{
public const string LowerValuePropertyName = "LowerValue";
public const string MaximumValuePropertyName = "MaximumValue";
public const string MinimumValuePropertyName = "MinimumValue";
public const string UpperValuePropertyName = "UpperValue";
public const string MinThumbHiddenPropertyName = "MinThumbHidden";
public const string MaxThumbHiddenPropertyName = "MaxThumbHidden";
public const string StepValuePropertyName = "StepValue";
public const string StepValueContinuouslyPropertyName = "StepValueContinuously";
public const string BarHeightPropertyName = "BarHeight";
public const string ShowTextAboveThumbsPropertyName = "ShowTextAboveThumbs";
public const string TextSizePropertyName = "TextSize";
public const string TextFormatPropertyName = "TextFormat";
public const string FormatLabelPropertyName = "FormatLabel";
public const string ActiveColorPropertyName = "ActiveColor";
public const string NormalColorPropertyName = "NormalColor";
public const string SliderPropertyName = "SliderName";
//public const string LowerThumbImagePropertyName = "LowerThumbImage";
//public const string UpperThumbImagePropertyName = "UpperThumbImage";
//public static BindableProperty LowerThumbImageProperty =
//
BindableProperty.Create(LowerThumbImagePropertyName, typeof(string), typeof(RangeSlider), null);
//public static BindableProperty UpperThumbImageProperty =
//
BindableProperty.Create(UpperThumbImagePropertyName, typeof(string), typeof(RangeSlider), null);
public static BindableProperty ActiveColorProperty =
BindableProperty.Create(ActiveColorPropertyName, typeof(Color), typeof(RangeSlider), Color.FromRgb(0, 160, 212));
public static BindableProperty NormalColorProperty =
BindableProperty.Create(NormalColorPropertyName, typeof(Color), typeof(RangeSlider), Color.FromRgb(149, 208, 231));
public static readonly BindableProperty LowerValueProperty =
BindableProperty.Create(LowerValuePropertyName, typeof(float), typeof(RangeSlider), 0f);
public static readonly BindableProperty MaximumValueProperty =
BindableProperty.Create(MaximumValuePropertyName, typeof(float), typeof(RangeSlider), 0f);
public static readonly BindableProperty MaxThumbHiddenProperty =
BindableProperty.Create(MaxThumbHiddenPropertyName, typeof(bool), typeof(RangeSlider), false);
public static readonly BindableProperty MinimumValueProperty =
BindableProperty.Create(MinimumValuePropertyName, typeof(float), typeof(RangeSlider), 0f);
public static readonly BindableProperty MinThumbHiddenProperty =
BindableProperty.Create(MinThumbHiddenPropertyName, typeof(bool), typeof(RangeSlider), false);
public static readonly BindableProperty StepValueContinuouslyProperty =
BindableProperty.Create(StepValueContinuouslyPropertyName, typeof(bool), typeof(RangeSlider), false);
public static readonly BindableProperty StepValueProperty =
BindableProperty.Create(StepValuePropertyName, typeof(float), typeof(RangeSlider), 0f);
public static readonly BindableProperty UpperValueProperty =
BindableProperty.Create(UpperValuePropertyName, typeof(float), typeof(RangeSlider), 0f);
public static readonly BindableProperty BarHeightProperty =
BindableProperty.Create(BarHeightPropertyName, typeof(int), typeof(RangeSlider), 0);
public static readonly BindableProperty ShowTextAboveThumbsProperty =
BindableProperty.Create(ShowTextAboveThumbsPropertyName, typeof(bool), typeof(RangeSlider), false);
public static readonly BindableProperty TextSizeProperty =
BindableProperty.Create(TextSizePropertyName, typeof(double), typeof(RangeSlider), 10D);
public static readonly BindableProperty TextFormatProperty =
BindableProperty.Create(TextFormatPropertyName, typeof(string), typeof(RangeSlider), "F0");
public static readonly BindableProperty FormatLabelProperty =
BindableProperty.Create(FormatLabelPropertyName, typeof(Func<Thumb, float, string>), typeof(RangeSlider), null);
public static readonly BindableProperty sliderNamePro =
BindableProperty.Create(SliderPropertyName, typeof(string), typeof(RangeSlider), "F0");
//public string LowerThumbImageValue
//{
//
get { return (string)GetValue(LowerThumbImageProperty); }
//
set { SetValue(LowerThumbImageProperty, value); }
//}
//public string UpperThumbImageValue
//{
//
get { return (string)GetValue(UpperThumbImageProperty); }
//
set { SetValue(UpperThumbImageProperty, value); }
//}
public Color ActiveColorValue
{
get { return (Color)GetValue(ActiveColorProperty); }
set { SetValue(ActiveColorProperty, value); }
}
public string SliderNameValue
{
get { return (string)GetValue(sliderNamePro); }
set { SetValue(sliderNamePro, value); }
}
public Color NormalColorValue
{
get { return (Color)GetValue(NormalColorProperty); }
set { SetValue(NormalColorProperty, value); }
}
public float MinimumValue
{
get { return (float)GetValue(MinimumValueProperty); }
set { SetValue(MinimumValueProperty, value); }
}
public float MaximumValue
{
get { return (float)GetValue(MaximumValueProperty); }
set { SetValue(MaximumValueProperty, value); }
}
public float LowerValue
{
get { return (float)GetValue(LowerValueProperty); }
set { SetValue(LowerValueProperty, value); }
}
public float UpperValue
{
get { return (float)GetValue(UpperValueProperty); }
set { SetValue(UpperValueProperty, value); }
}
public bool MinThumbHidden
{
get { return (bool)GetValue(MinThumbHiddenProperty); }
set { SetValue(MinThumbHiddenProperty, value); }
}
public bool MaxThumbHidden
{
get { return (bool)GetValue(MaxThumbHiddenProperty); }
set { SetValue(MaxThumbHiddenProperty, value); }
}
public float StepValue
{
get { return (float)GetValue(StepValueProperty); }
set { SetValue(StepValueProperty, value); }
}
public bool StepValueContinuously
{
get { return (bool)GetValue(StepValueContinuouslyProperty); }
set { SetValue(StepValueContinuouslyProperty, value); }
}
public int? BarHeight
{
get { return (int?)GetValue(BarHeightProperty); }
set { SetValue(BarHeightProperty, value); }
}
public bool ShowTextAboveThumbs
{
get { return (bool)GetValue(ShowTextAboveThumbsProperty); }
set { SetValue(ShowTextAboveThumbsProperty, value); }
}
[TypeConverter(typeof(FontSizeConverter))]
public double TextSize
{
get { return (double)GetValue(TextSizeProperty); }
set { SetValue(TextSizeProperty, value); }
}
public string TextFormat
{
get { return (string)GetValue(TextFormatProperty); }
set { SetValue(TextFormatProperty, value); }
}
public Func<Thumb, float, string> FormatLabel
{
get { return (Func<Thumb, float, string>)GetValue(FormatLabelProperty); }
set { SetValue(FormatLabelProperty, value); }
}
public event EventHandler LowerValueChanged;
public event EventHandler UpperValueChanged;
public event EventHandler DragStarted;
public event EventHandler DragCompleted;
public void OnLowerValueChanged(float value)
{
LowerValue = value;
LowerValueChanged?.Invoke(this, EventArgs.Empty);
}
public void OnUpperValueChanged(float value)
{
UpperValue = value;
UpperValueChanged?.Invoke(this, EventArgs.Empty);
}
public void OnDragStarted()
{
DragStarted?.Invoke(this, EventArgs.Empty);
}
public void OnDragCompleted()
{
DragCompleted?.Invoke(this, EventArgs.Empty);
}
}
}