/// <summary> /// Converts the net more or less reliable to a string which can be read as a *.dot-File by Graphviz (http://www.graphviz.org/) /// </summary> /// <returns>Returns said string, which you have to put into a file.</returns> public String ConvertToDot() { StringBuilder content = new StringBuilder(); content.Append("digraph TC {\n"); content.Append("node[shape=circle];\nrankdir=LR\n"); // draw all places with their respective labels and amount of tokens (p0 [label="A (1)"]) for (int index = 0; index <= Places.Count() - 1; index++) { content.Append("p" + index + " [label=\"" + Places[index].Name + " (" + Places[index].Token + ")\"]\n"); } content.Append("node[shape=rect];\n"); // draw all transitions with their respective labels (t0 [label="AtoB"]) for (int index = 0; index <= Transitions.Count() - 1; index++) { content.Append("t" + index + " [label=\"" + Transitions[index].Name + "\"]\n"); // and for each transition draw the incoming (p0 -> t0)... foreach (Place incomingPlace in Transitions[index].IncomingPlaces) { content.Append("p" + Places.IndexOf(incomingPlace) + " -> " + "t" + index + "\n"); } // ... and outgoing (t0 -> p1) connections foreach (Place outgoingPlace in Transitions[index].OutgoingPlaces) { content.Append("t" + index + " -> " + "p" + Places.IndexOf(outgoingPlace) + "\n"); } } content.Append("}"); return(content.ToString()); }
private void MoveToTop(object phoneObj) { PlaceViewModel phone = phoneObj as PlaceViewModel; if (phone == null) { return; } int oldIndex = Places.IndexOf(phone); if (oldIndex > 0) { Places.Move(oldIndex, oldIndex - 1); } }
private void MoveToBottom(object phoneObj) { PlaceViewModel phone = phoneObj as PlaceViewModel; if (phone == null) { return; } int oldIndex = Places.IndexOf(phone); if (oldIndex < Places.Count - 1) { Places.Move(oldIndex, oldIndex + 1); } }
public void GenerateEventsIntoDb(int count) { //Creating an amount of items on the entry int indexOfFirstPlace = Places.IndexOf(Places.FirstOrDefault(p => p.Name == "p0")); for (var i = 0; i < count; i++) { var tk = new Token("Token_" + i.ToString(), Places.ElementAt(indexOfFirstPlace)); Tokens.Add(tk); Places.ElementAt(indexOfFirstPlace).Capacity++; DbConn.Pn_InsertNewToken(tk); Event ev = GenerateNextEvent(Tokens.Last()); //DbConn.Pn_InsertEvent(ev); while (ev != null) { DbConn.Pn_InsertEvent(ev); ev = GenerateNextEvent(Tokens.Last()); } } }
/// <summary> /// Returns a generated PlaceID /// </summary> /// <param name="place"></param> /// <returns></returns> /// <autor>Andrej Albrecht</autor> public String GetPlaceID(Place place) { return("p" + Places.IndexOf(place)); }