千问写完触发器功能,错误未修复

This commit is contained in:
2025-09-14 16:16:10 +08:00
parent 25cd43d436
commit a079cf8de8
24 changed files with 1684 additions and 6 deletions

View File

@@ -0,0 +1,29 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace DMS.WPF.Converters
{
/// <summary>
/// 枚举到可见性转换器。当绑定的枚举值等于 ConverterParameter 时,返回 Visible否则返回 Collapsed。
/// </summary>
public class EnumToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null || parameter == null)
return Visibility.Collapsed;
string enumValue = value.ToString();
string targetValue = parameter.ToString();
return enumValue.Equals(targetValue, StringComparison.OrdinalIgnoreCase) ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Globalization;
using System.Windows.Data;
namespace DMS.WPF.Converters
{
/// <summary>
/// 可空 TimeSpan 到秒数字符串的双向转换器。
/// 用于在 TextBox 和 TimeSpan? 之间进行转换。
/// </summary>
public class NullableTimeSpanToSecondsConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is TimeSpan timeSpan)
{
return timeSpan.TotalSeconds.ToString(CultureInfo.InvariantCulture);
}
return "";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string str && !string.IsNullOrWhiteSpace(str))
{
if (double.TryParse(str, NumberStyles.Float, CultureInfo.InvariantCulture, out double seconds))
{
return TimeSpan.FromSeconds(seconds);
}
}
return null; // Return null for invalid or empty input
}
}
}