private void AddPath(object e) { ComboBox cb = (ComboBox)e; if (cb.SelectedIndex == -1) { return; } AddPath(UtilityStuff.IndexInGraph(selectedNode, graph), cb.SelectedIndex, isPathTwoWay, UtilityStuff.Dist(graph.TheGraph[UtilityStuff.IndexInGraph(selectedNode, graph)], Graph[cb.SelectedIndex])); }