/// <summary> /// Removes the node from connector. /// </summary> /// <param name="nodeRelation">The node relation.</param> /// <param name="nodeObj">The node obj.</param> /// <remarks> /// If the Connector is removed at both ends it would be automatically removed from the inner collection. /// </remarks> public void RemoveNodeFromConnector(NodeRelationDescriptor nodeRelation, object nodeObj) { if (CheckItemInCollection(this.SourceListSet[nodeRelation.ChildSourceName], nodeObj)) { Node childNode = GetChildNodeFromSourceListSet(this.SourceListSet[nodeRelation.ChildSourceName], nodeObj); IGraphNode tNode = childNode as IGraphNode; if (tNode != null) { foreach (ConnectorBase connector in IterateEdges(childNode, tNode.EdgesEntering)) { Diagram.Model.RemoveChild(connector); nodeRelation.nodeConnections.Remove(connector); } foreach (ConnectorBase connector in IterateEdges(childNode, tNode.EdgesLeaving)) { Diagram.Model.RemoveChild(connector); nodeRelation.nodeConnections.Remove(connector); } } } else { throw new ArgumentException("object passed is not an instance of " + this.SourceListSet[nodeRelation.ChildSourceName].SourceName); } }
private void ProcessConnection(NodeRelationDescriptor nodeRelation, SourceListSetEntry childSourceList, SourceListSetEntry parentSourceList, object item) { ConnectorBase connector = null; Node parentNode = GetParentNodeFromSourceListSet(parentSourceList, item, nodeRelation.ChildID, nodeRelation.ParentID); Node childNode = GetChildNodeFromSourceListSet(childSourceList, item); if (parentNode != null && childNode != null && !CheckParentAndChildNodeAlreadyConnected(parentNode, childNode)) { if (!isNodeConnectStyleListening) { //Connect nodes connector = ConnectNodes(parentNode, childNode); } else { //Raise the event to customize the connectors connector = RaiseQueryNodeConnectorStyleInfoHandler(nodeRelation, parentNode, childNode); } } //Append the Connector to the DiagramModel. if (connector != null) { Diagram.Model.AppendChild(connector); Diagram.Model.SendToBack(connector); nodeRelation.nodeConnections.Add(connector); } }
/// <summary> /// Connects the parent node and child node based on the node relation. Iterates all the nodes present in the NodeRelation and connects it. /// </summary> internal void ResolveNodeRelations(string relationName) { NodeRelationDescriptor nodeRelation = this.nodeRelationCollection[relationName]; if (nodeRelation != null) { //Ensure that the IList is present with the ChildSourceName if (this.SourceListSet[nodeRelation.ChildSourceName] != null) { Diagram.BeginUpdate(); //Iterate thru the ChildSourceList and process the connections foreach (object item in NodeReflectionStrategy.IterateListSource(this.SourceListSet[nodeRelation.ChildSourceName])) { AddConnection(nodeRelation, item); } Diagram.EndUpdate(); } else { throw new ArgumentException("object passed is not an instance of " + this.SourceListSet[nodeRelation.ChildSourceName].SourceName); } } }
/// <summary> /// Processes the connection. /// </summary> /// <param name="nodeRelation">The node relation.</param> /// <param name="listItem">The item present in the IList provided as source.</param> internal void AddConnection(NodeRelationDescriptor nodeRelation, object listItem) { if (CheckItemInCollection(this.SourceListSet[nodeRelation.ChildSourceName], listItem)) { if (nodeRelation.RelationType == RelationType.ParentChild) { SourceListSetEntry childSourceList = this.SourceListSet[nodeRelation.ChildSourceName]; SourceListSetEntry parentSourceList = this.SourceListSet[nodeRelation.ParentSourceName]; ProcessConnection(nodeRelation, childSourceList, parentSourceList, listItem); } else if (nodeRelation.RelationType == RelationType.SelfRelation) { //if the RelationType is a SelfRelation one, it will take the SourceListSet based on the ChildSourceName of the NodeRelation. SourceListSetEntry sourceList = this.SourceListSet[nodeRelation.ChildSourceName]; ProcessConnection(nodeRelation, sourceList, sourceList, listItem); } } else { throw new ArgumentException("object passed is not an instance of " + this.SourceListSet[nodeRelation.ChildSourceName].SourceName); } }
/// <summary> /// Initializes a new instance of the <see cref="NodeConnectEventArgs"/> [ERROR: invalid expression DeclaringTypeKind]. /// </summary> /// <param name="nodeRelation">The node relation.</param> /// <param name="parentNode">The parent node.</param> /// <param name="childNode">The child node.</param> public NodeConnectEventArgs(NodeRelationDescriptor nodeRelation, Node parentNode, Node childNode) { this._nodeRelation = nodeRelation; this._parentNode = parentNode; this._childNode = childNode; }
/// <summary> /// Initializes a new instance of the <see cref="NodeRelationEventArgs"/> /// </summary> /// <param name="relation">Name of the relation.</param> /// <param name="collectionChangedType">Type of the collection changed.</param> public NodeRelationEventArgs(NodeRelationDescriptor relation, CollectionChangedType collectionChangedType) { _relation = relation; _collectionChangedType = collectionChangedType; }
/// <summary> /// Raises the query node connector style info handler. /// </summary> /// <param name="nodeRelation">The node relation.</param> /// <param name="parentNode">The parent node.</param> /// <param name="childNode">The child node.</param> private ConnectorBase RaiseQueryNodeConnectorStyleInfoHandler(NodeRelationDescriptor nodeRelation, Node parentNode, Node childNode) { //raise the event to customize the connectors. return(RaiseNodeConnectStyleInfo(new NodeConnectEventArgs(nodeRelation, parentNode, childNode))); }