/// <summary> /// Metoda SetSelectedVertex wywoływana po kliknięciu wierzchołka, /// ustawia go na aktualnie wybrany, co umożliwia edycję jego /// połączeń, albo w momencie gdy <c>waitingToConnect == true</c> wybiera /// połączenie dla aktualnie wybranego wierzchołka /// </summary> /// <param name="vertex"></param> public void SetSelectedVertex(Vertex vertex) { if (!waitingToConnect) { currentlySelectedVertex = vertex; UpdateConnectionsTable(); ActualVertex_Info.Text = currentlySelectedVertex.idNumber.ToString(); } else { if ((graph.LeftOrRight(vertex) == "Left" && searchingInLeft) || (graph.LeftOrRight(vertex) == "Right" && !searchingInLeft)) { currentlySelectedVertex.AddConnection(vertex); vertex.AddConnection(currentlySelectedVertex); waitingToConnect = false; LeftGrid.Background = null; RightGrid.Background = null; AddConnection_Button.Content = "Dodaj połączenie"; AddConnection_Button.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#ffc300")); AddConnection_Button.BorderBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#ffc300")); UpdateConnectionsTable(); Vertex backup = currentlySelectedVertex; SetSelectedVertex(vertex); SetSelectedVertex(backup); drawConnections(); } } VertexControl.HighlightSelected(this, currentlySelectedVertex.idNumber); }
public virtual Vertex[] ConnectVertices(params Vertex[] vertices) { for (int i = 0; i < vertices.Count(); i++) { Vertex currentVertex = vertices[i]; if (i + 1 < vertices.Length) { Vertex nextVertex = vertices[i + 1]; currentVertex.AddConnection(nextVertex); } else { currentVertex.AddConnection(vertices[0]); } } return(vertices); }
private void CreateShape() { StartPoint = new Vertex(new Point()); StartPoint.Name = Name + "p1"; EndPoint = new Vertex(new Point()); EndPoint.Name = Name + "p2"; StartPoint.AddConnection(EndPoint); }
private void CreateShape() { TopLeft = new Vertex(new Point()); TopRight = new Vertex(new Point()); BottomLeft = new Vertex(new Point()); BottomRight = new Vertex(new Point()); TopLeft.Name = Name + "p1"; TopRight.Name = Name + "p2"; BottomLeft.Name = Name + "p3"; BottomRight.Name = Name + "p4"; TopLeft.AddConnection(TopRight); TopRight.AddConnection(BottomRight); BottomRight.AddConnection(BottomLeft); BottomLeft.AddConnection(TopLeft); }