public void addStation(Station st) { _stations.Add(st); }
private void Open_Board_Click(object sender, RoutedEventArgs e) { Station station = new Station(); String nameLeft = ""; string nameRight = ""; foreach (Railway rl in subway.GetRailways) { foreach (Station st in rl.GetStations) { if (st.ellipsePath.Equals(currElleipse)) { station = st; nameLeft = rl.GetStations.ElementAt(rl.GetStations.Count - 1).stationName.Text; nameRight = rl.GetStations.ElementAt(0).stationName.Text; break; } } } if (station.Board.BoardWindow == null || !station.Board.BoardWindow.IsLoaded) { station.Board.BoardWindow = new BoardWindow(); station.Board.BoardWindow.lastLeftLB.Content = nameLeft; station.Board.BoardWindow.lastRightLB.Content = nameRight; station.Board.BoardWindow.Show(); } }
internal void AddStation(String name) { if (on) { Station st = new Station(name); st.lineNumber = SubwayLinesLBox.SelectedIndex; st.Number = subway.GetRailways.ElementAt(SubwayLinesLBox.SelectedIndex).GetStations.Count; subway.GetRailways.ElementAt(SubwayLinesLBox.SelectedIndex).addStation(st); } }
private void Mouse_Move_On_Field(object sender, MouseEventArgs e) { if (on) { bool block = false; EllipseGeometry currentEllipse = new EllipseGeometry(); PathGeometry ellipseLine = new PathGeometry(); PathFigure startLineFigure = new PathFigure(); PathFigure endLineFigure = new PathFigure(); PathFigure backLineFigure = new PathFigure(); PathFigure backendLineFigure = new PathFigure(); Station st = new Station(); if (isAttached && attachedElement != null) { foreach (Railway rl in subway.GetRailways) { for (int i = 0; i < rl.GetStations.Count; i++) { if (rl.GetStations[i].ellipsePath == attachedElement as System.Windows.Shapes.Path) { currentEllipse = rl.GetStations[i].ellipsePath.Data as EllipseGeometry; st = rl.GetStations[i]; if (rl.GetStations[i].startLinePath != null) { ellipseLine = rl.GetStations[i].startLinePath.Data as PathGeometry; startLineFigure = ellipseLine.Figures.ElementAt(0); if (i + 1 < rl.GetStations.Count) { backLineFigure = (rl.GetStations[i + 1].endLinePath.Data as PathGeometry).Figures.ElementAt(0); } } if (i > 0) { ellipseLine = rl.GetStations[i - 1].startLinePath.Data as PathGeometry; endLineFigure = ellipseLine.Figures.ElementAt(0); backendLineFigure = (rl.GetStations[i].endLinePath.Data as PathGeometry).Figures.ElementAt(0); } } } } Point p = new Point(Mouse.GetPosition(fieldCanvas).X, Mouse.GetPosition(fieldCanvas).Y); foreach (Railway rl in subway.GetRailways) { foreach (Station s in rl.GetStations) { if (s.ellipsePath != st.ellipsePath) { if (s.lineNumber == st.lineNumber) { if (Math.Sqrt((s.Coordinate.X - Mouse.GetPosition(fieldCanvas).X) * (s.Coordinate.X - Mouse.GetPosition(fieldCanvas).X) + (s.Coordinate.Y - Mouse.GetPosition(fieldCanvas).Y) * (s.Coordinate.Y - Mouse.GetPosition(fieldCanvas).Y)) < 100) { block = true; } } else { if (Math.Sqrt((s.Coordinate.X - Mouse.GetPosition(fieldCanvas).X) * (s.Coordinate.X - Mouse.GetPosition(fieldCanvas).X) + (s.Coordinate.Y - Mouse.GetPosition(fieldCanvas).Y) * (s.Coordinate.Y - Mouse.GetPosition(fieldCanvas).Y)) < 40) { block = true; } } } } } if (!block) { double X = 35; double Y = 30; if (Mouse.GetPosition(fieldCanvas).X > 30) { X = Mouse.GetPosition(fieldCanvas).X; } if (Mouse.GetPosition(fieldCanvas).Y > 30) { Y = Mouse.GetPosition(fieldCanvas).Y; } currentEllipse.Center = new Point(X, Y); st.Coordinate = currentEllipse.Center; st.stationName.Margin = new Thickness(currentEllipse.Center.X - 35, currentEllipse.Center.Y - 35, currentEllipse.Center.X, currentEllipse.Center.Y); startLineFigure.StartPoint = currentEllipse.Center; backendLineFigure.StartPoint = currentEllipse.Center; if (endLineFigure.Segments.Count > 0) { endLineFigure.Segments.RemoveAt(0); } if (backLineFigure.Segments.Count > 0) { backLineFigure.Segments.RemoveAt(0); } List<Point> pointsList = new List<Point>(); pointsList.Add(currentEllipse.Center); pointsList.Add(currentEllipse.Center); pointsList.Add(currentEllipse.Center); endLineFigure.Segments.Add(new PolyBezierSegment(pointsList, true)); backLineFigure.Segments.Add(new PolyBezierSegment(pointsList, true)); } } } }