private void MakeRoad() { var data = new RoadDialogeViewModel(); var view = new RoadDialogeView { DataContext = data, ViewModel = data }; Mouse.OverrideCursor = Cursors.Arrow; Dialoge.ShowDialog(view, "Road builder"); Mouse.OverrideCursor = Cursors.Pen; if (data.Length == 0) { return; } var road = new RoadCore(core.Canvas, first, second, simulationService, data.Length); try { (core as StationCore).AddRoadToEach(road); (core.SimulationModel as Station).AttachRoad(road.SimulationModel as Road); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
public void AddRoadToEach(RoadCore road) { if (road.SimulationModel is Road r) { GetModelBy(r.First).roads.Add(road); GetModelBy(r.Second).roads.Add(road); } else { throw new Exception("Can't add road to second station"); } }