/// <summary> /// Processes the node. /// </summary> /// <param name="sourceListItem">The source list item.</param> /// <param name="item">The item.</param> /// <remarks> /// Pass the ith item of the IList along with the SourceListSet. Use NodeReflectionStrategy.GetItemAt() function for better usage. /// </remarks> public void AddNode(SourceListSetEntry sourceListItem, object item) { if (sourceListItem.nodeInfoCollection.Find(delegate(NodeInfo nInfo) { return(item.Equals(nInfo.ObjectInstance)); }) == null) { NodeClassInfo nodeClassInfo = NodeReflectionStrategy.GetNodeClassInfo(item); Node node = GenerateNode(item, nodeClassInfo); if (node != null) { //Add the node to the diagram model. AddToDiagramModel((Node)node); //Add to NodeInfoCollection sourceListItem.nodeInfoCollection.Add(new NodeInfo(nodeClassInfo.ClassType, (Node)node, item)); if (_diagramEngine.IsNodeAddedEventListening) { //Raise the event. We can customize the look and feel of the nodes in the event listener code. _diagramEngine.RaiseNodeAddedEvent(new NodeAddedEventArgs(sourceListItem.SourceName, (Node)node)); } foreach (NodeRelationDescriptor nodeRelation in this._diagramEngine.IterateNodeRelationOfSourceListSetItem(sourceListItem)) { //Provide ChildSourceList's objects to iterate and connect. this._diagramEngine.AddConnection(nodeRelation, item); } } } }
/// <summary> /// Resolves the node based on the Attribute values specified dynamically. /// </summary> /// <param name="item">The item.</param> /// <param name="nodeClassInfo">The node class info.</param> /// <returns></returns> internal Node GenerateNode(object item, NodeClassInfo nodeClassInfo) { if (nodeClassInfo != null) { //Generate Node based on the NodeClassInfo and Append it to the Diagram Model NodeTypeAttribute nodeTypeAttr = nodeClassInfo.GetNodeTypeAttribute(); /*if ( !nodeTypeAttr.IsGroupNode ) * {*/ object node = GenerateNode(nodeTypeAttr.NodeType, nodeTypeAttr.Dimensions); foreach (NodePropInfo pInfo in nodeClassInfo.NodePropertyInfoCollection) { NodeAttributeAttribute nAttr = pInfo.GetCustomAttribute(); if (nAttr.VisibilityType == VisibleType.Label) { //Add labels to node type. Get the value from the IList item and then add a label. string lblText = item.GetType().GetProperty(pInfo.PropertyName).GetValue(item, null).ToString(); if (lblText != "") { AddLabel(node, lblText); } } } /* } * else * { * ConstructorInfo cInfo = nodeTypeAttr.NodeType.GetConstructor( Type.EmptyTypes ); * //Invoke the default constructor * node = cInfo.Invoke( new object[0] ); * if ( nodeTypeAttr.NodeRectangleF.Length == 4 ) * { * ( ( Group )node ).PinPoint = new PointF( nodeTypeAttr.NodeRectangleF[0], nodeTypeAttr.NodeRectangleF[1] ); * ( ( Group )node ).Size = new SizeF( nodeTypeAttr.NodeRectangleF[2], nodeTypeAttr.NodeRectangleF[3] ); * } * else * { * ( ( Group )node ).PinPoint = new PointF( 0, 0 ); * ( ( Group )node ).Size = new SizeF( 100, 100 ); * } * * foreach ( NodePropInfo pInfo in nodeClassInfo.NodePropertyInfoCollection ) * { * NodeAttributeAttribute nAttr = pInfo.GetCustomAttribute( ); * if ( nAttr.VisibilityType == VisibleType.Node ) * { * //add node to the Group collection * object childNode = GenerateNode( nAttr.NodeType, nAttr.NodeRectangleF ); * //add the node to the Group object * ( ( Group )node ).AppendChild( ( Node )childNode ); * } * } * }*/ return((Node)node); } return(null); }