public LayerElementBuilding(MangoLayerElement ele, ElementIconSet icon, IconExtParamBuilding ext) : base(ele)
 {
     this.iconSet = icon;
     this.Width   = icon.icon.Width;
     this.Height  = icon.icon.Height;
     this.Ext     = ext;
 }
Beispiel #2
0
        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();
        }
 public LayerElementFence(MangoLayerElement ele, ElementIconSet icon, IconExtParamFence Ext) : base(ele)
 {
     this.iconSet = icon;
     this.Ext     = Ext;
     this.Type    = ElementType.TYPE_FENCE;
 }
 public LayerElement(MangoLayerElement ele, ElementIconSet icon) : base(ele)
 {
     this.iconSet = icon;
 }