private void InitializePlanet() { planet.Name = nameTextBox.Text; planet.InventingDate = dateTimePicker1.Value; planet.Photo = StarForm1.ConvertImage(pictureBox1.Image); uint temp; if (uint.TryParse(radiusTextBox.Text, out temp)) { planet.Radius = temp; } if (uint.TryParse(distanceTextBox.Text, out temp)) { UnitType t; switch (comboBox1.Text) { case "км": t = UnitType.Kilometers; break; case "св. г.": t = UnitType.LightYears; break; case "а.е.": t = UnitType.AstronomicUnits; break; default: throw new ArgumentException(); } planet.MiddleDistance = new Distance(temp, t); } planet.HasAtmosphere = checkBox1.Checked; PlanetType type; switch (comboBox2.Text) { case "Газовый гигант": type = PlanetType.Gas; break; case "Каменистая планета": type = PlanetType.Tought; break; default: throw new ArgumentException(); } planet.Type = type; //planet.Moons.AddRange(Moons.Items.Cast<Moon>()); foreach (Moon pl in Moons.Items) { if (!planet.Moons.Contains(pl)) { planet.Moons.Add(pl); } } }
private void InitializeMoon() { moon.Name = nameTextBox.Text; moon.InventingDate = dateTimePicker1.Value; moon.Photo = StarForm1.ConvertImage(moonPicture.Image); uint temp; if (uint.TryParse(radiusTextBox.Text, out temp)) { moon.Radius = temp; } moon.HasAtmosphere = checkBox1.Checked; }