} // AddVertex_Click private void AddLink_Click(object sender, RoutedEventArgs e) { if (graph == null) { MessageBox.Show($"Create new \"Graph\" first"); return; } if (graph.GetVerticesCount() == 0) { MessageBox.Show($"Add more \"Vertices\" to create \"Links\""); return; } CreateLinkWindow window = new CreateLinkWindow(CheckAndAddLink, graph); window.Owner = this; window.ShowDialog(); } // AddLink_Click
} // Graph_MouseDown private void Grid_MouseUp(object sender, MouseButtonEventArgs e) { if (tempLine != null) { Grid grid1 = selectedElement as Grid; Grid grid2 = sender as Grid; if (grid2.Children[0] is Ellipse && grid1 != grid2) { TextBlock textBox1 = grid1.Children[1] as TextBlock; Vertex vertex1 = (Vertex)textBox1.DataContext; TextBlock textBox2 = grid2.Children[1] as TextBlock; Vertex vertex2 = (Vertex)textBox2.DataContext; CreateLinkWindow window = new CreateLinkWindow(CheckAndAddLink, graph, vertex1.Id, vertex2.Id); window.Owner = this; window.ShowDialog(); } myCanvas.Children.Remove(tempLine); tempLine = null; } } // Grid_MouseUp