Exemplo n.º 1
0
 public override bool IsMouseIn(PointF c, MapViewport map)
 {
     foreach (PointF p in Ext.points)
     {
         PointF target = map.WorldToImage(new Coordinate(p.X, p.Y));
         if (LayerElement.IsPoint(target, c) <= LayerElement.ICON_RADIUS)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 2
0
        private void Item_Click(object sender, EventArgs e)
        {
            DeviceType type = (sender as ToolStripMenuItem).Tag as DeviceType;

            if (type.deviceClass == "ElectronicFence")
            {
                this.drawFence      = new DrawFence();
                this.drawFence.type = type.deviceTypeCode;
                return;
            }


            Coordinate        p       = this.mapBox1.Map.ImageToWorld(this.addMemuPoint);
            MangoLayerElement ele     = new MangoLayerElement(this.currentMap.id, p, type.deviceTypeCode);
            LayerElement      element = new LayerElement(ele, type.ToIconSet());

            this.deviceLayer.AddLayerElement(element);
            this.Refresh();

            if (this.OnElementAdd != null)
            {
                this.OnElementAdd.Invoke(element);
            }
        }
Exemplo n.º 3
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();
        }