public NodeData(string typeName, string name) { _typeName = typeName; _name = name; _iconType = MetaClassDescriptor.GetIcon(typeName); InitPropertyGridData(typeName); }
private void UpdateMetaClasses(int dllHandle, string getCountMetho, string getInfoMetho) { Tuple <Delegate, Delegate> delegates = GetDelegate <Win32.GetMetaClassCountDelegate, Win32.GetMetaClassesDelegate>(dllHandle, getCountMetho, getInfoMetho); int count = (delegates.Item1 as Win32.GetMetaClassCountDelegate)(); CClassInfo[] metaDatas = new CClassInfo[count]; _metaClasses.Clear(); int size = Marshal.SizeOf(typeof(CClassInfo)) * count; IntPtr buffer = Marshal.AllocHGlobal(size); (delegates.Item2 as Win32.GetMetaClassesDelegate)(buffer, count); for (int i = 0; i < count; ++i) { IntPtr p = new IntPtr(buffer.ToInt64() + Marshal.SizeOf(typeof(CClassInfo)) * i); metaDatas[i] = (CClassInfo)Marshal.PtrToStructure(p, typeof(CClassInfo)); var classDescriptor = new MetaClassDescriptor(metaDatas[i].TypeName, metaDatas[i].Category, metaDatas[i].DisplayName, metaDatas[i].Description, MetaClassDescriptor.GetIcon(metaDatas[i].TypeName)); var properties = new List <MetaPropertyDescriptor>(); foreach (var pd in metaDatas[i].PropertyData) { //如果ID为0表示这个属性信息为空 if (pd.TypeID != 0) { var enumSource = pd.EnumSource.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); var x = MetaPropertyDescriptor.GetTupleInfo(pd.ValueTypeName, enumSource); if (x == null) { ViewModel.LogData.Add(LogLevel.Warn, "元件{0}的属性{1}使用了不支持的C++属性类型{2}", classDescriptor.TypeName, pd.DisplayName, pd.ValueTypeName); continue; } properties.Add(new MetaPropertyDescriptor(pd.ValueTypeName, pd.TypeID, pd.Category, pd.DisplayName, pd.Order, pd.Description, enumSource, x.Item1, x.Item2, x.Item3)); } } _metaClasses.Add(new MetaClass(classDescriptor, properties)); } Marshal.FreeHGlobal(buffer); }