コード例 #1
0
        //网络表更新
        private void RefreshNetGrid()
        {
            NetGrid.Rows.Clear();
            IEnumerator <GMapRoute> ir = Net.Routes.GetEnumerator();

            if (NewNetMap.Count == 0)
            {
                return;
            }
            //IDictionaryEnumerator IdTor = NewNetMap.GetEnumerator();
            while (ir.MoveNext())
            {
                double    dist = 0;
                GMapRoute de   = (GMapRoute)ir.Current;
                string[]  name = de.Name.Split('-');
                if (DistMap.Contains(de.Name))
                {
                    dist = double.Parse((string)DistMap[de.Name]);
                }
                else
                {
                    dist = UtilityClass.CalcDistance(GetGpsFromName(name[0]), GetGpsFromName(name[1]));
                    DistMap.Add(de.Name, dist.ToString());
                }
                string[] rowstr = { (name[0]).TrimStart('节', '点'), name[1].TrimStart('节', '点'), (dist.ToString("F01")) };
                NetGrid.Rows.Add(rowstr);
            }
            NetGrid.Sort(NetGrid.Columns[0], ListSortDirection.Ascending);
            for (int i = 0; i < NetGrid.Rows.Count; i++)
            {
                DataGridViewComboBoxCell Dcell = (DataGridViewComboBoxCell)NetGrid.Rows[i].Cells[3];
                Dcell.Value       = Dcell.Items[0];
                Dcell.ToolTipText = Dcell.Value.ToString();
            }
        }
コード例 #2
0
        //判断是否选择了路由路线。
        private void routemap_MouseClick(object sender, MouseEventArgs e)
        {
            if (CurrentMarker != null)//点击节点时不响应
            {
                return;
            }
            PointLatLng p = routemap.FromLocalToLatLng(e.X, e.Y);

            foreach (GMapRoute r in Net.Routes)
            {
                double d = UtilityClass.CalcDistance(p, (PointLatLng)r.From) + UtilityClass.CalcDistance(p, (PointLatLng)r.To) - r.Distance * 1000;
                if (d < 10)
                {
                    if (CurrentRoute != null)
                    {
                        CurrentRoute.Stroke.Color = Color.WhiteSmoke;//将之前选择的路由颜色还原
                    }
                    if (!r.Equals(CurrentRoute))
                    {
                        CurrentRoute   = r; //
                        r.Stroke.Color = Color.DeepPink;
                        break;              //选择了另一节点,跳出
                    }
                    //又选择同一节点,说明是放弃选择
                    CurrentRoute = null;
                }
            }
        }
コード例 #3
0
        //领接节点表更新
        private void RefreshNeiborList(string startnode)
        {
            NeiborNodeLst.Rows.Clear();
            if (NewNetMap.Count == 0)
            {
                return;
            }
            IDictionaryEnumerator IdTor = NewNetMap.GetEnumerator();

            while (IdTor.MoveNext())
            {
                DictionaryEntry de = (DictionaryEntry)IdTor.Current;
                if (startnode == (string)de.Key)
                {
                    string[]      str    = { "节点配置", (string)de.Key, "节点位置", "纬度" };
                    double        lat    = double.Parse(XmlHelper.GetConfigValue(xmldoc, str));
                    string[]      lngstr = { "节点配置", (string)de.Key, "节点位置", "经度" };
                    double        lng    = double.Parse(XmlHelper.GetConfigValue(xmldoc, lngstr));
                    List <string> lst    = (List <string>)NewNetMap[de.Key];
                    foreach (string name in lst)
                    {
                        string[]    sstr    = { "节点配置", name, "节点位置", "纬度" };
                        double      slat    = double.Parse(XmlHelper.GetConfigValue(xmldoc, sstr));
                        string[]    lngsstr = { "节点配置", name, "节点位置", "经度" };
                        double      slng    = double.Parse(XmlHelper.GetConfigValue(xmldoc, lngsstr));
                        PointLatLng fr      = new PointLatLng(lat, lng);
                        PointLatLng to      = new PointLatLng(slat, slng);
                        double      d       = UtilityClass.CalcDistance(fr, to);
                        string[]    rowstr  = { ((string)de.Key).TrimStart('节', '点'), name.TrimStart('节', '点'), d.ToString("F01") };
                        NeiborNodeLst.Rows.Add(rowstr);
                    }
                }
            }
            NeiborNodeLst.Sort(NeiborNodeLst.Columns[0], ListSortDirection.Ascending);
            for (int i = 0; i < NeiborNodeLst.Rows.Count; i++)
            {
                DataGridViewComboBoxCell Dcell = (DataGridViewComboBoxCell)NeiborNodeLst.Rows[i].Cells[3];
                Dcell.Value       = Dcell.Items[0];
                Dcell.ToolTipText = Dcell.Value.ToString();
            }
            //领接节点表更新
        }
コード例 #4
0
        private void ShowLineAni(object obj)
        {
            List <PointLatLng> plist = (List <PointLatLng>)obj;
            PointLatLng        lastp = new PointLatLng();

            while (RouteisRunning)//循环演示
            {
                foreach (PointLatLng p in plist)
                {
                    if (!lastp.IsZero)
                    {
                        int time = (int)(UtilityClass.CalcDistance(lastp, p) * 1000 / 1500);
                        mf.LineEmitAnimation(ref routemap, lastp, p, time, "");
                        Thread.Sleep(time);
                    }
                    lastp = p;
                }
                //遍历完清零
                lastp.Lat = 0;
                lastp.Lng = 0;
            }
        }