修改命名

This commit is contained in:
ww-rm
2025-03-05 16:24:19 +08:00
parent 20953c2dfc
commit eb44c1271e
4 changed files with 9 additions and 53 deletions

View File

@@ -24,11 +24,11 @@ namespace SpineViewer.Controls
public PreviewerProperty(SpinePreviewer previewer) { this.previewer = previewer; }
[TypeConverter(typeof(SizeTypeConverter))]
[TypeConverter(typeof(SizeConverter))]
[Category("导出"), DisplayName("分辨率")]
public Size Resolution { get => previewer.Resolution; set => previewer.Resolution = value; }
[TypeConverter(typeof(PointFTypeConverter))]
[TypeConverter(typeof(PointFConverter))]
[Category("导出"), DisplayName("画面中心点")]
public PointF Center { get => previewer.Center; set => previewer.Center = value; }

View File

@@ -136,7 +136,7 @@ namespace SpineViewer.Spine
/// <summary>
/// 获取所属版本
/// </summary>
[TypeConverter(typeof(VersionTypeConverter))]
[TypeConverter(typeof(VersionConverter))]
[Category("基本信息"), DisplayName("版本")]
public Version Version { get; }
@@ -164,7 +164,7 @@ namespace SpineViewer.Spine
/// <summary>
/// 位置
/// </summary>
[TypeConverter(typeof(PointFTypeConverter))]
[TypeConverter(typeof(PointFConverter))]
[Category("变换"), DisplayName("位置")]
public abstract PointF Position { get; set; }
@@ -202,7 +202,7 @@ namespace SpineViewer.Spine
/// <summary>
/// 当前动画名称
/// </summary>
[TypeConverter(typeof(AnimationTypeConverter))]
[TypeConverter(typeof(AnimationConverter))]
[Category("动画"), DisplayName("当前动画")]
public abstract string CurrentAnimation { get; set; }

View File

@@ -9,9 +9,9 @@ using System.Threading.Tasks;
namespace SpineViewer.Spine
{
public class VersionTypeConverter : EnumConverter
public class VersionConverter : EnumConverter
{
public VersionTypeConverter() : base(typeof(Version)) { }
public VersionConverter() : base(typeof(Version)) { }
public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type? destinationType)
{
@@ -25,7 +25,7 @@ namespace SpineViewer.Spine
}
}
public class AnimationTypeConverter : StringConverter
public class AnimationConverter : StringConverter
{
public override bool GetStandardValuesSupported(ITypeDescriptorContext? context)
{

View File

@@ -9,7 +9,7 @@ using System.Threading.Tasks;
namespace SpineViewer
{
public class PointFTypeConverter : ExpandableObjectConverter
public class PointFConverter : ExpandableObjectConverter
{
public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(true)] Type? destinationType)
{
@@ -52,48 +52,4 @@ namespace SpineViewer
public override bool GetPropertiesSupported(ITypeDescriptorContext? context) => true;
}
public class SizeTypeConverter : ExpandableObjectConverter
{
public override bool CanConvertTo(ITypeDescriptorContext? context, [NotNullWhen(true)] Type? destinationType)
{
return destinationType == typeof(string) || base.CanConvertTo(context, destinationType);
}
public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
{
if (destinationType == typeof(string) && value is Size size)
{
return $"{size.Width}, {size.Height}";
}
return base.ConvertTo(context, culture, value, destinationType);
}
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
{
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
}
public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
{
if (value is string str)
{
var parts = str.Split(',');
if (parts.Length == 2 &&
int.TryParse(parts[0], out var width) &&
int.TryParse(parts[1], out var height))
{
return new Size(width, height);
}
}
return base.ConvertFrom(context, culture, value);
}
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext? context, object value, Attribute[]? attributes)
{
return TypeDescriptor.GetProperties(typeof(Size), attributes);
}
public override bool GetPropertiesSupported(ITypeDescriptorContext? context) => true;
}
}