Logic Problem with Progress Circle

1

I have a progress circle in my wpf project, I am using a class to convert the 360 value to 100, to stay as if it were 100%, but I have a problem, I get a X time, and 100% of the circle has that be filled in time X; If X = 120 seconds, then the circle has to be filled in 120 seconds. I do not know how to do. I use a TimeSpan to do the time counting:

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 converting 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;
    }
}
    
asked by anonymous 06.08.2018 / 16:24

1 answer

0

I found the solution. I stopped using the Converter; using the 360 ° of the circle I just divide 360 by X and increment the angle value from that result.

    
06.08.2018 / 19:16