添加项目文件。
This commit is contained in:
49
UIShare/Converters/DeviceNameConverter.cs
Normal file
49
UIShare/Converters/DeviceNameConverter.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace UIShare.Converters
|
||||
{
|
||||
public class DeviceNameConverter : IValueConverter
|
||||
{
|
||||
private readonly string[] specialName = { "奇偶" };
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is string name)
|
||||
{
|
||||
if (specialName.Contains(name))
|
||||
{
|
||||
if (parameter?.ToString() == "Inverse")
|
||||
{
|
||||
return Visibility.Visible;
|
||||
}
|
||||
else if (parameter?.ToString() == "Items")
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "奇偶":
|
||||
return new List<string> { "无", "奇", "偶" };
|
||||
}
|
||||
}
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
if (parameter?.ToString() == "Inverse")
|
||||
{
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
return Visibility.Visible;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user