/// <summary> /// Method for creating new random <see cref="graph"/> instance with /// given number of nodes in <see cref="NodeCount"/> window. /// </summary> private void Menu_NewRandom_Click(object sender, RoutedEventArgs e) { NodeCount nodeCountPopUp = new NodeCount(); int nodeCount; if (nodeCountPopUp.ShowDialog() == true) { sequentialCounter = 0; nodeCount = Int32.Parse(nodeCountPopUp.Answer); graph = new Graph.Graph(MainCanvas, nodeCount); graph.DrawGraph(); ResetStats(); EnableMenu(); } e.Handled = true; }
/// <summary> /// Method for dispatcher <see cref="EventHandler"/> which executes /// force calculator for given <see cref="graph"/>. /// </summary> private void Sequentia_Arrange_Tick(object sender, EventArgs e) { sequentialCounter++; ForceCalculator.ForceCalculator forceCalculator = new ForceCalculator.ForceCalculator(MainCanvas); forceCalculator.CalculateForces(graph); graph.DrawGraph(); ResetStats(); sequentialProggresBar.Value = sequentialCounter; if (sequentialCounter >= 120) { timer.Stop(); } }
/// <summary> /// Method handling opening graph from file. /// </summary> private void Menu_Open_Click(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog { Filter = "Graph file (*.graph)|*.graph", InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) }; if (openFileDialog.ShowDialog() == true) { string adjacencyMatrixString = File.ReadAllText(openFileDialog.FileName); graph = new Graph.Graph(MainCanvas, adjacencyMatrixString); graph.DrawGraph(); ResetStats(); } e.Handled = true; }
/// <summary> /// Method for creating new <see cref="graph"/> instance with /// given number of <see cref="Graph.Node"/> in <see cref="NodeCount"/> window /// and user-added <see cref="Graph.Edge"/>s. /// </summary> private void Menu_New_Click(object sender, RoutedEventArgs e) { NodeCount nodeCountPopUp = new NodeCount(); if (nodeCountPopUp.ShowDialog() == true) { int nodeCount = Int32.Parse(nodeCountPopUp.Answer); MatrixCreator matrixCreator = new MatrixCreator(nodeCount); if (matrixCreator.ShowDialog() == true) { graph = new Graph.Graph(MainCanvas, matrixCreator.AdjecencyMatrix); graph.DrawGraph(); ResetStats(); EnableMenu(); } } e.Handled = true; }