兼容win7版应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.4 KiB

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
{
/// <summary>
/// 转换逻辑:进度>0且<100 → 显示发光条;否则隐藏
/// </summary>
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;
}
/// <summary>
/// 反向转换(无需实现)
/// </summary>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException("无需反向转换");
}
}
}