public List<Link> LoadLinks() { _links.Clear(); foreach (string line in File.ReadAllLines(DATA_PATH + "links.txt")) { if (IsSkip(line)) continue; else { string[] split = line.Split(','); for (int i = 0; i < split.Length; i++) split[i] = split[i].Trim(); Point[] nodes = new Point[0]; if (split.Length > 3) nodes = GetNodes(split[3]); string[] splitNames = split[0].Split('/'); for (int i = 1; i < splitNames.Length; i++) { Link link = new Link(_stations[splitNames[i - 1]], _stations[splitNames[i]], split[1] == "1", int.Parse(split[2]), nodes); _stations[splitNames[i - 1]].Links.Add(splitNames[i], link); _stations[splitNames[i]].Links.Add(splitNames[i - 1], link); _links.Add(link); } } } ConnectTracks(); return _links; }
public static Color GetLinkColor(Link link) { if (link.TrackCount == 0) return Color.LightGray; else if (link.Efficiency <= 0.8f) return LINK_BAD; else return link.IsTunnel ? LINK_GOOD_TUNNEL : LINK_GOOD; }
private Link AddLink(string inStation, string outStation, bool isTunnel, int trackCount, Point[] nodes) { Link link = new Link(_stations[inStation], _stations[outStation], isTunnel, trackCount, nodes); _stations[inStation].Links.Add(outStation, link); _stations[outStation].Links.Add(inStation, link); _links.Add(link); return link; }
public static int GetLinkWidth(Link link) { return link.TrackCount * 60; }