예제 #1
0
        private void saveAirport_Click(object sender, EventArgs e)
        {
            aerodrom           = new Aerodrom();
            aerodrom.City      = cityOfAirport.Text;
            aerodrom.Name      = nameOfAirport.Text;
            aerodrom.ShortName = shortNameOfAirport.Text;

            DialogResult = DialogResult.OK;
        }
예제 #2
0
        private void addDestination_Click(object sender, EventArgs e)
        {
            AddDestination addDestination = new AddDestination();

            if (addDestination.ShowDialog() == DialogResult.OK)
            {
                Aerodrom a = (Aerodrom)listAirports.SelectedItem;
                a.Destinations.Add(addDestination.destination);
                listDest.Items.Add(addDestination.destination);
            }
        }
예제 #3
0
        private void listAirports_SelectedIndexChanged(object sender, EventArgs e)
        {
            listDest.Items.Clear();
            Aerodrom    a   = (Aerodrom)listAirports.SelectedItem;
            Destination max = new Destination();

            max.Distance = Int32.MinValue;
            float avg = 0;

            foreach (var item in a.Destinations)
            {
                if (max.Distance < item.Distance)
                {
                    max = item;
                }
                avg += item.Distance;
                listDest.Items.Add(item);
            }
            if (max.Distance != Int32.MinValue)
            {
                longestDest.Text = max.ToString();
            }
            averageDest.Text = avg / listDest.Items.Count + "";
        }