protected override void FillInList(ITypeDescriptorContext context, IServiceProvider provider, ListBox listBox) { //Note: ITypeDescriptorContext contains the Instance object // find out which mesh/package it was.... ObjectBaseProxy objProxy = (ObjectBaseProxy)context.Instance; PropertyContextData contextData = objProxy.contextData; ClassPropertyInfo packageProperty = contextData.context1.getPropertyValue("Model"); ObjectBase oo = packageProperty.mObject; if (oo != null && oo is Mesh) { Mesh m = (Mesh)oo; List <String> animList = new List <string>(); m.getAnimations(animList); foreach (string animName in animList) { listBox.Items.Add(animName); } } }
private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { currentNode = e.Node; if (e.Node.Tag is PackageInfo) { mPackageNode = e.Node; PackageInfo pinfo = (PackageInfo)e.Node.Tag; // Find the package... Package p = GodzUtil.FindPackage(pinfo.hash); if (p != null) { mSelectedPackage = p; } else { // Create the package. // Note/Bug: if the pack exists somewhere on the // hard drive and the user later loads that one // it will lose this object. mSelectedPackage = GodzUtil.AddPackage(pinfo.name, pinfo.type); } mTemplate = null; mValue = null; propertyGrid1.SelectedObject = null; } else if (e.Node.Tag is ObjectBase) { // Stores context information PropertyContextData contextData = null; ClassBase templateClass = ClassBase.findClass("ObjectTemplate"); ObjectBase obj = (ObjectBase)e.Node.Tag; if (obj.IsA(templateClass)) { mTemplate = (ObjectBase)e.Node.Tag; mTemplateNode = e.Node; mSelectedPackage = mTemplate.getPackage(); } else { mSelectedPackage = obj.getPackage(); //Set the 'Template' parent object as the context. This way //the property knows about it's parent Object TreeNode tnode = e.Node.Parent; while (tnode != null) { Object temp = tnode.Tag; if (temp is ObjectBase) { ObjectBase tempBase = (ObjectBase)temp; if (tempBase.IsA(templateClass)) { contextData = new PropertyContextData(); contextData.context1 = tempBase; break; } } tnode = tnode.Parent; } } //Debug.Assert(mSelectedPackage != null); object proxy = Editor.GetNewObjectProxy(obj); ObjectBaseProxy objProxy = (ObjectBaseProxy)proxy; objProxy.contextData = contextData; propertyGrid1.SelectedObject = proxy; mValue = null; } else if (e.Node.Tag is PropertyClassSelection) { PropertyClassSelection propertySelection = (PropertyClassSelection)e.Node.Tag; mSelectedPackage = propertySelection.obj.getPackage(); mValue = new PropertyGridValue(); //refresh the property propertySelection.cp = propertySelection.obj.getPropertyValue(propertySelection.cp.mName); if (propertySelection.cp.mPropertyType == ClassPropertyType.PropertyType_HashCode) { mValue.value = Editor.GetHashString(propertySelection.cp.mObjectHash); } else { mValue.value = propertySelection.cp.mText; } mValue.mPropertySelection = propertySelection; propertyGrid1.SelectedObject = mValue; } }