示例#1
0
        private void AddCommodityButton_Click(object sender, EventArgs e)
        {
            if (gameData.StarSystems.Count == 0 || gameData.StarSystems[SystemComboBox.SelectedIndex].Stations.Count == 0)
            {
                return;
            }

            StarSystem selectedSystem  = gameData.StarSystems[SystemComboBox.SelectedIndex];
            Station    selectedStation = selectedSystem.Stations[StationComboBox.SelectedIndex];

            AddEditCommodityDialog dialog = new AddEditCommodityDialog(selectedSystem.Name, selectedStation.Name, gameData.StarSystems);

            dialog.ShowDialog();

            if (dialog.Result == null)
            {
                return;
            }

            Commodity newCommodity = dialog.Result;

            newCommodity.LastUpdated = DateTime.Now;

            selectedStation.Commodities.Add(newCommodity);
            BindCommodities();
        }
        private void AddCommodityButton_Click(object sender, EventArgs e)
        {
            if (gameData.StarSystems.Count == 0 || gameData.StarSystems[SystemComboBox.SelectedIndex].Stations.Count == 0)
                return;

            StarSystem selectedSystem = gameData.StarSystems[SystemComboBox.SelectedIndex];
            Station selectedStation = selectedSystem.Stations[StationComboBox.SelectedIndex];

            AddEditCommodityDialog dialog = new AddEditCommodityDialog(selectedSystem.Name, selectedStation.Name, gameData.StarSystems);
            dialog.ShowDialog();

            if (dialog.Result == null)
                return;

            Commodity newCommodity = dialog.Result;

            newCommodity.LastUpdated = DateTime.Now;

            selectedStation.Commodities.Add(newCommodity);
            BindCommodities();
        }