public GraphConnector(int idConnector, GraphElement parent, Point position, GraphSide side) { this.idConnector = idConnector; this.parent = parent; this.side = side; this.Surface = new Surface(ElementGraphics.connectorGraphic); this.Center = position; this.Visible = false; }
public GraphElement Clone(List <GraphElement> elements, List <GraphElement> clonedElements, Hashtable element_clone) { //you get the previous element of the arrow GraphElement prevElement = (GraphElement)element_clone[this.Previous[0]]; if (prevElement == null) { prevElement = this.Previous[0].Clone(); clonedElements.Add(prevElement); element_clone.Add(this.Previous[0], prevElement); } //you get the next element of the arrow GraphElement nextElement = (GraphElement)element_clone[this.Next]; if (nextElement == null) { if (this.Next is GraphArrow) { nextElement = ((GraphArrow)this.Next).Clone(elements, clonedElements, element_clone); } else { nextElement = this.Next.Clone(); } clonedElements.Add(nextElement); element_clone.Add(this.Next, nextElement); } Connector initConnector = prevElement.GetConnector(this.initConnector.Side); Connector finConnector = nextElement.GetConnector(this.next.Side); GraphArrow clone = new GraphArrow(initConnector, finConnector, this.segments); if (prevElement is GraphConditional) { if (((GraphConditional)this.initConnector.Parent).NextTrue == this) { ((GraphConditional)prevElement).AddNext(initConnector, clone, ConditionalOut.True); } else { ((GraphConditional)prevElement).AddNext(initConnector, clone, ConditionalOut.False); } } else { prevElement.AddNext(initConnector, clone); } nextElement.AddPrevious(finConnector, clone); return(clone); }
private GraphElement GetClone(GraphElement element, List <GraphElement> elements, List <GraphElement> clonedElements, Hashtable element_clone) { GraphElement cloneElement = (GraphElement)element_clone[element]; if (cloneElement == null) { if (element is GraphArrow) { cloneElement = ((GraphArrow)element).Clone(elements, clonedElements, element_clone); } else { cloneElement = element.Clone(); } clonedElements.Add(cloneElement); element_clone.Add(element, cloneElement); } return(cloneElement); }
public GraphArrow(string key, string idElement, XmlElement xmlElement, List <GraphElement> graphElements, List <Element> elements, SortedList <string, XmlElement> id_XmlElements, SortedList <string, GraphElement> id_GraphElements, SortedList <string, Variable> variables) { this.element = new Arrow(); this.key = key; Point position = new Point(-1, -1); List <Point> locations = new List <Point>(); foreach (XmlElement nodo in xmlElement) { switch (nodo.Name) { case "position": position = new Point(System.Convert.ToInt32(nodo.ChildNodes[0].InnerText), System.Convert.ToInt32(nodo.ChildNodes[1].InnerText)); break; case "previous": if ((nodo.ChildNodes[0].Name == "elementId") && (nodo.ChildNodes[1].Name == "connectorId")) { GraphElement prevElement = null; try { prevElement = id_GraphElements[nodo.ChildNodes[0].InnerText]; } catch { prevElement = GraphDiagram.CreateGraphElement(id_XmlElements[nodo.ChildNodes[0].InnerText], graphElements, elements, id_XmlElements, id_GraphElements, variables); graphElements.Add(prevElement); id_GraphElements.Add(nodo.ChildNodes[0].InnerText, prevElement); elements.Add(prevElement.Element); } this.initConnector = prevElement.GetConnector(System.Convert.ToInt32(nodo.ChildNodes[1].InnerText)); this.previous.Add(this.initConnector); if (this.previous[0].Parent is GraphConditional) { if (this.GetOutLine(id_XmlElements[nodo.ChildNodes[0].InnerText], idElement) == ConditionalOut.True) { ((GraphConditional)this.previous[0].Parent).AddNext(this.initConnector, this, ConditionalOut.True); } else { ((GraphConditional)this.previous[0].Parent).AddNext(this.initConnector, this, ConditionalOut.False); } } else { this.previous[0].Parent.AddNext(this.initConnector, this); } } break; case "next": if ((nodo.ChildNodes[0].Name == "elementId") && (nodo.ChildNodes[1].Name == "connectorId")) { GraphElement nextElement = null; try { nextElement = (GraphElement)id_GraphElements[nodo.ChildNodes[0].InnerText]; } catch { nextElement = GraphDiagram.CreateGraphElement(id_XmlElements[nodo.ChildNodes[0].InnerText], graphElements, elements, id_XmlElements, id_GraphElements, variables); graphElements.Add(nextElement); id_GraphElements.Add(nodo.ChildNodes[0].InnerText, nextElement); elements.Add(nextElement.Element); } this.next = nextElement.GetConnector(System.Convert.ToInt32(nodo.ChildNodes[1].InnerText)); this.next.Parent.AddPrevious(this.next, this); } break; case "points": foreach (XmlElement location in nodo.ChildNodes) { if ((location.ChildNodes[0].Name == "x") && (location.ChildNodes[1].Name == "y")) { locations.Add(new Point(System.Convert.ToInt32(location.ChildNodes[0].InnerText), System.Convert.ToInt32(location.ChildNodes[1].InnerText))); } } break; default: throw new GraphException("Error al crear GraphStart"); } } CreateArrowSurface(locations); this.Center = position; }