Esempio n. 1
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="_gmapControl">地图控件</param>
 /// <param name="_element">图元</param>
 public EditText(GMapControl _gmapControl, IMFElement _element)
 {
     gmapControl             = _gmapControl;
     marker                  = _element as GMapMarker;
     element                 = _element as IMFText;
     textCtrl                = new TextInput();
     textCtrl.InputFinished += InputFinish;
 }
Esempio n. 2
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     ReleaseCommond();
     gmapControl          = null;
     mapLogic             = null;
     textCtrl             = null;
     layer                = null;
     textElement          = null;
     CommondExecutedEvent = null;
 }
Esempio n. 3
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     ReleaseCommond();
     CommondExecutedEvent = null;
     mapControl           = null;
     textCtrl             = null;
     downPoint            = null;
     mapLogic             = null;
     textElement          = null;
     isControl            = false;
 }
Esempio n. 4
0
        private void 添加ToolStripMenuItem3_Click(object sender, System.EventArgs e)
        {
            Kml kml = new Kml();

            kml.Placemark.Name  = "text";
            kml.Placemark.Graph = new KmlText()
            {
                Position = new MapLngLat(102, 45), Content = "Hello World", Color = Color.Red, Font = "宋体", Size = 20
            };
            mapLogic.GetLayer(drawLayerName).AddElement(kml);//添加多边形到地图中
            textElement = mapLogic.GetLayer(drawLayerName).GetElement("text") as IMFText;
        }
Esempio n. 5
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     if (textCtrl != null)
     {
         textCtrl.Dispose();
     }
     downPoint   = null;
     isControl   = true;
     textElement = null;
     mapLogic    = null;
     layer       = null;
     mapControl  = null;
 }
Esempio n. 6
0
 /// <summary>
 /// 文字输入完成
 /// </summary>
 /// <param name="context">输入的文本内容</param>
 /// <param name="font">文字字体</param>
 /// <param name="color">字体颜色</param>
 /// <param name="esc">是否取消编辑</param>
 private void InputFinish(string context, Font font, Color color, bool esc)
 {
     if (!esc)
     {
         if (!string.IsNullOrEmpty(context))
         {
             Kml textKml = new Kml();
             textKml.Placemark.Name  = "draw_text" + Utils.ElementIndex;
             textKml.Placemark.Graph = new KmlText()
             {
                 Position = new MapLngLat(txtPoint.Lng, txtPoint.Lat), Size = font.Size, Content = context, Font = font.Name, Color = color, FontStyle = font.Style
             };
             IMFElement element = null;
             layer.AddElement(textKml, out element);
             textElement = element as IMFText;
             RegistCommondExecuteEvent();
             ReleaseCommond();//修改  陈静
         }
     }
 }
Esempio n. 7
0
 /// <summary>
 /// 完成事件
 /// </summary>
 /// <param name="context">文字内容</param>
 /// <param name="color">颜色</param>
 /// <param name="esc">是否绘制</param>
 private void InputFinish(string context, Color color, bool esc)
 {
     if (esc)
     {
         if (!string.IsNullOrEmpty(context))
         {
             Kml     kml  = new Kml();
             KmlText text = new KmlText();
             text.Content        = context;
             text.Position       = downPoint;
             text.Size           = (float)0.5;
             text.Color          = color;
             kml.Placemark.Name  = "mgis_Text" + Utils.ElementIndex;
             kml.Placemark.Graph = text;
             IMFElement element = null;
             layer.AddElement(kml, out element);
             textElement = element as IMFText;
         }
         RegistCommondExecutedEvent();
         ReleaseCommond();//修改  陈静
     }
     isMouseDown = false;
 }
Esempio n. 8
0
 /// <summary>
 /// 文字输入完成
 /// </summary>
 /// <param name="context">输入的文本内容</param>
 /// <param name="font">文字字体</param>
 /// <param name="color">字体颜色</param>
 /// <param name="esc">是否取消编辑</param>
 private void InputFinish(string context, Font font, Color color, bool esc)
 {
     if (!esc)
     {
         if (!string.IsNullOrEmpty(context))
         {
             Kml kml = new Kml();
             kml.Placemark.Name  = "arc_text" + Utils.ElementIndex;
             kml.Placemark.Graph = new KmlText()
             {
                 Position = downPoint, Size = font.Size, Content = context, Font = font.Name, Color = color, FontStyle = font.Style
             };
             IMFElement element = null;
             layer.AddElement(kml, out element);
             textElement = element as IMFText;
         }
         RegistCommondExecutedEvent();
         ReleaseCommond();//修改  陈静
     }
     else
     {
         isMouseDown = false;
     }
 }
Esempio n. 9
0
        // 处理波束数据
        private void DealBeamCover(BeamData e)
        {
            if (e.Point.Alt > 0)
            {
                return;                     // 卫星数据,不做处理
            }
            if (mapLogic == null)
            {
                return;
            }
            // 添加圆图元(波束覆盖)
            IMFLayer layer = mapLogic.AddLayer(coverLayerName);

            if (layer == null)
            {
                return;
            }

            string circleName = string.Format("卫星{0}-波束{1}", e.SatelliteId, e.BeamId);
            string textName   = string.Format("卫星{0}-波束{1}_描述", e.SatelliteId, e.BeamId, e.BeamId);

            if (!beamDic.ContainsKey(e.SatelliteId))   // 新的波束
            {
                Kml kmlCircle = new Kml();
                kmlCircle.Placemark.Name = circleName;
                KmlCircle circle = new KmlCircle();
                circle.Position           = e.Point;
                circle.FillColor          = Color.FromArgb(50, Color.Green);
                circle.Radius             = 500000;
                circle.StrokeColor        = Color.Blue;
                circle.StrokeWidth        = 1;
                kmlCircle.Placemark.Graph = circle;
                layer.AddElement(kmlCircle);

                // 添加文字图元
                Kml kmlText = new Kml();
                kmlText.Placemark.Name = textName;
                string context = string.Format("卫星{0}-波束{1}", e.SatelliteId, e.BeamId);
                kmlText.Placemark.Graph = new KmlText()
                {
                    Position = e.Point, Content = context, Color = Color.Blue, Font = "宋体", Size = 10
                };

                IMFElement elementText;
                if (layer.AddElement(kmlText, out elementText))
                {
                    bool visible = zoom >= visibleZoom ? true : false;
                    elementText.SetVisible(visible);
                }


                // 添加到字典进行维护
                List <int> beamIdList = new List <int>();
                beamIdList.Add(e.BeamId);
                lock (beamDic)
                {
                    beamDic.Add(e.SatelliteId, beamIdList);
                }
            }
            else
            {
                if (!beamDic[e.SatelliteId].Contains(e.BeamId))   // 新的波束
                {
                    Kml kmlCircle = new Kml();
                    kmlCircle.Placemark.Name = circleName;
                    KmlCircle circle = new KmlCircle();
                    circle.Position           = e.Point;
                    circle.FillColor          = Color.FromArgb(50, Color.Green);
                    circle.Radius             = 500000;
                    circle.StrokeColor        = Color.Blue;
                    circle.StrokeWidth        = 1;
                    kmlCircle.Placemark.Graph = circle;
                    layer.AddElement(kmlCircle);


                    // 添加文字图元
                    string context = string.Format("卫星{0}-波束{1}", e.SatelliteId, e.BeamId);
                    Kml    kmlText = new Kml();
                    kmlText.Placemark.Name  = textName;
                    kmlText.Placemark.Graph = new KmlText()
                    {
                        Position = e.Point, Content = context, Color = Color.Blue, Font = "宋体", Size = 10
                    };

                    IMFElement elementText;
                    if (layer.AddElement(kmlText, out elementText))
                    {
                        bool visible = zoom >= visibleZoom ? true : false;
                        elementText.SetVisible(visible);
                    }

                    lock (beamDic)
                    {
                        // 添加到字典进行维护
                        beamDic[e.SatelliteId].Add(e.BeamId);
                    }
                }
                else
                {
                    // 更新圆图元(波束覆盖)位置
                    IMFElement elementCircle = layer.GetElement(circleName);
                    if (elementCircle != null)
                    {
                        IMFCircle circle = elementCircle as IMFCircle;
                        if (circle != null)
                        {
                            circle.UpdatePosition(e.Point);
                        }
                    }

                    // 更新文字图元(描述信息)位置
                    IMFElement elementText = layer.GetElement(textName);
                    if (elementText != null)
                    {
                        IMFText text = elementText as IMFText;
                        if (text != null)
                        {
                            text.UpdatePosition(e.Point);
                        }
                    }
                }
            }
        }
Esempio n. 10
0
        void Form1_CommondExecutedEvent(object sender, MessageEventArgs e)
        {
            switch (e.ToolType)
            {
            case ToolTypeEnum.Draw:
                element = e.Data as IMFElement;
                switch (element.ElementType)
                {
                case ElementTypeEnum.Circle:
                    circleElement = element as IMFCircle;
                    break;

                case ElementTypeEnum.Point:
                    pointElement = element as IMFPoint;
                    break;

                case ElementTypeEnum.Line:
                    lineElement = element as IMFLine;
                    double length = lineElement.GetDistance();
                    break;

                case ElementTypeEnum.Polygon:
                    polygonElement = element as IMFPolygon;
                    double area = polygonElement.GetArea();
                    break;

                case ElementTypeEnum.Text:
                    textElement = element as IMFText;
                    break;

                case ElementTypeEnum.Rectangle:
                    rectangleElement = element as IMFPolygon;
                    break;
                }
                break;

            case ToolTypeEnum.Measure:
                break;

            case ToolTypeEnum.Select:
                List <IMFElement> elements = (sender as IMFSelect).GetSelectElements();
                break;

            case ToolTypeEnum.Edit:
                switch (element.ElementType)
                {
                case ElementTypeEnum.Point:
                    pointElement = element as IMFPoint;
                    break;

                case ElementTypeEnum.Line:
                    lineElement = element as IMFLine;
                    double length = lineElement.GetDistance();
                    break;

                case ElementTypeEnum.Polygon:
                    polygonElement = element as IMFPolygon;
                    double area = polygonElement.GetArea();
                    break;

                case ElementTypeEnum.Text:
                    textElement = element as IMFText;
                    break;
                }
                break;
            }
        }
Esempio n. 11
0
        /// <summary>
        /// 删除指定文字图元
        /// </summary>
        /// <param name="element"></param>
        /// <param name="layerName"></param>
        /// <returns></returns>
        public bool RemoveElement(Core.Interface.IMFElement element, string layerName)
        {
            IMFText textMgis = element as IMFText;

            return(mapControl.MgsDelObject(textMgis.ElementPtr) == 0 ? true : false);
        }