コード例 #1
0
        private void TransferAirplane_Click(object sender, RoutedEventArgs e)
        {
            Airplane airplane = (Airplane)MyAirplanesGrid.SelectedItem;

            if (airplane != null)
            {
                _game.Pause();

                var dialog = new TransferAirplaneDialog(CityCatalog.Cities.Where(x => airplane.CanFlyTo(x)));
                if ((bool)dialog.ShowDialog())
                {
                    City     city = (City)dialog.CitiesComboBox.SelectedItem;
                    DateTime?date = dialog.DateComboBox.SelectedDate;
                    if (city != null && date.HasValue)
                    {
                        var hours   = int.Parse(dialog.HoursText.Text);
                        var minutes = int.Parse(dialog.MinutesText.Text);
                        date += new TimeSpan(hours, minutes, 0);

                        _game.Player.TransferAirplane(airplane, city, date.Value);
                    }
                }
                _game.Unpause();
            }
        }