Exemplo n.º 1
0
        /**
         * 地面站box
         * */
        void frm_changebox7_event(Boolean selected, int flag)
        {
            if (selected)
            {
                if (1 == flag || (2 == flag && landStation == true))
                {
                    landStation = true;
                    landStationOverlay.Clear();
                    this.gMapControl1.Overlays.Add(landStationOverlay);

                    List <Dictionary <string, object> > result = ProfileHelper.Instance.Select("SELECT * FROM LandStation");

                    foreach (Dictionary <string, object> dictionary in result)
                    {
                        String          name            = Convert.ToString(dictionary["Name"]);
                        double          lat             = Convert.ToDouble(dictionary["Lat"]);
                        double          lang            = Convert.ToDouble(dictionary["Lng"]);
                        PointLatLng     point           = new PointLatLng(lat, lang);
                        GMapLandStation gMapLandStation = new GMapLandStation(point, name);
                        landStationOverlay.Markers.Add(gMapLandStation);
                    }

                    gMapControl1.Refresh();

                    // 是否要显示距离环
                    frm_changebox10_event(landDistenceCircle);
                }
            }
            else
            {
                if (1 == flag)
                {
                    landStation = false;
                    landStationOverlay.Clear();
                    this.gMapControl1.Overlays.Remove(landStationOverlay);
                    gMapControl1.Refresh();
                }
            }
            initListAirplaneCheck(false);
        }
Exemplo n.º 2
0
        private void mapControl_OnMarkerClick(GMapMarker item, MouseEventArgs e)
        {
            if (item is GMapAirPlane)
            {
                GMapAirPlane gMapAirPlane = item as GMapAirPlane;
                gMapAirPlane.Pen = new Pen(Brushes.Red, 2);
                if (!listAirplaneCheck.ContainsKey(gMapAirPlane.AirPlaneMarkerInfo.sModeAddress))
                {
                    listAirplaneCheck.Add(gMapAirPlane.AirPlaneMarkerInfo.sModeAddress, gMapAirPlane.AirPlaneMarkerInfo.sModeAddress);
                    // 插入数据库
                    String flightNo     = gMapAirPlane.AirPlaneMarkerInfo.flightNo;
                    String sModeAddress = Convert.ToString(gMapAirPlane.AirPlaneMarkerInfo.sModeAddress);

                    ProfileHelper.Instance.Update("INSERT INTO PlaneFollow (ID, Type, IDNum, Length) VALUES (NULL, 1, '" + sModeAddress + "', 0)");
                }
                else
                {
                    int     sModeAddress = gMapAirPlane.AirPlaneMarkerInfo.sModeAddress;
                    Boolean isCommon     = false;
                    List <Dictionary <string, object> > result = ProfileHelper.Instance.Select("SELECT * FROM CommonPlane");
                    foreach (Dictionary <string, object> dictionary in result)
                    {
                        int sModeAddressSel = Convert.ToInt32(dictionary["SModeAddress"]);
                        if (sModeAddressSel == sModeAddress)
                        {
                            isCommon = true;
                        }
                    }

                    if (isCommon)
                    {
                        MessageBox.Show("常用飞机不可以直接在关注列表中直接删除,请去<常用飞行器>中删除!");
                        return;
                    }
                    else
                    {
                        pointPlaneLand.Remove(sModeAddress);
                        ProfileHelper.Instance.Update("Delete FROM PlaneFollow WHERE Type = 1 AND IDNum = \"" + sModeAddress + "\"");
                    }
                }
            }
            else if (item is GMapLandStation)
            {
                GMapLandStation gMapLandStation = item as GMapLandStation;
                // 根据name查出地面站信息
                List <Dictionary <string, object> > stationList = ProfileHelper.Instance.Select("SELECT * FROM LandStation WHERE Name = '" + gMapLandStation.Name + "'");
                if (stationList.Count() > 0)
                {
                    Dictionary <string, object> dictionary = stationList[0];
                    int id = Convert.ToInt32(dictionary["ID"]);
                    List <Dictionary <string, object> > result =
                        ProfileHelper.Instance.Select("SELECT * FROM PlaneFollow WHERE Type = 2 AND IDNum = " + id);
                    if (result.Count() == 0)
                    {
                        ProfileHelper.Instance.Update("INSERT INTO PlaneFollow (ID, Type, IDNum, Length) VALUES (NULL, 2, '" + id + "', 0)");
                    }
                    else
                    {
                        ProfileHelper.Instance.Update("Delete FROM PlaneFollow WHERE Type = 2 AND IDNum = \"" + id + "\"");
                    }
                }
            }
            else
            {
                panel1.Visible   = false;
                textBox1.Visible = false;
                textBox2.Visible = false;
                textBox3.Visible = false;
                textBox4.Visible = false;
                textBox5.Visible = false;
            }
            initListAirplaneCheck(false);
        }