diff --git a/Sources/Stim/DoubleToStar.cs b/Sources/Stim/DoubleToStar.cs new file mode 100644 index 0000000..eea0b8e --- /dev/null +++ b/Sources/Stim/DoubleToStar.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Stim +{ + public class DoubleToStar : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (parameter != null && parameter is string && !string.IsNullOrEmpty(parameter as string)) + { + string param = parameter as string; + double rate = double.Parse(param.Split('|')[0]); + int pos = int.Parse(param.Split('|')[0]); + + if (pos <= rate ) return "etoile_pleine.png"; + if (pos - 1 < rate && rate < pos) return "etoile_mi_plein.png"; + } + return "etoile_vide.png"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +}