1
I have a Circle preview in my wpf project, I’m using a class to convert the value 360 to 100, to look like it’s 100%, but I have a problem, I get an X time, and the 100% of the circle has to be filled in time X; If X=120 seconds, then the circle has to be filled in 120 seconds. I don’t know how to do it. I use a Timespan to do the time count:
public partial class TempoEtapa : UserControl
{
public static DispatcherTimer Temporizador = new DispatcherTimer();
public TempoEtapa()
{
InitializeComponent();
Temporizador.Tick += new EventHandler(DispatcherTimer_Tick);
Temporizador.Interval = new TimeSpan(0, 0, 1);
}
private void DispatcherTimer_Tick(object sender, EventArgs e)
{
Valor = 0;
if (Value == 120)
{
Valor = 0;
}
else
{
Valor = Value + 1;
}
SetValue(ValueProperty, Valor);
}
//Code that converts 360 to 100
[ValueConversion(typeof(int), typeof(double))]
public class Valor : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (double)((int)value * 0.01) * 360;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return (int)((double)value / 360) * 100;
}
}