You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.4 KiB
C#

1 month ago
using System;
using System.ComponentModel;
using System.Globalization;
using GeoSigma.SigmaDrawerStyle;
using GeoSigma.SigmaDrawerStyle.Converter;
namespace GeoSigma.SigmaDrawerElement.Converter
{
/// <summary>
/// 字体 Converter
/// </summary>
public class WellFontExConverter : BaseTypeConverter
{
/// <inheritdoc/>
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof(string) || base.CanConvertTo(context, destinationType);
}
/// <inheritdoc/>
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture,
object value, Type destinationType)
{
if (destinationType == typeof(string) && value is WellFontEx font)
{
return $"{font.FontName}";
}
return base.ConvertTo(context, culture, value, destinationType);
}
/// <inheritdoc/>
public override bool GetPropertiesSupported(ITypeDescriptorContext context)
{
return true;
}
/// <inheritdoc/>
public override PropertyDescriptorCollection GetProperties(
ITypeDescriptorContext context,
object value, Attribute[] attributes)
{
return TypeDescriptor.GetProperties(typeof(WellFontEx), attributes);
}
}
}