public LabelLayerProperty(MangoLayer layer)
 {
     InitializeComponent();
     this.layer = layer;
     this.color = ParseUtil.ParseColor(layer.labelColor);
     this.font  = ParseUtil.ParseFont(layer.labelFont, layer.labelFontSize);
     this.Load += LabelLayerProperty_Load;
 }
Ejemplo n.º 2
0
        public ILayer LoadLayer(MangoLayer layer)
        {
            LayerType type = (LayerType)layer.type;

            switch (type)
            {
            case LayerType.SHAPE_FILE:
                return(LoadShapeFileLayer(layer));

            case LayerType.GDI_IMAGE:
                return(LoadGDILayer(layer));
            }

            return(null);
        }
Ejemplo n.º 3
0
        public void CreateLayer(string filename)
        {
            MangoLayer layer = new MangoLayer();

            layer.type = (int)(filename.Contains(".shp") ? LayerType.SHAPE_FILE : LayerType.GDI_IMAGE);


            layer.name           = Path.GetFileNameWithoutExtension(filename);
            layer.filenamePrefix = Path.GetFileName(filename);//此处仅记录文件名和扩展名,基于整个应用默认将地图路径作为可配置的原因,切方便不同客户端部署
            layer.mapId          = this.currentMap.id;
            this.LoadLayer(layer);
            this.Refresh();
            if (this.OnLayerCreate != null)
            {
                this.OnLayerCreate.Invoke(layer);
            }
        }
Ejemplo n.º 4
0
        private ILayer LoadGDILayer(MangoLayer layer)
        {
            if (layer.filenamePrefix == null || layer.filenamePrefix == "")
            {
                return(null);
            }
            string filename = MAP_PATH + layer.filenamePrefix;

            if (!System.IO.File.Exists(filename))
            {
                return(null);
            }

            MangoGDILayer gdiImageLayer = new MangoGDILayer(layer, filename);

            this.mapBox1.Map.Layers.Add(gdiImageLayer);
            return(gdiImageLayer);
        }
Ejemplo n.º 5
0
        public ILayer LoadShapeFileLayer(MangoLayer layer)
        {
            if (layer.filenamePrefix == null || layer.filenamePrefix == "")
            {
                return(null);
            }
            string filename = MAP_PATH + layer.filenamePrefix;     // 默认载入文件名, .shp 为层文件名,每个图层包括前缀名+ (.shp,.dbf,.sbx 等若干文件)

            if (!System.IO.File.Exists(filename))
            {
                return(null);
            }
            ShapeFile        shapeFileData  = new ShapeFile(filename);
            MangoVectorLayer shapeFileLayer = new MangoVectorLayer(layer, shapeFileData);

            shapeFileLayer.RenderPrepare();
            this.mapBox1.Map.Layers.Add(shapeFileLayer);
            return(shapeFileLayer);
        }
Ejemplo n.º 6
0
 public MangoVectorLayer(MangoLayer layer, IBaseProvider dataSource) : base(layer.name, dataSource)
 {
     this.Layer = layer;
 }
Ejemplo n.º 7
0
 public MangoVectorLayer(MangoLayer layer) : base(layer.name)
 {
     this.Layer = layer;
 }
Ejemplo n.º 8
0
 public MangoLabelLayer(MangoLayer layer, string name) : base(name)
 {
     this.Layer = layer;
 }
Ejemplo n.º 9
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();
        }