/// <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> /// 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> /// Initializes a new instance of the <see cref="DiagramDataBindingManager"/> /// </summary> /// <param name="diagram">The diagram.</param> public DiagramDataBindingManager(Syncfusion.Windows.Forms.Diagram.Controls.Diagram diagram) { _sourceListSetColl = new SourceListSetCollection(this); nodeReflectionStrategy = new NodeReflectionStrategy(); //Initialize NodeRelationCollection and hook it to listen any new node relations added to the Diagram. nodeRelationCollection = new NodeRelationCollection(this); nodeRelationCollection.NodeRelationCollectionChanged += new NodeRelationCollectionChangedEventHandler(nodeRelationCollection_NodeRelationCollectionChanged); HookUpDiagram(diagram); }
private bool CheckItemInCollection(SourceListSetEntry source, object Obj) { bool result = false; foreach (object o in NodeReflectionStrategy.IterateListSource(source)) { if (o.Equals(Obj)) { result = true; break; } } return(result); }
void item_ListChanged(object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.ItemAdded) { SourceListSetEntry sourceListSet = GetSourceListSetFromList((IList)sender); if (sourceListSet != null) { AddNode(sourceListSet, NodeReflectionStrategy.GetItemAt((IList)sender, e.NewIndex)); } } /* * else if ( e.ListChangedType == ListChangedType.ItemDeleted ) * { * SourceListSet sourceListSet = GetSourceListSetFromList( ( IList )sender ); * if ( sourceListSet != null ) * { * RemoveNode( sourceListSet, NodeReflectionStrategy.GetItemAt( ( IList )sender, e.NewIndex ) ); * } * }*/ this._diagramEngine.Diagram.Refresh(); }
/// <summary> /// Resolves all the node present in the SourceListSet. /// </summary> /// <param name="item">The item.</param> internal void ResolveNodes(SourceListSetEntry item) { if (_sourceListSetColl.Contains(item)) { this._diagramEngine.Diagram.BeginUpdate(); //Loop thru each object that is present inside the IList of SourceListSet. foreach (object itemObj in NodeReflectionStrategy.IterateListSource(item)) { AddNode(item, itemObj); } //this._diagramEngine.RefreshLayoutManager( ); this._diagramEngine.Diagram.EndUpdate(); if (item.Source is System.ComponentModel.IBindingList) { WireBindingList((IBindingList)item.Source); } } else { throw new ArgumentException("Unknown SourceListSet instance"); } }