Example #1
0
        private void setupStartSelector_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (setupStartSelector.SelectedItem == null)
            {
                return;
            }

            var start = (setupStartSelector.SelectedItem as Tag <StartingConditions>).Value;

            if (start != null)
            {
                var sb        = new StringBuilder();
                var formatter = new ThousandsFormatter(start.Population);

                sb.AppendLine("Colonies: " + start.Colonies);
                sb.AppendLine("Population: " + formatter.Format(start.Population));
                foreach (var building in start.Buildings.Select(x => controller.StartBuildingInfo(x)))
                {
                    sb.AppendLine(building.Name + ": " + formatter.Format(building.Quantity));
                }

                startingDescription.Text = sb.ToString();
                controller.SelectedStart = start;
            }
            else
            {
                using (var form = new FormStartingConditions()) {
                    form.Initialize(controller.CustomStart);
                    if (form.ShowDialog() == DialogResult.OK && form.IsValid)
                    {
                        controller.CustomStart = form.GetResult();
                        setupStartSelector.Items[customStartIndex] = new Tag <StartingConditions>(controller.CustomStart, controller.CustomStart.Name);
                        setupStartSelector.SelectedIndex           = customStartIndex;
                        controller.SelectedStart = controller.CustomStart;
                    }
                }
            }
        }