Fix old version volume exception #1653
Some checks are pending
MSBuild / build (push) Waiting to run
MSBuild / publish (push) Blocked by required conditions

This commit is contained in:
ema
2025-06-02 13:17:41 +08:00
parent d18b33a18e
commit 8b6ab6b037

View File

@@ -53,16 +53,17 @@ public sealed class VolumeToIconConverter : DependencyObject, IValueConverter
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return Volumes[0];
if (value is double v)
{
// Clump to range [0, 1]
v = Math.Max(0d, Math.Min(v, 1d));
var v = (double)value;
if (Math.Abs(v) < 0.01)
return Volumes[0];
if (v < 0.01d) return Volumes[0];
v = Math.Min(v, 1);
return Volumes[1 + (int)(v / 0.34d)];
}
return Volumes[1 + (int)(v / 0.34)];
return Volumes[0];
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)