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(); }
public ShortestPath(GPSNavigation gps, Node start, Node end, Characteristic.CharacteristicTypes type) { this.gps = gps; this.start = start; this.end = end; FindShortestPath(type); SetPathInfoCharacteristic(); }
// klik na slicicu za pronaci sve karakteristike private void tempFunctionForGetAllCharacteristic(Characteristic.CharacteristicTypes type) { //type=Store, Pharmacy... GPSDatabase gpsDatabase = new GPSDatabase(); Graphics g = pictureBox1.CreateGraphics(); List <Element> list = gpsDatabase.GetAllElementsWithCharacteristics(type); drawMap.drawAllElementsWithCharacteristic(g, list); }
public List <Edge> EdgesByChType(Characteristic.CharacteristicTypes type) { var typeCharacteristics = CharacteristicsByType(type); var typeEdges = from characteristic in typeCharacteristics join edge in qEdges on characteristic.ElementId equals edge.ElementId select edge; return(typeEdges.ToList()); }
public List <Node> NodesByChType(Characteristic.CharacteristicTypes type) { var typeCharacteristics = CharacteristicsByType(type); var typeNodes = from characteristic in typeCharacteristics join node in qNodes on characteristic.ElementId equals node.ElementId select node; return(typeNodes.ToList()); }
// bridu dodaje karakteristiku public void EdgeAddCharacteristic(Edge n, Characteristic.CharacteristicTypes x) { Characteristic newChar = new Characteristic(); newChar.ElementId = n.ElementId; newChar.CharacteristicType = x; this.gpsContext.Characteristics.Add(newChar); this.gpsContext.SaveChanges(); }
//vraca sve elemente s danom karakteristikom public List <Element> GetAllElementsWithCharacteristics(Characteristic.CharacteristicTypes type) { List <Element> list = new List <Element>(); var q = gpsContext.Characteristics.Where(c => c.CharacteristicType == type); foreach (var element in q) { list.Add(GetElementById(element.ElementId)); } return(list); }
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) { ErrorMsg f8 = new ErrorMsg(); 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 { ErrorMsg f8 = new ErrorMsg(); f8.ShowDialog(); return; } this.Close(); drawMap.AddEdge(sx, sy, sname, enumlist, smjer); }
public void FindShortestPath(Characteristic.CharacteristicTypes type) { double minDistance = Double.MaxValue; stop = null; var typeNodes = gps.NodesByChType(type); foreach (Node n in typeNodes) { double currentDistance = new ShortestPath(gps, start, n).distance + new ShortestPath(gps, n, end).distance; if (currentDistance < minDistance) { minDistance = currentDistance; stop = n; } } var typeEdges = gps.EdgesByChType(type); foreach (Edge e in typeEdges) { double currentDistance = new ShortestPath(gps, start, e.Start()).distance + e.Distance + new ShortestPath(gps, e.End(), end).distance; double reverseDistance = Double.MaxValue; if (e.SingleDirection == false) { reverseDistance = new ShortestPath(gps, start, e.End()).distance + e.Distance + new ShortestPath(gps, e.Start(), end).distance; } if (currentDistance < minDistance || reverseDistance < minDistance) { minDistance = Math.Min(currentDistance, reverseDistance); stop = e; } } }
public IQueryable <Characteristic> CharacteristicsByType(Characteristic.CharacteristicTypes type) { return(context.Characteristics.Where(c => c.CharacteristicType == type)); }