Ejemplo n.º 1
0
 public void changeEdgeDirection(AbstractEdge item, bool selected)
 {
     if (this.edges.Contains(item))
     {
         AbstractEdge edge = null;
         if (item is EdgePositionTransition)
         {
             Transition endTransition = (Transition)item.End;
             if (!TransitionType.SINK.Equals(endTransition.TransitionType))
             {
                 edge = new EdgeTransitionPosition(item.Name, item.Unid, item.ShowAnnotation, item.Weight, endTransition, (Position)item.Start, item.CurveMiddlePointOffset, EdgeType.NORMAL);
             }
         }
         else if (item is EdgeTransitionPosition)
         {
             Transition startTransition = (Transition)item.Start;
             if (!TransitionType.SOURCE.Equals(startTransition.TransitionType))
             {
                 edge = new EdgePositionTransition(item.Name, item.Unid, item.ShowAnnotation, item.Weight, (Position)item.End, startTransition, item.CurveMiddlePointOffset, item.EdgeType);
             }
         }
         if (edge != null)
         {
             this.deleteEdge(item);
             this.addEdge(edge);
             if (selected)
             {
                 this.selectItem(edge);
             }
         }
     }
 }
Ejemplo n.º 2
0
 public static AbstractEdge openFromXml(XmlNode node, List<AbstractNetworkItem> items)
 {
     long positionUnid = 0;
     long transitionUnid = 0;
     bool isStartPosition = false;
     PointF curveMiddlePoint = new PointF(0, 0);
     XmlNodeList list = node.ChildNodes;
     foreach (XmlNode childNode in list)
     {
         string namespaceUri = childNode.NamespaceURI;
         string localName = childNode.LocalName;
         switch (namespaceUri)
         {
             case PetriXmlHelper.XML_EDGE_NAMESPACE:
                 string reftype = AbstractEdge.openRefTypeAttrFromNode(childNode);
                 switch (localName)
                 {
                     case "Start":
                         if ("TRANSITION".Equals(reftype))
                         {
                             transitionUnid = Convert.ToInt64(childNode.InnerText);
                         }
                         else if ("POSITION".Equals(reftype))
                         {
                             positionUnid = Convert.ToInt64(childNode.InnerText);
                             isStartPosition = true;
                         }
                         break;
                     case "End":
                         if ("TRANSITION".Equals(reftype))
                         {
                             isStartPosition = true;
                             transitionUnid = Convert.ToInt64(childNode.InnerText);
                         }
                         else if ("POSITION".Equals(reftype))
                         {
                             positionUnid = Convert.ToInt64(childNode.InnerText);
                         }
                         break;
                 }
                 break;
             case PetriXmlHelper.XML_POINTF_NAMESPACE:
                 if ("CurveMiddlePointOffset".Equals(localName))
                 {
                     curveMiddlePoint = PetriXmlHelper.openPointF(childNode);
                 }
                 break;
         }
     }
     Position position = (Position)AbstractNetworkItem.findItemByUnid(items, positionUnid);
     Transition transition = (Transition)AbstractNetworkItem.findItemByUnid(items, transitionUnid); ;
     int weight = AbstractEdge.openWeightAttrFromNode(node);
     EdgeType edgeType = AbstractEdge.openEdgeTypeFromXml(node);
     string name = AbstractItem.openNameAttrFromNode(node);
     long unid = AbstractItem.openUnidAttrFromNode(node);
     bool showAnnotation = AbstractItem.openShowAnnotationAttrFromNode(node);
     AbstractEdge ret = null;
     if (isStartPosition)
     {
         ret = new EdgePositionTransition(name, unid, showAnnotation, weight, position, transition, curveMiddlePoint, edgeType);
     }
     else
     {
         ret = new EdgeTransitionPosition(name, unid, showAnnotation, weight, transition, position, curveMiddlePoint, edgeType);
     }
     return ret;
 }