private void OnAddFenceFinished() { if (drawFence.lines.Count == 0) { return; } IconExtParamFence ext = new IconExtParamFence(); ext.type = drawFence.type; ext.points = new PointF[drawFence.lines.Count]; for (int i = 0; i < ext.points.Length; i++) { Coordinate p = (drawFence.lines[i]); ext.points[i] = new PointF((float)p.X, (float)p.Y); } Coordinate p1 = (drawFence.lines[0]); LayerElementFence fence = new LayerElementFence(new MangoLayerElement(this.currentMap.id, p1, ElementType.TYPE_FENCE), deviceTypeList[drawFence.type].ToIconSet(), ext); this.deviceLayer.AddLayerElement(fence); this.mapBox1.Refresh(); if (this.OnElementAdd != null) { this.OnElementAdd.Invoke(fence); } }
public void LoadMap(MangoMap map, MangoLayer[] layers, MangoLayerElement[] elements) { this.Clear(); this.SetBackgroundColor(Color.FromArgb(map.backgroundColor)); this.SetMap(map); this.Zoom(map.defaultZoomLevel); List <ILayer> _layers = new List <ILayer>(); foreach (MangoLayer layer in layers) { ILayer mapLayer = this.LoadLayer(layer); if (mapLayer == null) { continue; } _layers.Add(mapLayer); } //添加标签层 foreach (ILayer _layer in _layers) { //当前图层是否有标签层 if (_layer is MangoVectorLayer) { MangoLayer layer = (_layer as MangoVectorLayer).Layer; if (layer.labelEnabled == 1) { this.AddLabelLayer(layer.name + "(标签层)", _layer as MangoVectorLayer); } } } // 添加设备层 DeviceLayer deviceLayer = this.AddDeviceLayer("DeviceLayer"); if (elements != null) { foreach (MangoLayerElement ele in elements) { switch (ele.deviceTypeCode) { case ElementType.TYPE_BUILDING: { IconExtParamBuilding ext = JsonConvert.DeserializeObject <IconExtParamBuilding>(ele.iconExt); Bitmap bitmap = new Bitmap(ext.filename); ElementIconSet set = new ElementIconSet(bitmap, null, null); LayerElementBuilding building = new LayerElementBuilding(ele, set, ext); deviceLayer.AddLayerElement(building); break; } case ElementType.TYPE_FENCE: { IconExtParamFence ext = JsonConvert.DeserializeObject <IconExtParamFence>(ele.iconExt); LayerElementFence fence = new LayerElementFence(ele, this.GetIconSet(ext.type), ext); deviceLayer.AddLayerElement(fence); break; } default: { LayerElement element = new LayerElement(ele, GetIconSet(ele.deviceTypeCode)); deviceLayer.AddLayerElement(element); break; } } } } this.Center(new Coordinate(map.defaultLatitude, map.defaultLongitude)); this.Refresh(); }