public static void addConnectionText(DDTRelation rel, Netron.NetronLight.DDTConnection connection, Netron.NetronLight.Win.DiagramControl diagramControl) { string from = rel.text.from; string mid = rel.text.middle; string to = rel.text.to; connection.setText(from, mid, to); //add 3 text blocks if (connection.Tfrom != null || connection.Tfrom.Length>0) { ConnectionText ctfrom = new ConnectionText(connection, TextPosition.From); diagramControl.controller.Model.AddShape(ctfrom); } if (connection.Tmid != null || connection.Tmid.Length > 0) { ConnectionText ctmid = new ConnectionText(connection, TextPosition.Mid); diagramControl.controller.Model.AddShape(ctmid); } if (connection.Tto != null || connection.Tto.Length > 0) { ConnectionText ctto = new ConnectionText(connection, TextPosition.To); diagramControl.controller.Model.AddShape(ctto); } }
public static DDTProject createDDTProject() { List<DDT_Obj_Property> properties = new List<DDT_Obj_Property>(); properties.Add(new DDT_Obj_Property("p", "d", "v")); properties.Add(new DDT_Obj_Property("p1", "d1", "v1")); List<DDT_Obj_Event> events = new List<DDT_Obj_Event>(); events.Add(new DDT_Obj_Event("s","s")); events.Add(new DDT_Obj_Event("s1", "s1")); DDTObject o1 = new DDTObject(DDT_Obj_Type.ADT, "obj1",properties,events); DDTObject o2 = new DDTObject(DDT_Obj_Type.SMOBJECT, "obj2"); DDTObject o3 = new DDTObject(DDT_Obj_Type.DATASTORE, "obj3"); DDTObject o4 = new DDTObject(DDT_Obj_Type.TERMINATOR, "obj4"); DDTConnector from1 = new DDTConnector(1, 3); DDTConnector to1 = new DDTConnector(2, 1); DDTConnector from2 = new DDTConnector(3, 3); DDTConnector to2 = new DDTConnector(2, 3); DDTConnector from3 = new DDTConnector(1, 4); DDTConnector to3 = new DDTConnector(4, 1); DDTRelationTexts text1 = new DDTRelationTexts("1", "s", "s"); DDTRelation r1 = new DDTRelation(DDT_Rel_Type.ONETOMANY, from1, to1, text1); DDTRelation r2 = new DDTRelation(DDT_Rel_Type.WIDEARROW, from2, to2, null); DDTRelation r3 = new DDTRelation(DDT_Rel_Type.SINGLEARROW, from3, to3, null); List<DDTObjectReference> obl = new List<DDTObjectReference>(); obl.Add(new DDTObjectReference(1, new Point(100,100))); obl.Add(new DDTObjectReference(2, new Point(200, 300))); obl.Add(new DDTObjectReference(3, new Point(300, 200))); obl.Add(new DDTObjectReference(4, new Point(400, 400))); List<int> rel = new List<int>(); rel.Add(5); rel.Add(6); rel.Add(7); DDTDiagram diagram1 = new DDTDiagram("dia1", DDT_Diagram_Type.ERD, obl, rel); List<DDTDiagram> dia=new List<DDTDiagram>(); dia.Add(diagram1); List<DDTObject> obj = new List<DDTObject>(); obj.Add(o1); obj.Add(o2); obj.Add(o3); obj.Add(o4); List<DDTRelation> re = new List<DDTRelation>(); re.Add(r1); re.Add(r2); re.Add(r3); DDTProject proj = new DDTProject("pro1", dia,obj ,re); return proj; }
public DDTRelation deepClone() { DDTRelation newRel = new DDTRelation(type, this.from.clone(), this.to.clone(), this.text.clone()); newRel.diagramType = this.diagramType; newRel.parentDiagramID = this.parentDiagramID; return newRel; }
public void addRelation(DDTRelation rel) { this.relations.Add(rel); }
public static Netron.NetronLight.DDTConnection DDTRelationToCanvas(DDTRelation rel, Netron.NetronLight.Win.DiagramControl diagramControl) { Netron.NetronLight.DDTConnection connection; Netron.NetronLight.ConnectionType type; int fromId = rel.from.objectId; int toId = rel.to.objectId; int fromIndex; int toIndex; Netron.NetronLight.IDDTObject fromObj=null; Netron.NetronLight.IDDTObject toObj = null; IConnector fromConnector = null; IConnector toConnector = null; //get from and to objects foreach (Netron.NetronLight.IDDTDiagramEntity temp in diagramControl.controller.Model.Paintables) { if (temp.GetType().IsSubclassOf(typeof(Netron.NetronLight.IDDTObject))) { if (((Netron.NetronLight.IDDTObject)temp).ID == fromId && fromObj == null) { fromObj = ((Netron.NetronLight.IDDTObject)temp); } if (((Netron.NetronLight.IDDTObject)temp).ID == toId && toObj == null) { toObj = ((Netron.NetronLight.IDDTObject)temp); } if (fromObj != null && toObj != null) { break; } } } fromConnector = getConnector(rel, ConnectorOrientation.FROM, fromObj); toConnector = getConnector(rel, ConnectorOrientation.TO, toObj); switch (rel.from.pos) { case Conn_Position.LEFT: fromIndex = 1; break; case Conn_Position.TOP: fromIndex = 2; break; case Conn_Position.RIGHT: fromIndex = 3; break; case Conn_Position.BOTTOM: fromIndex = 4; break; default: fromIndex = 1; break; } switch (rel.to.pos) { case Conn_Position.LEFT: toIndex = 1; break; case Conn_Position.TOP: toIndex = 2; break; case Conn_Position.RIGHT: toIndex = 3; break; case Conn_Position.BOTTOM: toIndex = 4; break; default: toIndex = 1; break; } if (fromConnector == null || toConnector == null) { MessageBox.Show("DDTRelationToCanvas: the connection connects to a null DDTObject"); return null; } type = getType(rel); connection = new Netron.NetronLight.DDTConnection(fromConnector, toConnector, diagramControl.controller.Model, type); connection.fromId = fromId; connection.toId = toId; connection.ID = rel.ID; connection.fromConnectorIndex = fromIndex; connection.toConnectorIndex = toIndex; ///////////////////////// return connection; }
private static Netron.NetronLight.ConnectionType getType(DDTRelation rel) { Netron.NetronLight.ConnectionType type; switch (rel.type) { case DDT_Rel_Type.NORMAL: type = Netron.NetronLight.ConnectionType.NORMAL; break; case DDT_Rel_Type.SINGLEARROW: type = Netron.NetronLight.ConnectionType.SINGLEARROW; break; case DDT_Rel_Type.DOUBLEARROW: type = Netron.NetronLight.ConnectionType.DOUBLEARROW; break; case DDT_Rel_Type.ONETOONE: type = Netron.NetronLight.ConnectionType.ONETOONE; break; case DDT_Rel_Type.ONETOMANY: type = Netron.NetronLight.ConnectionType.ONETOMANY; break; case DDT_Rel_Type.MANYTOMANY: type = Netron.NetronLight.ConnectionType.MANYTOMANY; break; case DDT_Rel_Type.WIDEARROW: type = Netron.NetronLight.ConnectionType.WIDEARROW; break; case DDT_Rel_Type.DIAMONDARROW: type = Netron.NetronLight.ConnectionType.DIAMONDARROW; break; case DDT_Rel_Type.DASHEDARROW: type = Netron.NetronLight.ConnectionType.DASHEDARROW; break; default: type = Netron.NetronLight.ConnectionType.SINGLEARROW; break; } return type; }
private static IConnector getConnector(DDTRelation rel, ConnectorOrientation orientation, Netron.NetronLight.IDDTObject obj) { IConnector connector = null; Conn_Position temp; if (orientation == ConnectorOrientation.FROM) temp = rel.from.pos; else if (orientation == ConnectorOrientation.TO) temp = rel.to.pos; else return null; switch (temp) { case Conn_Position.LEFT: connector = obj.connectorA; break; case Conn_Position.TOP: connector = obj.connectorB; break; case Conn_Position.RIGHT: connector = obj.connectorC; break; case Conn_Position.BOTTOM: connector = obj.connectorD; break; default: connector = obj.connectorC; break; } return connector; }