Esempio n. 1
0
        // 添加卫星模型图元
        private bool AddModel2Earth(Model3D model)
        {
            var layer = mapLogic.AddLayer(model.LayerName);

            if (layer == null)
            {
                Log4Allen.WriteLog(typeof(ArcGlobeBusiness), "创建卫星模型失败:添加图层失败。");
                return(false);
            }

            Kml kml = new Kml();

            kml.Placemark.Name = model.ModelName;
            KmlModel3d modelKml = new KmlModel3d();

            modelKml.ModelFilePath = model.ModelPath;
            modelKml.Description   = model.ModelName;
            modelKml.Position      = model.Coordinate;
            modelKml.Scale         = model.Scale;
            modelKml.Azimuth       = model.Azimuth;
            kml.Placemark.Graph    = modelKml;

            MapFrame.Core.Interface.IMFElement element = null;
            var ret = layer.AddElement(kml, out element);

            if (ret)
            {
                EventPublisher.PublishElementAddEvent(this, new ElementAddEventArgs(model.LayerName, model.ModelName));
            }

            return(ret);
        }
Esempio n. 2
0
        private void mapControl_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)
        {
            if (eventInited == 1)
            {
                ICommand command = mapControl.CurrentTool as ICommand;
                if (command != null && command.Name == "ControlToolsMapNavigation_Pan")
                {
                    //更新标牌
                    IPoint targetPoint = base.Geometry as IPoint;
                    Core.Model.MapLngLat startPoint = new Core.Model.MapLngLat(targetPoint.X, targetPoint.Y);
                    int x = -1;
                    int y = -1;
                    mapControl.FromMapPoint(targetPoint, ref x, ref y);
                    mapLabel.UpdateLabelLocation(new System.Drawing.Point(x, y));

                    //更新线
                    IPoint labelPoint             = mapControl.ToMapPoint(mapLabel.Location.X, mapLabel.Location.Y);
                    Core.Model.MapLngLat endPoint = new Core.Model.MapLngLat(labelPoint.X, labelPoint.Y);
                    MapFrame.Core.Interface.IMFElement element = BelongLayer.GetElement("标牌线");
                    if (element == null)
                    {
                        return;
                    }
                    IMFLine lineElement = element as IMFLine;
                    List <Core.Model.MapLngLat> lnglatList = new List <Core.Model.MapLngLat>();
                    lnglatList.Add(startPoint);
                    lnglatList.Add(endPoint);
                    lineElement.UpdatePosition(lnglatList);
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 编辑图元
 /// </summary>
 /// <param name="elementName"></param>
 public void EditElement(string elementName)
 {
     MapFrame.Core.Interface.IMFElement element = mapLogic.GetElement(elementName);
     if (element == null)
     {
         return;
     }
     EditElement(element);
 }
Esempio n. 4
0
        /// <summary>
        /// 移除图元
        /// </summary>
        /// <param name="layerName">图层名称</param>
        /// <param name="element">图元</param>
        /// <returns></returns>
        public bool RemoveElement(string layerName, MapFrame.Core.Interface.IMFElement element)
        {
            if (element == null)
            {
                return(true);
            }
            var layer = lyMgr.GetLayer(layerName);

            if (layer == null)
            {
                return(true);
            }
            IElementFactory elementFactory = null;

            switch (element.ElementType)
            {
            case ElementTypeEnum.Point:
                elementFactory = pointFac;
                break;

            case ElementTypeEnum.Line:
                elementFactory = lineFac;
                break;

            case ElementTypeEnum.Polygon:
                elementFactory = polygonFac;
                break;

            case ElementTypeEnum.Text:
                elementFactory = textFac;
                break;

            case ElementTypeEnum.Circle:
                elementFactory = circleFac;
                break;

            case ElementTypeEnum.Picture:
                elementFactory = pointIcoFac;
                break;
            }

            if (elementFactory == null)
            {
                return(false);
            }

            bool ret = elementFactory.RemoveElement(element, layer);

            element.Dispose();

            this.Refresh();
            return(ret);
        }
Esempio n. 5
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="_mapControl">地图控件</param>
        /// <param name="element">图元</param>
        public EditPoint(AxMapControl _mapControl, MapFrame.Core.Interface.IMFElement element)
        {
            mapControl = _mapControl;
            currTool   = _mapControl.CurrentTool;

            editElement = element as IMFPoint;
            if (editElement != null)
            {
                layer = editElement.BelongLayer;
            }
            SetGraphicsLayer();
        }
Esempio n. 6
0
        public void EditElement(MapFrame.Core.Interface.IMFElement element)
        {
            //释放之前的工具
            ReleaseTool();

            switch (element.ElementType)
            {
            case MapFrame.Core.Model.ElementTypeEnum.Point:    //编辑点
                currentTool = new EditPoint(mapControl, element);
                break;

            case MapFrame.Core.Model.ElementTypeEnum.Line:    //编辑线
                currentTool = new EditLine(mapControl, element);
                break;

            case MapFrame.Core.Model.ElementTypeEnum.Polygon:    //编辑多边形
                currentTool = new EditPolygon(mapControl, element);
                break;

            case MapFrame.Core.Model.ElementTypeEnum.Circle:    //编辑圆
                currentTool = new EditCircle(mapControl, element);
                break;

            case MapFrame.Core.Model.ElementTypeEnum.Text:    //编辑文字
                currentTool = new EditText(mapControl, element);
                break;

            case MapFrame.Core.Model.ElementTypeEnum.Other:
                break;
            }

            if (currentTool != null)
            {
                currentTool.RunCommond();//执行命令
                (currentTool as MapFrame.Core.Interface.IMFDraw).MapLogic = mapLogic;
                currentTool.CommondExecutedEvent += new EventHandler <Core.Model.MessageEventArgs>(currentTool_CommondExecutedEvent);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 标牌移动移动线的位置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void mapLabel_Move(object sender, EventArgs e)
        {
            IPoint targetPoint = base.Geometry as IPoint;

            Core.Model.MapLngLat startPoint = new Core.Model.MapLngLat(targetPoint.X, targetPoint.Y);//目标点

            MapFrame.ArcMap.Windows.MapLabel label = sender as MapFrame.ArcMap.Windows.MapLabel;
            IPoint labelLocation = mapControl.ToMapPoint(label.Location.X, label.Location.Y);

            Core.Model.MapLngLat endPoint = new Core.Model.MapLngLat(labelLocation.X, labelLocation.Y);//标牌点

            MapFrame.Core.Interface.IMFElement element = BelongLayer.GetElement("标牌线");
            if (element == null)
            {
                return;
            }
            IMFLine lineElement = element as IMFLine;
            List <Core.Model.MapLngLat> lnglatList = new List <Core.Model.MapLngLat>();

            lnglatList.Add(startPoint);
            lnglatList.Add(endPoint);
            lineElement.UpdatePosition(lnglatList);//更新位置
        }
Esempio n. 8
0
 /// <summary>
 /// 编辑图元
 /// </summary>
 /// <param name="elementName">图元名称</param>
 public void EditElement(string elementName)
 {
     MapFrame.Core.Interface.IMFElement element = mapLogic.GetElement(elementName);
     EditElement(element);
 }
Esempio n. 9
0
        /// <summary>
        /// 添加图元
        /// </summary>
        /// <param name="layerName">图层名称</param>
        /// <param name="kml">Kml对象</param>
        /// <returns></returns>
        public MapFrame.Core.Interface.IMFElement AddElement(string layerName, Core.Model.Kml kml)
        {
            if (kml == null)
            {
                return(null);
            }
            if (kml.Placemark == null)
            {
                return(null);
            }
            if (kml.Placemark.Graph == null)
            {
                return(null);
            }
            if (string.IsNullOrEmpty(kml.Placemark.Name))
            {
                return(null);
            }

            var layer = lyMgr.GetLayer(layerName);

            if (layer == null)
            {
                return(null);
            }

            IElementFactory elementFactory = null;
            Type            type           = kml.Placemark.Graph.GetType();

            // 点
            if (type == typeof(KmlPoint))
            {
                KmlPoint pointKml = kml.Placemark.Graph as KmlPoint;
                if (pointKml == null)
                {
                    return(null);
                }
                if (string.IsNullOrEmpty(pointKml.IcoUrl))//没有图标纯点
                {
                    elementFactory = pointFac;
                }
                else //有图标
                {
                    elementFactory = pointIcoFac;
                }
            }
            // 线
            else if (type == typeof(KmlLineString))
            {
                elementFactory = lineFac;
            }
            // 面
            else if (type == typeof(KmlPolygon))
            {
                elementFactory = polygonFac;
            }
            // 文字
            else if (type == typeof(KmlText))
            {
                elementFactory = textFac;
            }
            // 圆
            else if (type == typeof(KmlCircle))
            {
                elementFactory = circleFac;
            }

            if (elementFactory == null)
            {
                return(null);
            }

            MapFrame.Core.Interface.IMFElement element = elementFactory.CreateElement(kml, layer);
            if (element != null)
            {
                element.ElementName = kml.Placemark.Name;
            }

            Refresh(layer as Core.Interface.IMFLayer);
            return(element);
        }