using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; namespace AIK.Views.Converters { public class ProgressToGlowVisibilityConverter : IValueConverter { /// /// 转换逻辑:进度>0且<100 → 显示发光条;否则隐藏 /// public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { // 1. 校验进度值类型 if (!(value is double progressValue)) { return Visibility.Collapsed; } // 2. 校验是否为ProgressBar(可选:处理Indeterminate状态) if (parameter is ProgressBar progressBar && progressBar.IsIndeterminate) { return Visibility.Collapsed; } // 3. 核心逻辑:进度在1~99之间显示发光条 return (progressValue > 0 && progressValue < 100) ? Visibility.Visible : Visibility.Collapsed; } /// /// 反向转换(无需实现) /// public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException("无需反向转换"); } } }