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 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 list; if (context.Instance is ViewSurface surface) list = surface.NameList; else list = null; return new StandardValuesCollection(list); } } } }