Files
wg_cpso/RBFMorphing/ViewSurface.cs
2026-03-25 18:20:24 +08:00

61 lines
1.6 KiB
C#

using CaeMesh;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
namespace RBFMorphing
{
public class ViewSurface
{
private readonly FeMesh _mesh;
public ViewSurface(FeMesh mesh)
{
_mesh = mesh;
}
[Category("面集合")]
[DisplayName("名称")]
[Description("指定面集合名称")]
[TypeConverter(typeof(NameListConverter))]
public string Name { get; set; }
[Browsable(false)]
public List<string> NameList
{
get
{
if (_mesh != null && _mesh.Surfaces.Count > 0)
{
return _mesh.Surfaces
.Select(pair => pair.Value)
.Where(s => !s.Internal)
.Select(s => s.Name)
.OrderBy(x => x)
.ToList();
}
return null;
}
}
class NameListConverter : TypeConverter
{
public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
{
return true;
}
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
List<string> list;
if (context.Instance is ViewSurface surface)
list = surface.NameList;
else
list = null;
return new StandardValuesCollection(list);
}
}
}
}