private void btnDrawRandomGraphFromLines_Click(object sender, RoutedEventArgs e) { draw.ClearAll(); if (Graph.MaxConnections((int)intUpDownRandomPoints1.Value) < (int)intUpDownConnections.Value) { MessageBox.Show(String.Format("Przekroczono maksymalną liczbę połaczeń!\nMaksymalna liczba polaczen dla {0} wierzcholkow wynosi {1}.", (int)intUpDownRandomPoints1.Value, Graph.MaxConnections((int)intUpDownRandomPoints1.Value)), "Błąd!"); return; } if (intUpDownRandomPoints1.Value != null && intUpDownConnections.Value != null) { draw.CurrentGraph = GraphCreator.CreateRandomGraph((int)intUpDownRandomPoints1.Value, (int)intUpDownConnections.Value); } else { MessageBox.Show("Niepoprawna ilość wierchołków bądź połaczeń!", "Błąd!"); return; } draw.NodeRadius = (int)sliderNodeRadius.Value; draw.Radius = (int)sliderRadius.Value; draw.DrawMainCircle(); draw.Draw(); }
private void btnOpenFromFile_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog(); openFileDialog.Multiselect = false; openFileDialog.Filter = "Pliki tekstowe | *.txt|Wszystkie pliki |*.*"; if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { int[,] graphMatrix; if (SaveOpenGraph.ReadFromFile(openFileDialog.FileName, out graphMatrix)) { draw.ClearAll(); draw.CurrentGraph = GraphCreator.CreateFromMatrix(graphMatrix); draw.NodeRadius = (int)sliderNodeRadius.Value; draw.Radius = (int)sliderRadius.Value; draw.DrawMainCircle(); draw.Draw(); } else { MessageBox.Show("Błędna zawartość pliku!", "Błąd"); } } }