예제 #1
0
 private void buttonAddMap_Click(object sender, EventArgs e)
 {
     MapFile mf = new MapFile("", "");
     FormMap frm = new FormMap(mf);
     if(frm.ShowDialog(this) == DialogResult.OK)
     {
         ListViewItem item = new ListViewItem(mf.Name);
         item.SubItems.Add(mf.File);
         listViewMaps.Items.Add(item);
         mlist.Add(mf);
     }
 }
예제 #2
0
파일: FormMap.cs 프로젝트: suwadee2015/GPS
 public FormMap(MapFile m)
 {
     InitializeComponent();
     this.SetFormStyle(false, false, false, true);
     mf = m;
     textBoxMapName.Text = mf.Name;
     textBoxMapFile.Text = mf.File;
     gList = new List<GeoInfoLayer>();
     foreach(GeoInfoLayer gl in mf.GeoInfoList)
     {
         ListViewItem item = new ListViewItem(gl.TableName);
         item.SubItems.Add(gl.ColName);
         item.SubItems.Add(LAYER_TYPE[gl.Type]);
         item.SubItems.Add(gl.Distance.ToString());
         item.SubItems.Add(gl.Head);
         item.SubItems.Add(gl.Foot);
         listViewLayers.Items.Add(item);
         gList.Add(gl);
     }
 }
예제 #3
0
파일: FormMain.Map.cs 프로젝트: yfyf510/GPS
        //初始化地图,更换地图
        private void InitMap(MapFile mapFile)
        {
            currentMap = mapFile;
            if (preMap == mapFile.File)
            {
                return;
            }
            mapControl.Map.Clear();
            mapControl.Map.Load(MapInfo.Mapping.MapLoader.CreateFromFile(mapFile.File));
            mapControlOver.Map.Load(MapInfo.Mapping.MapLoader.CreateFromFile(mapFile.File));
            initZoom = mapControl.Map.Zoom;

            initCenter = mapControl.Map.Bounds.Center();
            ClearDistanceLayer();
            preMap = mapFile.File;

            comboBoxLayers.Items.Clear();
            listBoxLayerPlace.Items.Clear();
            for (int i = 1; i < mapControl.Map.Layers.Count; i++)
            {
                if (mapControl.Map.Layers[i].Name != "Watching" && mapControl.Map.Layers[i].Name != "Place" &&
                    mapControl.Map.Layers[i].Name != "HisPos" && mapControl.Map.Layers[i].Name != "HisLine" &&
                    mapControl.Map.Layers[i].Name != "HisAlarm" && mapControl.Map.Layers[i].Name != "Alarm" &&
                    mapControl.Map.Layers[i].Name != "DisLine" && mapControl.Map.Layers[i].Name != "Temp" &&
                    mapControl.Map.Layers[i].Name != "HisPlayPos" && mapControl.Map.Layers[i].Name != "HisPlayLine" &&
                    mapControl.Map.Layers[i].Name != "Watching_L" && mapControl.Map.Layers[i].Name != "Place_L" &&
                    mapControl.Map.Layers[i].Name != "HisPos_L" && mapControl.Map.Layers[i].Name != "HisAlarm_L" &&
                    mapControl.Map.Layers[i].Name != "Alarm_L" && mapControl.Map.Layers[i].Name != "HisPlayPos_L" &&
                    mapControl.Map.Layers[i].Name != "Administrative")
                {
                    comboBoxLayers.Items.Add(mapControl.Map.Layers[i].Name);
                }
            }
            if (comboBoxLayers.Items.Count > 0)
            {
                comboBoxLayers.SelectedIndex = 0;
            }

            if (tableWatching == null)
            {
                //监控点图层
                TableInfo ti = TableInfoFactory.CreateTemp("Watching");
                ti.Columns.Add(ColumnFactory.CreateStringColumn("ID", 10));
                ti.Columns.Add(ColumnFactory.CreateStringColumn("Label", 20));
                tableWatching = Session.Current.Catalog.CreateTable(ti);
                TextStyle ts = new TextStyle();
                ts.Font.Size       = 8;
                ts.Font.FontWeight = FontWeight.Bold;
                ts.Font.ForeColor  = Color.Green;
                labLayWatching     = new LabelLayer("Watching_L", "Watching_L");
                LabelSource source = new LabelSource(tableWatching);
                source.DefaultLabelProperties.Caption                 = "Label";
                source.DefaultLabelProperties.Style                   = ts;
                source.DefaultLabelProperties.CalloutLine.Use         = false;
                source.DefaultLabelProperties.Layout.Alignment        = MapInfo.Text.Alignment.CenterRight;
                source.DefaultLabelProperties.Layout.Offset           = 10;
                source.DefaultLabelProperties.Visibility.AllowOverlap = true;
                //labLayWatching = (LabelLayer)mapControl.Map.Layers["Watching_L"];
                labLayWatching.Sources.Append(source);
                //自定义标注点图层
                TableInfo ti2 = TableInfoFactory.CreateTemp("Place");
                ti2.Columns.Add(ColumnFactory.CreateStringColumn("Label", 20));
                tablePlace = Session.Current.Catalog.CreateTable(ti2);
                TextStyle ts2 = new TextStyle();
                ts2.Font.Size       = 8;
                ts2.Font.FontWeight = FontWeight.Bold;
                ts2.Font.ForeColor  = Color.Blue;
                labLayPlace         = new LabelLayer("Place_L", "Place_L");
                LabelSource source2 = new LabelSource(tablePlace);
                source2.DefaultLabelProperties.Caption                 = "Label";
                source2.DefaultLabelProperties.Style                   = ts2;
                source2.DefaultLabelProperties.CalloutLine.Use         = false;
                source2.DefaultLabelProperties.Layout.Alignment        = MapInfo.Text.Alignment.CenterRight;
                source2.DefaultLabelProperties.Layout.Offset           = 10;
                source2.DefaultLabelProperties.Visibility.AllowOverlap = false;
                //labLayPlace = (LabelLayer)mapControl.Map.Layers["Place_L"];
                labLayPlace.Sources.Append(source2);
                //历史轨迹点图层
                TableInfo ti3 = TableInfoFactory.CreateTemp("HisPos");
                ti3.Columns.Add(ColumnFactory.CreateStringColumn("Label", 20));
                tableHisPos = Session.Current.Catalog.CreateTable(ti3);
                TextStyle ts3 = new TextStyle();
                ts3.Font.Size       = 8;
                ts3.Font.FontWeight = FontWeight.Bold;
                ts3.Font.ForeColor  = Color.Navy;
                labLayHisPos        = new LabelLayer("HisPos_L", "HisPos_L");
                LabelSource source3 = new LabelSource(tableHisPos);
                source3.DefaultLabelProperties.Caption                 = "Label";
                source3.DefaultLabelProperties.Style                   = ts3;
                source3.DefaultLabelProperties.CalloutLine.Use         = false;
                source3.DefaultLabelProperties.Layout.Alignment        = MapInfo.Text.Alignment.CenterRight;
                source3.DefaultLabelProperties.Layout.Offset           = 10;
                source3.DefaultLabelProperties.Visibility.AllowOverlap = false;
                //labLayHisPos = (LabelLayer)mapControl.Map.Layers["HisPos_L"];
                labLayHisPos.Sources.Append(source3);
                //历史轨迹线图层
                TableInfo ti4 = TableInfoFactory.CreateTemp("HisLine");
                tableHisLine = Session.Current.Catalog.CreateTable(ti4);
                //历史报警点图层
                TableInfo ti5 = TableInfoFactory.CreateTemp("HisAlarm");
                ti5.Columns.Add(ColumnFactory.CreateStringColumn("Label", 20));
                tableHisAlarm = Session.Current.Catalog.CreateTable(ti5);
                TextStyle ts5 = new TextStyle();
                ts5.Font.Size       = 8;
                ts5.Font.FontWeight = FontWeight.Bold;
                ts5.Font.ForeColor  = Color.Red;
                labLayHisAlarm      = new LabelLayer("HisAlarm_L", "HisAlarm_L");
                LabelSource source5 = new LabelSource(tableHisAlarm);
                source5.DefaultLabelProperties.Caption                 = "Label";
                source5.DefaultLabelProperties.Style                   = ts5;
                source5.DefaultLabelProperties.CalloutLine.Use         = false;
                source5.DefaultLabelProperties.Layout.Alignment        = MapInfo.Text.Alignment.CenterRight;
                source5.DefaultLabelProperties.Layout.Offset           = 10;
                source5.DefaultLabelProperties.Visibility.AllowOverlap = false;
                //labLayHisAlarm = (LabelLayer)mapControl.Map.Layers["HisAlarm_L"];
                labLayHisAlarm.Sources.Append(source5);
                //报警点图层
                TableInfo ti6 = TableInfoFactory.CreateTemp("Alarm");
                ti6.Columns.Add(ColumnFactory.CreateStringColumn("Label", 20));
                tableAlarm = Session.Current.Catalog.CreateTable(ti6);
                TextStyle ts6 = new TextStyle();
                ts6.Font.Size       = 8;
                ts6.Font.FontWeight = FontWeight.Bold;
                ts6.Font.ForeColor  = Color.Red;
                labLayAlarm         = new LabelLayer("Alarm_L", "Alarm_L");
                LabelSource source6 = new LabelSource(tableAlarm);
                source6.DefaultLabelProperties.Caption                 = "Label";
                source6.DefaultLabelProperties.Style                   = ts6;
                source6.DefaultLabelProperties.CalloutLine.Use         = false;
                source6.DefaultLabelProperties.Layout.Alignment        = MapInfo.Text.Alignment.CenterRight;
                source6.DefaultLabelProperties.Layout.Offset           = 10;
                source6.DefaultLabelProperties.Visibility.AllowOverlap = false;
                //labLayAlarm = (LabelLayer)mapControl.Map.Layers["Alarm_L"];
                labLayAlarm.Sources.Append(source6);
                //测距线图层
                TableInfo ti7 = TableInfoFactory.CreateTemp("DisLine");
                tableDisLine = Session.Current.Catalog.CreateTable(ti7);
                //临时图层
                TableInfo ti8 = TableInfoFactory.CreateTemp("Temp");
                tableTemp = Session.Current.Catalog.CreateTable(ti8);
                //轨迹回放点图层
                TableInfo ti9 = TableInfoFactory.CreateTemp("HisPlayPos");
                ti9.Columns.Add(ColumnFactory.CreateStringColumn("Label", 20));
                tableHisPlay = Session.Current.Catalog.CreateTable(ti9);
                TextStyle ts9 = new TextStyle();
                ts9.Font.Size       = 8;
                ts9.Font.FontWeight = FontWeight.Bold;
                ts9.Font.ForeColor  = Color.Black;
                labLayHisPlayPos    = new LabelLayer("HisPlayPos_L", "HisPlayPos_L");
                LabelSource source9 = new LabelSource(tableHisPlay);
                source9.DefaultLabelProperties.Caption                 = "Label";
                source9.DefaultLabelProperties.Style                   = ts9;
                source9.DefaultLabelProperties.CalloutLine.Use         = false;
                source9.DefaultLabelProperties.Layout.Alignment        = MapInfo.Text.Alignment.CenterRight;
                source9.DefaultLabelProperties.Layout.Offset           = 10;
                source9.DefaultLabelProperties.Visibility.AllowOverlap = false;
                labLayHisPlayPos.Sources.Append(source9);
                //轨迹回放线图层
                TableInfo ti10 = TableInfoFactory.CreateTemp("HisPlayLine");
                tableHisPlayLine = Session.Current.Catalog.CreateTable(ti10);
            }

            FeatureLayer lyr = new FeatureLayer(tableWatching);

            mapControl.Map.Layers.Insert(0, lyr);
            FeatureLayer lyr2 = new FeatureLayer(tablePlace);

            mapControl.Map.Layers.Insert(0, lyr2);

            FeatureLayer lyr3 = new FeatureLayer(tableHisPos);

            mapControl.Map.Layers.Insert(0, lyr3);
            FeatureLayer lyr4 = new FeatureLayer(tableHisLine);

            mapControl.Map.Layers.Insert(0, lyr4);

            FeatureLayer lyr5 = new FeatureLayer(tableHisAlarm);

            mapControl.Map.Layers.Insert(0, lyr5);

            FeatureLayer lyr6 = new FeatureLayer(tableAlarm);

            mapControl.Map.Layers.Insert(0, lyr6);
            FeatureLayer lyr7 = new FeatureLayer(tableDisLine);

            mapControl.Map.Layers.Insert(0, lyr7);

            FeatureLayer lyr8 = new FeatureLayer(tableTemp);

            mapControl.Map.Layers.Insert(0, lyr8);

            FeatureLayer lyr9 = new FeatureLayer(tableHisPlay);

            mapControl.Map.Layers.Insert(0, lyr9);
            FeatureLayer lyr10 = new FeatureLayer(tableHisPlayLine);

            mapControl.Map.Layers.Insert(0, lyr10);

            //标注图层
            mapControl.Map.Layers.Add(labLayWatching);
            mapControl.Map.Layers.Add(labLayPlace);
            mapControl.Map.Layers.Add(labLayHisPos);
            mapControl.Map.Layers.Add(labLayHisAlarm);
            mapControl.Map.Layers.Add(labLayAlarm);
            mapControl.Map.Layers.Add(labLayHisPlayPos);
        }
예제 #4
0
파일: Config.cs 프로젝트: suwadee2015/GPS
 public MapFile(MapFile mf)
 {
     name = mf.name;
     file = mf.file;
     foreach(GeoInfoLayer gl in mf.geoInfoList)
         geoInfoList.Add(new GeoInfoLayer(gl));
 }
예제 #5
0
파일: Config.cs 프로젝트: suwadee2015/GPS
        /// <summary>
        /// ���������ļ�
        /// </summary>
        /// <returns></returns>
        public static bool loadFromFile()
        {
            defaultMap.Name = "ȫ��ͼ";
            defaultMap.File = APP_PATH + "maps\\china\\map.gst";
            defaultMap.GeoInfoList.Clear();
            defaultMap.GeoInfoList.Add(new GeoInfoLayer("ʡ��", "Name", 0, 0, "", ""));
            defaultMap.GeoInfoList.Add(new GeoInfoLayer("�н�", "Name", 0, 0, "", ""));
            defaultMap.GeoInfoList.Add(new GeoInfoLayer("���ؽ�", "Name", 0, 0, "", ""));
            defaultMap.GeoInfoList.Add(new GeoInfoLayer("����", "Name", 1, 200, "", ""));
            defaultMap.GeoInfoList.Add(new GeoInfoLayer("ʡ��", "Name", 1, 200, "", ""));
            defaultMap.GeoInfoList.Add(new GeoInfoLayer("�е�", "Name", 1, 150, "", ""));
            defaultMap.GeoInfoList.Add(new GeoInfoLayer("�ص�", "Name", 1, 100, "", ""));
            defaultMap.GeoInfoList.Add(new GeoInfoLayer("��Ϣ��", "Name", 1, 200, "", "����"));
            bool ret = false;
            try
            {
                XmlDocument XMLDom = new XmlDocument();
                XMLDom.Load(APP_PATH + FILE);
                XmlElement root = XMLDom.DocumentElement;
                host = readXmlNode(root, "host");
                port = Int32.Parse(readXmlNode(root, "port"));
                userType = Int32.Parse(readXmlNode(root, "userType"));
                user = readXmlNode(root, "user");
                pw = Pub.decode(readXmlNode(root, "pw"));
                autoLogin = (readXmlNode(root, "autoLogin") == "1");
                autoReconn = (readXmlNode(root, "autoReconn") == "1");
                autoAlarmList = (readXmlNode(root, "autoAlarmList") == "1");
                autoWatchOnPoint = (readXmlNode(root, "autoWatchOnPoint") == "1");
                autoWatchOnHandleAlarm = (readXmlNode(root, "autoWatchOnHandleAlarm") == "1");
                autoChatForm = (readXmlNode(root, "autoChatForm") == "1");
                autoGetCarGeoInfo = (readXmlNode(root, "autoGetCarGeoInfo") == "1");
                gisPort = Int32.Parse(readXmlNode(root, "telPort"));
                autoStartGis = (readXmlNode(root, "autoStartGis") == "1");

                myzoom = double.Parse(readXmlNode(root, "myzoom"));
                lo = double.Parse(readXmlNode(root,"lo"));
                la = double.Parse(readXmlNode(root,"la"));

                XmlNodeList mlist = root.GetElementsByTagName("maps");

                mapList.Clear();
                for(int i = 0; i < mlist.Count; i++)
                {
                    MapFile mf = new MapFile(readXmlNode(mlist.Item(i) as XmlElement, "name"), readXmlNode(mlist.Item(i) as XmlElement, "file"));
                    XmlNodeList llist = (mlist[i] as XmlElement).GetElementsByTagName("layers");
                    for(int j = 0; j < llist.Count; j++)
                    {
                        GeoInfoLayer gi = new GeoInfoLayer();
                        gi.TableName = readXmlNode(llist.Item(j) as XmlElement, "tableName");
                        gi.ColName = readXmlNode(llist.Item(j) as XmlElement, "colName");
                        gi.Type = Int32.Parse(readXmlNode(llist.Item(j) as XmlElement, "type"));
                        gi.Distance = Int32.Parse(readXmlNode(llist.Item(j) as XmlElement, "distance"));
                        gi.Head = readXmlNode(llist.Item(j) as XmlElement, "head");
                        gi.Foot = readXmlNode(llist.Item(j) as XmlElement, "foot");
                        mf.GeoInfoList.Add(gi);
                    }
                    mapList.Add(mf);
                }
                XmlNodeList hlist = root.GetElementsByTagName("hosts");
                hostList.Clear();
                for(int i = 0; i < hlist.Count; i++)
                {
                    hostList.Add(new HostConfig(readXmlNode(hlist.Item(i) as XmlElement, "host"), Int32.Parse(readXmlNode(hlist.Item(i) as XmlElement, "port"))));
                }
                XmlNodeList ulist = root.GetElementsByTagName("users");
                userList.Clear();
                for(int i = 0; i < ulist.Count; i++)
                {
                    userList.Add(new UserConfig(readXmlNode(ulist.Item(i) as XmlElement, "name"), Int32.Parse(readXmlNode(ulist.Item(i) as XmlElement, "type"))));
                }
                ret = true;

            }
            catch
            {
                saveToFile();
            }
            return ret;
        }
예제 #6
0
파일: Config.cs 프로젝트: yfyf510/GPS
        /// <summary>
        /// 载入配置文件
        /// </summary>
        /// <returns></returns>
        public static bool loadFromFile()
        {
            defaultMap.Name = "全国图";
            defaultMap.File = APP_PATH + "maps\\china\\map.gst";
            defaultMap.GeoInfoList.Clear();
            defaultMap.GeoInfoList.Add(new GeoInfoLayer("省界", "Name", 0, 0, "", ""));
            defaultMap.GeoInfoList.Add(new GeoInfoLayer("市界", "Name", 0, 0, "", ""));
            defaultMap.GeoInfoList.Add(new GeoInfoLayer("区县界", "Name", 0, 0, "", ""));
            defaultMap.GeoInfoList.Add(new GeoInfoLayer("高速", "Name", 1, 200, "", ""));
            defaultMap.GeoInfoList.Add(new GeoInfoLayer("省道", "Name", 1, 200, "", ""));
            defaultMap.GeoInfoList.Add(new GeoInfoLayer("市道", "Name", 1, 150, "", ""));
            defaultMap.GeoInfoList.Add(new GeoInfoLayer("县道", "Name", 1, 100, "", ""));
            defaultMap.GeoInfoList.Add(new GeoInfoLayer("信息点", "Name", 1, 200, "", "附近"));
            bool ret = false;

            try
            {
                XmlDocument XMLDom = new XmlDocument();
                XMLDom.Load(APP_PATH + FILE);
                XmlElement root = XMLDom.DocumentElement;
                host                   = readXmlNode(root, "host");
                port                   = Int32.Parse(readXmlNode(root, "port"));
                userType               = Int32.Parse(readXmlNode(root, "userType"));
                user                   = readXmlNode(root, "user");
                pw                     = Pub.decode(readXmlNode(root, "pw"));
                autoLogin              = (readXmlNode(root, "autoLogin") == "1");
                autoReconn             = (readXmlNode(root, "autoReconn") == "1");
                autoAlarmList          = (readXmlNode(root, "autoAlarmList") == "1");
                autoWatchOnPoint       = (readXmlNode(root, "autoWatchOnPoint") == "1");
                autoWatchOnHandleAlarm = (readXmlNode(root, "autoWatchOnHandleAlarm") == "1");
                autoChatForm           = (readXmlNode(root, "autoChatForm") == "1");
                autoGetCarGeoInfo      = (readXmlNode(root, "autoGetCarGeoInfo") == "1");
                gisPort                = Int32.Parse(readXmlNode(root, "telPort"));
                autoStartGis           = (readXmlNode(root, "autoStartGis") == "1");

                myzoom = double.Parse(readXmlNode(root, "myzoom"));
                lo     = double.Parse(readXmlNode(root, "lo"));
                la     = double.Parse(readXmlNode(root, "la"));

                XmlNodeList mlist = root.GetElementsByTagName("maps");


                mapList.Clear();
                for (int i = 0; i < mlist.Count; i++)
                {
                    MapFile     mf    = new MapFile(readXmlNode(mlist.Item(i) as XmlElement, "name"), readXmlNode(mlist.Item(i) as XmlElement, "file"));
                    XmlNodeList llist = (mlist[i] as XmlElement).GetElementsByTagName("layers");
                    for (int j = 0; j < llist.Count; j++)
                    {
                        GeoInfoLayer gi = new GeoInfoLayer();
                        gi.TableName = readXmlNode(llist.Item(j) as XmlElement, "tableName");
                        gi.ColName   = readXmlNode(llist.Item(j) as XmlElement, "colName");
                        gi.Type      = Int32.Parse(readXmlNode(llist.Item(j) as XmlElement, "type"));
                        gi.Distance  = Int32.Parse(readXmlNode(llist.Item(j) as XmlElement, "distance"));
                        gi.Head      = readXmlNode(llist.Item(j) as XmlElement, "head");
                        gi.Foot      = readXmlNode(llist.Item(j) as XmlElement, "foot");
                        mf.GeoInfoList.Add(gi);
                    }
                    mapList.Add(mf);
                }
                XmlNodeList hlist = root.GetElementsByTagName("hosts");
                hostList.Clear();
                for (int i = 0; i < hlist.Count; i++)
                {
                    hostList.Add(new HostConfig(readXmlNode(hlist.Item(i) as XmlElement, "host"), Int32.Parse(readXmlNode(hlist.Item(i) as XmlElement, "port"))));
                }
                XmlNodeList ulist = root.GetElementsByTagName("users");
                userList.Clear();
                for (int i = 0; i < ulist.Count; i++)
                {
                    userList.Add(new UserConfig(readXmlNode(ulist.Item(i) as XmlElement, "name"), Int32.Parse(readXmlNode(ulist.Item(i) as XmlElement, "type"))));
                }
                ret = true;
            }
            catch
            {
                saveToFile();
            }
            return(ret);
        }