Logic problem with Progress Circle

Asked

Viewed 18 times

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;
    }
}

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.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.