private void loadButton_Click(object sender, RoutedEventArgs e) { RestartCanvas(_mainCanvas); List <NodeWithVisuals> nodes = new ServiceAccessLayer().GetNodes(); var layoutAlgorythm = new LayoutAlgorythms(); _nodesWithVisuals = layoutAlgorythm.CreateGridlikeLayout(nodes, _mainCanvas); new NodesEventHandler(_nodesSelected, _nodesWithVisuals).CreateEventHandlers(_mainCanvas); new NodesVisualHelper().CreateConnectingLines(_nodesWithVisuals, _mainCanvas); }
private void pathButton_Click(object sender, RoutedEventArgs e) { if (_nodesSelected.Count != 2) { MessageBox.Show("First you have to select 2 nodes, before calculating path"); return; } NodeWithVisuals startNodeWithVisuals = _nodesSelected.First(); NodeWithVisuals lastNodeWithVisuals = _nodesSelected.Last(); var nodesVisualHelper = new NodesVisualHelper(); nodesVisualHelper.ClearSelectedLines(startNodeWithVisuals); nodesVisualHelper.ClearSelectedLines(lastNodeWithVisuals); var path = new ServiceAccessLayer().GetShortestPathList(startNodeWithVisuals.id, lastNodeWithVisuals.id); nodesVisualHelper.DrawPath(path, _nodesWithVisuals, _nodesSelected, _mainCanvas); }