示例#1
0
        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();
        }
示例#2
0
        public ShortestPath(GPSNavigation gps, Node start, Node end, Characteristic.CharacteristicTypes type)
        {
            this.gps   = gps;
            this.start = start;
            this.end   = end;

            FindShortestPath(type);
            SetPathInfoCharacteristic();
        }
示例#3
0
        // 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);
        }
示例#4
0
        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());
        }
示例#5
0
        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());
        }
示例#6
0
        // 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();
        }
示例#7
0
        //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);
        }
示例#8
0
        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);
        }
示例#9
0
        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;
                }
            }
        }
示例#10
0
 public IQueryable <Characteristic> CharacteristicsByType(Characteristic.CharacteristicTypes type)
 {
     return(context.Characteristics.Where(c => c.CharacteristicType == type));
 }