//dodavanje brida public void AddEdge(string start, string end, string name, List <Characteristic.CharacteristicTypes> list, bool smjer) { Form8 f8 = new Form8(); int kontrol = 0; Edge e = new Edge(); foreach (var elem in gpsDatabase.GetAllEdges()) { if (elem.Name == name) { f8.ShowDialog(); break; } else { e = gpsDatabase.AddEdge(start, end, name, smjer); kontrol = 1; break; } } if (kontrol == 1) { for (int i = 0; i < list.Count(); i++) { gpsDatabase.EdgeAddCharacteristic(e, list[i]); } } }
private void button1_Click(object sender, EventArgs e) { string sx = textBox1.Text.ToString(); string sy = textBox2.Text.ToString(); string sname = textBox3.Text.ToString(); if (sx == "" || sy == "" || sname == "") { f8.ShowDialog(); return; } List <Characteristic.CharacteristicTypes> enumlist = new List <Characteristic.CharacteristicTypes>(); foreach (object item in checkedListBox1.CheckedItems) { Characteristic.CharacteristicTypes en = (Characteristic.CharacteristicTypes)Enum.Parse(typeof(Characteristic.CharacteristicTypes), item.ToString()); enumlist.Add(en); } int x = Int32.Parse(sx); int y = Int32.Parse(sy); drawMap.AddNode(x, y, sname, enumlist); this.Close(); }
// dodavanje čvora public void AddNode(int kX, int kY, string name, List <Characteristic.CharacteristicTypes> list) { Form8 f8 = new Form8(); int kontrol = 0; Node n = new Node(); foreach (var elem in gpsDatabase.GetAllNodes()) { var node = (Node)gpsDatabase.GetElementById(elem.ElementId); if (node.X == kX && node.Y == kY) { f8.ShowDialog(); break; } else if (elem.Name == name) { f8.ShowDialog(); break; } else if (kX <= 0 || kX >= 521 || kY <= 0 || kY >= 351) { f8.ShowDialog(); break; } else { n = gpsDatabase.AddNode(kX, kY, name); kontrol = 1; break; } } //dodao je cvor -> provjerimo treba li karakteristike dodat if (kontrol == 1) { for (int i = 0; i < list.Count(); i++) { gpsDatabase.NodeAddCharacteristic(n, list[i]); } } }
private void button4_Click(object sender, EventArgs e) { userControl11.Hide(); userControl31.Hide(); GPSDatabase gpsDatabase = new GPSDatabase(); Node startNode = gpsDatabase.FindNodeByName(userControl21.textBox1.Text); Node endNode = gpsDatabase.FindNodeByName(userControl21.textBox2.Text); if (startNode != null && endNode != null) { userControl21.Hide(); button4.Hide(); Graphics g = pictureBox1.CreateGraphics(); userControl31.Show(); userControl31.label1.Text = startNode.Name; userControl31.label2.Text = endNode.Name; GPSNavigation gps = new GPSNavigation(); if (userControl21.isChecked == -1) { path = new ShortestPath(gps, startNode, endNode); } else { path = new ShortestPath(gps, startNode, endNode, (Characteristic.CharacteristicTypes)userControl21.isChecked); } pictureBox1.Refresh(); } else { string errorMessage = "Navedene lokacije ne postoje na karti:\n"; errorMessage += (startNode == null ? userControl21.textBox1.Text : "") + Environment.NewLine; errorMessage += (endNode == null ? userControl21.textBox2.Text : ""); userControl21.Show(); button4.Show(); Form8 notFoundForm = new Form8(errorMessage); notFoundForm.ShowDialog(); } }
//kada se klikne na ikonu ---search--- private void button8_Click(object sender, EventArgs e) { GPSDatabase gpsDatabase = new GPSDatabase(); //gledamo 1. postoji li uneseni element u bazi Element temp = gpsDatabase.FindElementByName(textBox1.Text); userControl21.Hide(); button4.Hide(); userControl31.Hide(); if (upDownInfo != 2) { upDownInfo = 1; } if (temp == null) { upDownInfo = 0; Form8 notFoundForm = new Form8("Unijeli ste lokaciju\nkoja ne postoji na karti!"); notFoundForm.ShowDialog(); return; } List <Characteristic.CharacteristicTypes> locations = gpsDatabase.GetCharacteristicsByElementId(temp.ElementId); userControl11.label1.Text = temp.Name; userControl11.label3.Text = ""; textBox1.Text = ""; foreach (Characteristic.CharacteristicTypes type in locations) { userControl11.label3.Text += " - " + type + Environment.NewLine; } Graphics g = pictureBox1.CreateGraphics(); drawMap.drawGraph(g, streets); drawMap.drawNodeOrEdgeLocation(g, temp.ElementId); }
private void button1_Click(object sender, EventArgs e) { string sx = comboBox1.Text.ToString(); string sy = comboBox2.Text.ToString(); string sname = textBox1.Text.ToString(); bool smjer = true; if (radioButton1.Checked == true) { smjer = true; } if (radioButton2.Checked == true) { smjer = false; } if (radioButton1.Checked == false && radioButton2.Checked == false) { Form8 f8 = new Form8(); f8.ShowDialog(); return; } List <Characteristic.CharacteristicTypes> enumlist = new List <Characteristic.CharacteristicTypes>(); foreach (object item in checkedListBox1.CheckedItems) { Characteristic.CharacteristicTypes en = (Characteristic.CharacteristicTypes)Enum.Parse(typeof(Characteristic.CharacteristicTypes), item.ToString()); enumlist.Add(en); } if (sname == "") // ako nije unio nista za ime javi gresku { Form8 f8 = new Form8(); f8.ShowDialog(); return; } this.Close(); drawMap.AddEdge(sx, sy, sname, enumlist, smjer); }