增加ResolutionConverter
This commit is contained in:
@@ -749,7 +749,7 @@ namespace SpineViewer.Controls
|
|||||||
public SpinePreviewPanel PreviewPanel { get; } = previewPanel;
|
public SpinePreviewPanel PreviewPanel { get; } = previewPanel;
|
||||||
|
|
||||||
[RefreshProperties(RefreshProperties.All)]
|
[RefreshProperties(RefreshProperties.All)]
|
||||||
[TypeConverter(typeof(SizeConverter))]
|
[TypeConverter(typeof(ResolutionConverter))]
|
||||||
[Category("[0] 导出"), DisplayName("分辨率")]
|
[Category("[0] 导出"), DisplayName("分辨率")]
|
||||||
public Size Resolution { get => PreviewPanel.Resolution; set => PreviewPanel.Resolution = value; }
|
public Size Resolution { get => PreviewPanel.Resolution; set => PreviewPanel.Resolution = value; }
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,8 @@ namespace SpineViewer.Utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private StandardValuesCollection standardValues;
|
||||||
|
|
||||||
public override bool GetStandardValuesSupported(ITypeDescriptorContext? context) => true;
|
public override bool GetStandardValuesSupported(ITypeDescriptorContext? context) => true;
|
||||||
|
|
||||||
public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
|
public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context)
|
||||||
@@ -88,16 +90,40 @@ namespace SpineViewer.Utils
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override StandardValuesCollection? GetStandardValues(ITypeDescriptorContext? context)
|
public override StandardValuesCollection? GetStandardValues(ITypeDescriptorContext? context)
|
||||||
|
{
|
||||||
|
if (standardValues is null)
|
||||||
{
|
{
|
||||||
// 查找属性上的 StandardValuesAttribute
|
// 查找属性上的 StandardValuesAttribute
|
||||||
var attribute = context?.PropertyDescriptor?.Attributes.OfType<StandardValuesAttribute>().FirstOrDefault();
|
var attribute = context?.PropertyDescriptor?.Attributes.OfType<StandardValuesAttribute>().FirstOrDefault();
|
||||||
StandardValuesCollection result;
|
|
||||||
if (attribute != null)
|
if (attribute != null)
|
||||||
result = new StandardValuesCollection(attribute.StandardValues);
|
standardValues = new StandardValuesCollection(attribute.StandardValues);
|
||||||
else
|
else
|
||||||
result = new StandardValuesCollection(Array.Empty<string>());
|
standardValues = new StandardValuesCollection(Array.Empty<string>());
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
return standardValues;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ResolutionConverter : SizeConverter
|
||||||
|
{
|
||||||
|
private static readonly StandardValuesCollection standardValues = new(new string[] {
|
||||||
|
"4096, 4096",
|
||||||
|
"2048, 2048",
|
||||||
|
"1024, 1024",
|
||||||
|
"512, 512",
|
||||||
|
"3840, 2160",
|
||||||
|
"2560, 1440",
|
||||||
|
"1920, 1080",
|
||||||
|
"1280, 720",
|
||||||
|
"2160, 3840",
|
||||||
|
"1440, 2560",
|
||||||
|
"1080, 1920",
|
||||||
|
"720, 1280",
|
||||||
|
});
|
||||||
|
|
||||||
|
public override bool GetStandardValuesSupported(ITypeDescriptorContext? context) => true;
|
||||||
|
public override bool GetStandardValuesExclusive(ITypeDescriptorContext? context) => false;
|
||||||
|
public override StandardValuesCollection? GetStandardValues(ITypeDescriptorContext? context) => standardValues;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SFMLColorConverter : ExpandableObjectConverter
|
public class SFMLColorConverter : ExpandableObjectConverter
|
||||||
|
|||||||
Reference in New Issue
Block a user