Esempio n. 1
0
        private void btnRemoveWagons_Click(object sender, EventArgs e)
        {
            int wagonNumber;

            if (lstViewWagons.SelectedItems.Count == 1)
            {
                if (int.TryParse(lstViewWagons.SelectedItems[0].SubItems[0].Text, out wagonNumber))
                {
                    Wagon remove = administration.FindWagon(wagonNumber);

                    if (remove != null)
                    {
                        administration.Remove(remove);
                        lstViewWagons.SelectedItems[0].Remove();

                        foreach (Train t in administration.Trains)
                        {
                            t.Wagons.Remove(remove); //remove wagons
                            remove.RemoveWagonFromTrain();
                        }

                        updateListViewTrains();
                    }
                    else
                    {
                        MessageBox.Show("Could not find wagon");
                    }
                }
            }
            else
            {
                MessageBox.Show("Select a wagon to remove");
            }
        }
Esempio n. 2
0
 public void Dispose()
 {
     foreach (Arduino arduino in connectedTrains)
     {
         try
         {
             administration.Remove(new Train(arduino.Id, int.Parse(arduino.ComPort.Remove(0, 3))));
             arduino.Disconnect();
         }
         catch (Exception)
         {
         }
     }
 }
Esempio n. 3
0
        public void Disconnect(ObjectType type, string name)
        {
            if ((int)type >= receipentList.Length ||
                string.IsNullOrEmpty(name) ||
                string.IsNullOrWhiteSpace(name))
            {
                return;
            }

            IPEndPoint id = GetCurrentEndpoint();

            bool rem_1 = receipentList[(int)type].Remove(name);
            bool rem_2 = trafficMessages.Remove(id);

            if (rem_1 || rem_2)
            {
                administration.Remove(new Station(name));
                //Console.WriteLine("Disconnect(" + type + ", " + name + ")::('" + id + "');");
            }
        }
Esempio n. 4
0
 public void RemoveWagonTest()
 {
     Administration admin = new Administration();
     Wagon wagon1 = new Wagon(1, 1, 1);
     Wagon wagon2 = new Wagon(2, 1, 1);
     Wagon wagon3 = new Wagon(3, 1, 1);
     admin.Add(wagon1);
     admin.Add(wagon2);
     admin.Add(wagon3);
     Assert.AreEqual(true, admin.Remove(wagon3));
     Assert.AreEqual(true, admin.Remove(wagon2));
     Assert.AreEqual(true, admin.Remove(wagon1));
 }
Esempio n. 5
0
 public void RemoveWagonNullTest()
 {
     Administration admin = new Administration();
     Wagon wagon = null;
     admin.Remove(wagon);
 }
Esempio n. 6
0
 public void RemoveTrainTest()
 {
     Administration admin = new Administration();
     Train train1 = new Train(1, 1);
     Train train2 = new Train(2, 2);
     Train train3 = new Train(3, 3);
     admin.Add(train1);
     admin.Add(train2);
     admin.Add(train3);
     Assert.AreEqual(true, admin.Remove(train1));
     Assert.AreEqual(true, admin.Remove(train2));
     Assert.AreEqual(true, admin.Remove(train3));
 }
Esempio n. 7
0
 public void RemoveTrainNullTest()
 {
     Administration admin = new Administration();
     Train train = null;
     admin.Remove(train);
 }
Esempio n. 8
0
 public void RemoveStationWithoutNameTest()
 {
     Administration admin = new Administration();
     Station station = new Station("");
     admin.Remove(station);
 }
Esempio n. 9
0
 public void RemoveStationTest()
 {
     Administration admin = new Administration();
     Station station1 = new Station("station1");
     Station station2 = new Station("station2");
     Station station3 = new Station("station3");
     admin.Add(station1);
     admin.Add(station2);
     admin.Add(station3);
     Assert.AreEqual(true, admin.Remove(station3));
     Assert.AreEqual(true, admin.Remove(station2));
     Assert.AreEqual(true, admin.Remove(station1));
 }
Esempio n. 10
0
 public void RemoveStationNullTest()
 {
     Administration admin = new Administration();
     Station station = null;
     admin.Remove(station);
 }
Esempio n. 11
0
 public void RemoveRouteTest()
 {
     Administration admin = new Administration();
     Route route1 = new Route(1);
     Route route2 = new Route(2);
     Route route3 = new Route(3);
     admin.Add(route1);
     admin.Add(route2);
     admin.Add(route3);
     Assert.AreEqual(true, admin.Remove(route1));
     Assert.AreEqual(true, admin.Remove(route2));
     Assert.AreEqual(true, admin.Remove(route3));
 }
Esempio n. 12
0
 public void RemoveRouteNullTest()
 {
     Administration admin = new Administration();
     Route route = null;
     admin.Remove(route);
 }
Esempio n. 13
0
 public void RemoveNotExistinWagonTest()
 {
     Administration admin = new Administration();
     Wagon wagon = new Wagon(1, 1, 1);
     Assert.AreEqual(false, admin.Remove(wagon));
 }
Esempio n. 14
0
 public void RemoveNotExistinTrainTest()
 {
     Administration admin = new Administration();
     Train train = new Train(1, 1);
     Assert.AreEqual(false, admin.Remove(train));
 }
Esempio n. 15
0
 public void RemoveNotExistinStationTest()
 {
     Administration admin = new Administration();
     Station station1 = new Station("station1");
     Assert.AreEqual(false, admin.Remove(station1));
 }
Esempio n. 16
0
 public void RemoveNotExistinRouteTest()
 {
     Administration admin = new Administration();
     Route route = new Route(1);
     Assert.AreEqual(false, admin.Remove(route));
 }