/// <summary> /// Adds a route to the RouteList using the currently selected station, the selected end station and the /// price that has been entered. It then repopulates the list box to include the new route and notifies /// all the observers of the new route so that they can be used in the single journey ticket option on /// the TokenMachineGUI. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnCreateRoute_Click(object sender, EventArgs e) { routes.AddRoute(new Route((Station)cbSelectStation.SelectedItem, (Station)cbEndStationEntry.SelectedItem, decimal.Parse(tbPriceEntry.Text))); lbRoutes.Items.Clear(); foreach (var route in routes.GetAllRoutes()) { if (route.GetStartPoint().ToString() == cbSelectStation.SelectedItem.ToString()) { lbRoutes.Items.Add(route.GetEndPoint()); } } routes.NotifyObservers(); }
private void btnAddNewGUI_Click(object sender, EventArgs e) { TokenMachineGUI gui = new TokenMachineGUI(counter); gui.Show(); counter.RegisterObserver(gui); routes.RegisterObserver(gui); routes.NotifyObservers(); }