private void buttonPridat_Click(object sender, EventArgs e) { if (textBoxNazev.Text.Length == 0 || textBoxX.Left == 0 || textBoxY.Text.Length == 0) { MessageBox.Show("Některý z parametrů není zadán"); return; } try { CestyGraf.Vrchol v = new CestyGraf.Vrchol(textBoxNazev.Text, double.Parse(textBoxX.Text), double.Parse(textBoxY.Text)); Mesto = v; DialogResult = System.Windows.Forms.DialogResult.OK; } catch (Exception) { MessageBox.Show("Některý z parametrů není zadán správně"); return; } }
public CestyGraf.Vrchol DejPolohu() { CestyGraf.Vrchol v = new CestyGraf.Vrchol(); v.Souradnice = new CestyGraf.Bod(); double vzdalenostX = Math.Abs(HranaPoloha.Vrchol1.Souradnice.X - HranaPoloha.Vrchol2.Souradnice.X); double vzdalenostY = Math.Abs(HranaPoloha.Vrchol1.Souradnice.Y - HranaPoloha.Vrchol2.Souradnice.Y); double vzdalenostPrepona = VzdalenostOdV1 + VzdalenostOdV2; double koeficient1 = VzdalenostOdV1 / vzdalenostPrepona; v.Souradnice.X = vzdalenostX * koeficient1; v.Souradnice.Y = vzdalenostY * koeficient1; if (HranaPoloha.Vrchol1.Souradnice.X > HranaPoloha.Vrchol2.Souradnice.X) { v.Souradnice.X *= -1; } if (HranaPoloha.Vrchol1.Souradnice.Y > HranaPoloha.Vrchol2.Souradnice.Y) { v.Souradnice.Y *= -1; } v.Souradnice.X += HranaPoloha.Vrchol1.Souradnice.X; v.Souradnice.Y += HranaPoloha.Vrchol1.Souradnice.Y; return v; }
public List<CestyGraf.Vrchol> NactiVrcholy() { List<CestyGraf.Vrchol> vrcholy = new List<CestyGraf.Vrchol>(); if (sr.BaseStream.Length == 0) { return vrcholy; } sr.BaseStream.Seek(0, SeekOrigin.Begin); int pocet = int.Parse(sr.ReadLine()); string[] pom = null; for (int i = 0; i < pocet; i++) { pom = null; pom = sr.ReadLine().Split(';'); CestyGraf.Vrchol c = new CestyGraf.Vrchol(pom[0], double.Parse(pom[1]), double.Parse(pom[2])); vrcholy.Add(c); } return vrcholy; }
private void comboBoxMesto_SelectedIndexChanged(object sender, EventArgs e) { MestoProOdebrani = comboBoxMesto.Items[comboBoxMesto.SelectedIndex] as CestyGraf.Vrchol; }