private TreeNodeDesigner CreateDesigner(object o) { if (o == null) { return(null); } TreeNodeDesigner des = o as TreeNodeDesigner; if (des == null) { var attr = o.GetType().GetCustomAttributes(typeof(DesignerAttribute), true); if (attr.Length > 0) { var desType = Type.GetType( ((DesignerAttribute)attr[0]).DesignerTypeName, true); des = (TreeNodeDesigner)Activator.CreateInstance(desType); } else { des = new TreeNodeDesigner(); } } mpitemToDesigner[o] = des; return(des); }
private ITreeNode CreateTreeNode(object o, TreeNodeDesigner des, TreeNodeDesigner?parentDes) { var node = tree.CreateNode(); node.Tag = des; node.Expand(); des.Services = Services; des.Host = this; des.TreeNode = node; des.Component = o; des.Parent = parentDes; des.Initialize(o); return(node); }
public void AddComponents(object parent, IEnumerable components) { TreeNodeDesigner parentDes = GetDesigner(parent); if (parentDes == null) { Debug.Print("No designer for parent object {0}", parent ?? "(null)"); AddComponents(components); return; } var nodes = components .Cast <object>() .Select(o => CreateTreeNode(o, CreateDesigner(o), parentDes)); parentDes.TreeNode.Nodes.AddRange(nodes); }
private TreeNodeDesigner?CreateDesigner(object?o) { if (o == null) { return(null); } if (o is TreeNodeDesigner des) { if (des.Component != null) { o = des.Component; } } else { var attr = o.GetType().GetCustomAttributes(typeof(DesignerAttribute), true); if (attr.Length > 0) { var svc = Services.RequireService <IPluginLoaderService>(); try { var desType = svc.GetType( ((DesignerAttribute)attr[0]).DesignerTypeName); if (desType != null) { des = (TreeNodeDesigner)Activator.CreateInstance(desType); } else { des = new TreeNodeDesigner(); } } catch { des = new TreeNodeDesigner(); } } else { des = new TreeNodeDesigner(); } } mpitemToDesigner[o] = des; return(des); }
private TreeNodeDesigner?CreateDesigner(object?o) { if (o == null) { return(null); } if (o is TreeNodeDesigner des) { if (des.Component != null) { o = des.Component; } } else { var attr = o.GetType().GetCustomAttributes(typeof(DesignerAttribute), true); if (attr.Length > 0) { var desType = Type.GetType( ((DesignerAttribute)attr[0]).DesignerTypeName, false); if (desType != null) { des = (TreeNodeDesigner)Activator.CreateInstance(desType); } else { des = new TreeNodeDesigner(); } } else { des = new TreeNodeDesigner(); } } mpitemToDesigner[o] = des; return(des); }