初始化 monorepo: Go后端(7微服务) + Unity客户端(9模块) + 启动器 HTML5原型: Three.js 3D体素世界, Perlin噪声地形, 原版材质, 22种方块 Minecraft创造模式背包: 双栏布局, 拖拽移动物品, 方向性元件引脚 AI助搭策划文档 + 客户端/服务端骨架 + Docker Compose + CI
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using PCL.Core.UI.Animation.Easings;
|
||||
|
||||
namespace PCL.Core.UI.Converters;
|
||||
|
||||
public class EasingConverter : TypeConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType) =>
|
||||
sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
|
||||
|
||||
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) =>
|
||||
destinationType == typeof(string) || base.CanConvertTo(context, destinationType);
|
||||
|
||||
public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
|
||||
{
|
||||
if (value is string s)
|
||||
{
|
||||
return s switch
|
||||
{
|
||||
"BackEaseIn" => new BackEaseIn(),
|
||||
"BackEaseOut" => new BackEaseOut(),
|
||||
"BackEaseInOut" => new BackEaseInOut(),
|
||||
"BounceEaseIn" => new BounceEaseIn(),
|
||||
"BounceEaseOut" => new BounceEaseOut(),
|
||||
"BounceEaseInOut" => new BounceEaseInOut(),
|
||||
"CircularEaseIn" => new CircularEaseIn(),
|
||||
"CircularEaseOut" => new CircularEaseOut(),
|
||||
"CircularEaseInOut" => new CircularEaseInOut(),
|
||||
"CubicEaseIn" => new CubicEaseIn(),
|
||||
"CubicEaseOut" => new CubicEaseOut(),
|
||||
"CubicEaseInOut" => new CubicEaseInOut(),
|
||||
"ElasticEaseIn" => new ElasticEaseIn(),
|
||||
"ElasticEaseOut" => new ElasticEaseOut(),
|
||||
"ElasticEaseInOut" => new ElasticEaseInOut(),
|
||||
"ExponentialEaseIn" => new ExponentialEaseIn(),
|
||||
"ExponentialEaseOut" => new ExponentialEaseOut(),
|
||||
"ExponentialEaseInOut" => new ExponentialEaseInOut(),
|
||||
"LinearEasing" => new LinearEasing(),
|
||||
"QuadEaseIn" => new QuadEaseIn(),
|
||||
"QuadEaseOut" => new QuadEaseOut(),
|
||||
"QuadEaseInOut" => new QuadEaseInOut(),
|
||||
"QuarticEaseIn" => new QuarticEaseIn(),
|
||||
"QuarticEaseOut" => new QuarticEaseOut(),
|
||||
"QuarticEaseInOut" => new QuarticEaseInOut(),
|
||||
"QuinticEaseIn" => new QuinticEaseIn(),
|
||||
"QuinticEaseOut" => new QuinticEaseOut(),
|
||||
"QuinticEaseInOut" => new QuinticEaseInOut(),
|
||||
"SineEaseIn" => new SineEaseIn(),
|
||||
"SineEaseOut" => new SineEaseOut(),
|
||||
"SineEaseInOut" => new SineEaseInOut(),
|
||||
_ => throw new NotSupportedException($"不支持的缓动: {s}")
|
||||
};
|
||||
}
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
}
|
||||
|
||||
|
||||
public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string) && value is IEasing easing)
|
||||
{
|
||||
return easing switch
|
||||
{
|
||||
BackEaseIn => "BackEaseIn",
|
||||
BackEaseOut => "BackEaseOut",
|
||||
BackEaseInOut => "BackEaseInOut",
|
||||
BounceEaseIn => "BounceEaseIn",
|
||||
BounceEaseOut => "BounceEaseOut",
|
||||
BounceEaseInOut => "BounceEaseInOut",
|
||||
CircularEaseIn => "CircularEaseIn",
|
||||
CircularEaseOut => "CircularEaseOut",
|
||||
CircularEaseInOut => "CircularEaseInOut",
|
||||
CubicEaseIn => "CubicEaseIn",
|
||||
CubicEaseOut => "CubicEaseOut",
|
||||
CubicEaseInOut => "CubicEaseInOut",
|
||||
ElasticEaseIn => "ElasticEaseIn",
|
||||
ElasticEaseOut => "ElasticEaseOut",
|
||||
ElasticEaseInOut => "ElasticEaseInOut",
|
||||
ExponentialEaseIn => "ExponentialEaseIn",
|
||||
ExponentialEaseOut => "ExponentialEaseOut",
|
||||
ExponentialEaseInOut => "ExponentialEaseInOut",
|
||||
LinearEasing => "LinearEasing",
|
||||
QuadEaseIn => "QuadEaseIn",
|
||||
QuadEaseOut => "QuadEaseOut",
|
||||
QuadEaseInOut => "QuadEaseInOut",
|
||||
QuarticEaseIn => "QuarticEaseIn",
|
||||
QuarticEaseOut => "QuarticEaseOut",
|
||||
QuarticEaseInOut => "QuarticEaseInOut",
|
||||
QuinticEaseIn => "QuinticEaseIn",
|
||||
QuinticEaseOut => "QuinticEaseOut",
|
||||
QuinticEaseInOut => "QuinticEaseInOut",
|
||||
SineEaseIn => "SineEaseIn",
|
||||
SineEaseOut => "SineEaseOut",
|
||||
SineEaseInOut => "SineEaseInOut",
|
||||
_ => throw new NotSupportedException($"不支持的缓动: {easing.GetType().Name}")
|
||||
};
|
||||
}
|
||||
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
|
||||
namespace PCL.Core.UI.Converters;
|
||||
|
||||
public class NColorConverter : TypeConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)
|
||||
=> sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
|
||||
|
||||
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) =>
|
||||
destinationType == typeof(string) || base.CanConvertTo(context, destinationType);
|
||||
|
||||
public override object? ConvertFrom(ITypeDescriptorContext? context, CultureInfo? culture, object value)
|
||||
{
|
||||
if (value is string s)
|
||||
{
|
||||
return new NColor(s);
|
||||
}
|
||||
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
}
|
||||
|
||||
public override object? ConvertTo(ITypeDescriptorContext? context, CultureInfo? culture, object? value, Type destinationType)
|
||||
{
|
||||
if (value is NColor color && destinationType == typeof(string))
|
||||
{
|
||||
return $"#{color.R:X2}{color.G:X2}{color.B:X2}{color.A:X2}";
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace PCL.Core.UI.Converters;
|
||||
|
||||
/// <summary>
|
||||
/// 将可 null 的值转换为 WPF Visibility 状态:若为 null 则折叠,否则可见
|
||||
/// </summary>
|
||||
public sealed class NullToVisibilityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
return value is not null ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user