Пример #1
0
 private AbstractEdge isAlreadyOppositeEdge(AbstractEdge item)
 {
     AbstractEdge ret = null;
     foreach (AbstractEdge edge in this.edges)
     {
         if (edge.Start.Equals(item.End))
         {
             if (edge.End.Equals(item.Start))
             {
                 ret = edge;
                 break;
             }
         }
     }
     return ret;
 }
Пример #2
0
 /// <summary>
 /// Add edge. If edge is already exists, only increment weight. If opposite edge is exists, curve middle point offset is setted.
 /// </summary>
 protected void addEdge(AbstractEdge item)
 {
     if (!this.edges.Contains(item))
     {
         AbstractEdge edge = this.isAlreadyEdge(item);
         if (edge == null)
         {
             AbstractEdge oppositeEdge = this.isAlreadyOppositeEdge(item);
             if (oppositeEdge == null)
             {
                 this.edges.Add(item);
             }
             else
             {
                 item.CurveMiddlePointOffset = new PointF(50, 50);
                 this.edges.Add(item);
             }
         }
         else
         {
             edge.incrementWeight();
         }
     }
 }
Пример #3
0
 protected void deleteEdge(AbstractEdge item)
 {
     if (this.edges.Contains(item))
     {
         this.removeNoteAttachmentBeforeDelete(item);
         this.unselectItem(item);
         this.edges.Remove(item);
         this.deleteAllStates();
     }
 }
Пример #4
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);
             }
         }
     }
 }