using CaeMesh; using System.Collections.Generic; using System.ComponentModel; using System.Linq; namespace RBFMorphing { public class ViewNodeSet { private readonly FeMesh _mesh; public ViewNodeSet(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.NodeSets.Count > 0) { return _mesh.NodeSets .Select(kvp => kvp.Value) .Where(n => !n.Internal) // 不显示内部节点集合 .Select(n => n.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; // ReSharper disable once SuspiciousTypeConversion.Global if (context.Instance is ViewNodeSet nodeSet) list = nodeSet.NameList; else list = null; return new StandardValuesCollection(list); } } } }