protected void OnAddAllButtonClicked(object sender, EventArgs e) { bool isPostProcess = true; if (_container != null) { List <Stop> stops = new List <Stop>(); foreach (VBox v in _container) { foreach (HBox h in v.AllChildren) { string title = ""; string time = ""; double position = -1; foreach (Widget w in h.AllChildren) { if (w.ToString() == "KursachAttemp2.Models.CustomGtkEntry") { var ent = (CustomGtkEntry)w; if (ent.Type == "time" && ent.Text != "") { time = ent.Text; try { var tmp = time.Split(':'); var tmpTime = new DateTime(2018, 12, Convert.ToInt32(tmp[0]), Convert.ToInt32(tmp[1]), Convert.ToInt32(tmp[2]), 0); if (stops.Count > 0 && tmpTime <= stops[stops.Count - 1].StartTime) { ent.Text = ""; return; } } catch (ArgumentOutOfRangeException) { ent.Text = ""; return; } catch (IndexOutOfRangeException) { //ent.Text = ""; //return; } } else if (ent.Type == "title" && ent.Text != "") { title = ent.Text; } else if (ent.Type == "position" && ent.Text != "") { try { position = Convert.ToDouble(ent.Text); if (stops.Count > 0 && position <= stops[stops.Count - 1].Position) { ent.Text = ""; } } catch (FormatException) { ent.Text = ""; return; } } } if (title != "" && time != "" && position >= 0) { stops.Add(new Stop(title, time, position)); } } } } try { if (stops.Count == 0) { isPostProcess = false; return; } stops[0].Position = 0; way = new Way(way_title, stops); g = Graph.Deserialize(_parent.Path_); /*List<string> count = new List<string>(); * for (int i = 0; i < g.Ways.Count; i++) * { * for (int j = 0; j < g.Ways[i].Count;j++) * { * bool contains = false; * foreach(string s in count) * { * if (s == g.Ways[i][j].Title) * contains = true; * } * if(!contains) * { * count.Add(g.Ways[i][j].Title); * } * } * } * for (int j = 0; j < way.Count;j++) * { * bool contains = false; * foreach (string s in count) * { * if (s == way[j].Title) * contains = true; * } * if (!contains) * { * count.Add(way[j].Title); * } * }*/ g.Ways.Add(way); g = new Graph(10, g.Ways); _parent.Graph = g; KursachAttemp2.Models.Graph.Serialize(g, _parent.Path_); } catch (FileNotFoundException) { List <string> count = new List <string>(); for (int j = 0; j < way.Count; j++) { bool contains = false; foreach (string s in count) { if (s == way[j].Title) { contains = true; } } if (!contains) { count.Add(way[j].Title); } } var list_way = new List <Way>(); list_way.Add(way); g = new Graph(count.Count, list_way); _parent.Graph = g; KursachAttemp2.Models.Graph.Serialize(g, _parent.Path_); } finally { if (isPostProcess) { (new AddToExistingWayWindow(_parent)).Show(); _parent.BuildGraph(); Destroy(); } } } }
public static void BuildGraph_(IGraph w) { w.BuildGraph(); }