/// <summary> /// Форма редактирования созвездия. /// </summary> /// <param name="sky">Небо.</param> /// <param name="cons">Созвездие.</param> public FormEditConstellation(Sky sky, Constellation cons) { InitializeComponent(); isAddForm = false; PrepareEditForm(sky, cons); }
private void PrepareEditForm(Sky sky, Star star) { Text = "Редактирование звезды"; bDel.Visible = true; this.sky = sky; this.star = star; // Настройка созвездий. cBoxCons.DataSource = sky.Constellations; cons = Filter.GetConstellationFromStar(star, sky); cBoxCons.SelectedIndex = sky.Constellations.IndexOf(cons); // Заполнение данными. tBoxName.Text = star.Name; tBoxUrl.Text = star.Url; cBoxUnit.DataSource = units; tBoxDist.Text = Editor.ToString(star.Distance); tBoxMagn.Text = Editor.ToString(star.Magnitude); EquatorialCS equa = star.Location; VerticalCord decl = equa.Declination; HorizontalCord RA = equa.RightAscension; numDeclDegree.Value = decl.Degrees; numDeclMinutes.Value = decl.Minutes; numDeclSeconds.Value = decl.Seconds; numRADegree.Value = RA.Degrees / 15; numRAMinutes.Value = RA.Minutes; numRASeconds.Value = RA.Seconds; }
private void cBoxCons_SelectedIndexChanged(object sender, EventArgs e) { if (cBoxCons.DataSource != null && sky != null) { cons = sky.Constellations[cBoxCons.SelectedIndex]; } }
// Удаляет созвездие с неба. private void bDel_Click(object sender, EventArgs e) { cons = Filter.GetConstellationFromStar(star, sky); cons.Stars.Remove(star); DialogResult = DialogResult.OK; Close(); }
public FormViewConstellation(Sky sky, Constellation cons, Human human) { InitializeComponent(); this.sky = sky; this.cons = cons; this.human = human; PrepareForm(); }
private void PrepareAddForm(Sky sky) { bDel.Visible = false; Text = "Создание звезды"; cBoxCons.DataSource = sky.Constellations; cBoxUnit.DataSource = units; this.sky = sky; cons = sky.Constellations[0]; }
private void PrepareEditForm(Sky sky, Constellation cons) { Text = "Редактирование созвездия"; pStars.Visible = true; bDel.Visible = true; this.sky = sky; this.cons = cons; tBoxName.Text = cons.Name; tBoxUrl.Text = cons.Url; lBoxStars.DataSource = cons.Stars; }
private void SaveData() { string name = tBoxName.Text; if (!ValidateName(name) || !IsAllFieldsFilled()) { return; } double distance = GetDistance(); double magn = Editor.ToDouble(tBoxMagn.Text); string url = tBoxUrl.Text; VerticalCord vert = GetDeclination(); HorizontalCord hor = GetRightAscension(); EquatorialCS equa = new EquatorialCS(vert, hor); if (isAddForm) { Star star = new Star(equa, name, magn, distance, url); cons.Stars.Add(star); } else { star.Name = name; star.Distance = distance; star.Magnitude = magn; star.Location = equa; star.Url = url; Constellation old = Filter.GetConstellationFromStar(star, sky); if (!cons.Equals(old)) { cons.Stars.Add(star); old.Stars.Remove(star); } } DialogResult = DialogResult.OK; Close(); }
private void SaveData() { string url = tBoxUrl.Text; string name = tBoxName.Text; if (!ValidateData(name)) { return; } if (isAddForm) { List <Star> stars = new List <Star>(); Constellation curr = new Constellation(stars, name, url); sky.Constellations.Add(curr); } else { cons.Url = url; cons.Name = name; } DialogResult = DialogResult.OK; Close(); }