46 lines
1 KiB
C#
46 lines
1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Data;
|
|
|
|
namespace DjRedo.Converters
|
|
{
|
|
public class PercentToDegree : IValueConverter
|
|
{
|
|
/// <inheritdoc />
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value is float i)
|
|
{
|
|
return ClampPercent(i) * 3.6;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
private int ClampPercent(float value)
|
|
{
|
|
if (value >= 100)
|
|
{
|
|
return 100;
|
|
}
|
|
else if (value <= 0)
|
|
{
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
return (int)value;
|
|
}
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|