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); } } }
void LoadPlanet() { nameTextBox.Text = planet.Name; dateTimePicker1.Value = planet.InventingDate; if (planet.Photo != null) { pictureBox1.Image = StarForm1.ConvertToImage(planet.Photo); } radiusTextBox.Text = planet.Radius.ToString(); distanceTextBox.Text = planet.MiddleDistance.Value.ToString(); planet.HasAtmosphere = checkBox1.Checked; switch (planet.MiddleDistance.Unit) { case UnitType.Kilometers: comboBox1.Text = "км"; break; case UnitType.LightYears: comboBox1.Text = "св. г."; break; case UnitType.AstronomicUnits: comboBox1.Text = "а.е."; break; default: throw new ArgumentOutOfRangeException(); } switch (planet.Type) { case PlanetType.Tought: this.comboBox2.Text = "Каменистая планета"; break; case PlanetType.Gas: this.comboBox2.Text = "Газовый гигант"; break; default: throw new ArgumentOutOfRangeException(); } checkBox1.Checked = planet.HasAtmosphere; foreach (var moon in planet.Moons) { if (!Moons.Items.Contains(moon)) { Moons.Items.Add(moon); } } Moons.Refresh(); }
void LoadMoon() { nameTextBox.Text = moon.Name; dateTimePicker1.Value = moon.InventingDate; if (moon.Photo != null) { moonPicture.Image = StarForm1.ConvertToImage(moon.Photo); } radiusTextBox.Text = moon.Radius.ToString(); moon.HasAtmosphere = checkBox1.Checked; checkBox1.Checked = moon.HasAtmosphere; }
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; }