/// <summary> /// 创建文字图元 /// </summary> /// <param name="kml">kml对象</param> /// <param name="gmapOverlay">图层</param> /// <returns></returns> public IMFElement CreateElement(Kml kml, GMapOverlay gmapOverlay) { KmlText text = kml.Placemark.Graph as KmlText; if (text == null) { return(null); } if (text.Position == null) { return(null); } PointLatLng p = new PointLatLng(text.Position.Lat, text.Position.Lng); Text_GMap element = new Text_GMap(p, text, kml.Placemark.Name); // 添加图元到图层 if (gmapOverlay.Control.InvokeRequired) { gmapOverlay.Control.Invoke(new Action(delegate { gmapOverlay.Markers.Add(element); })); } else { gmapOverlay.Markers.Add(element); } return(element); }
/// <summary> ///创建图元 /// </summary> /// <param name="kml"></param> /// <param name="layer"></param> /// <returns></returns> public Core.Interface.IMFElement CreateElement(Core.Model.Kml kml, ILayer layer) { KmlText kmlText = kml.Placemark.Graph as KmlText; if (kmlText == null) { return(null); } if (kmlText.Position == null) { return(null); } CompositeGraphicsLayerClass graphicLayer = layer as CompositeGraphicsLayerClass; if (graphicLayer == null) { return(null); } Text_ArcMap textElement = new Text_ArcMap(mapControl, kmlText, mapFactory); textElement.ElementType = ElementTypeEnum.Text; graphicLayer.AddElement(textElement, 0); return(textElement); }
/// <summary> /// 创建图元 /// </summary> /// <param name="kml"></param> /// <param name="layer"></param> /// <returns></returns> public IMFElement CreateElement(Kml kml, ILayer layer) { KmlText textKml = kml.Placemark.Graph as KmlText; if (textKml == null) { return(null); } if (textKml.Position == null) { return(null); } int index = -1; //图层 IGlobeGraphicsLayer graphicsLayer = layer as IGlobeGraphicsLayer; MapFrame.ArcGlobe.Element.Text_ArcGlobe textElement = null; this.Dosomething((Action) delegate() { //图元 textElement = new MapFrame.ArcGlobe.Element.Text_ArcGlobe(graphicsLayer, textKml); GlobeGraphicsElementPropertiesClass properties = new GlobeGraphicsElementPropertiesClass(); properties.Rasterize = textKml.Rasterize; graphicsLayer.AddElement(textElement, properties, out index); textElement.Index = index; //指定索引 textElement.ElementName = kml.Placemark.Name; }, true); return(textElement); }
/// <summary> /// 构造函数 /// </summary> /// <param name="pos">位置</param> /// <param name="text">kml</param> /// <param name="elementName">图元名称</param> public Text_GMap(PointLatLng pos, KmlText text, string elementName) : base(pos) { // 设置图元的类型 this.ElementType = ElementTypeEnum.Text; this.ElementName = elementName; // 设置图元的描述信息 this.Description = text.Description; this.Size = new System.Drawing.Size(20, 20); fontSize = text.Size;//记录字体大小 Color c = text.Color; mpen = new Pen(c, 3); mFont = new Font(text.Font, text.Size, text.FontStyle); mContext = text.Content; this.fontFamily = text.Font; //记录字体 this.fontStyle = text.FontStyle; //记录字形 mHightLightPen = new Pen(Color.Green, 2); flashTimer = new System.Timers.Timer(); flashTimer.Elapsed += flashTimer_Elapsed; base.Tag = this; }
/// <summary> /// 构造函数 /// </summary> /// <param name="graphicsLayer"></param> /// <param name="textKml">文字kml</param> public Text_ArcGlobe(IGlobeGraphicsLayer graphicsLayer, KmlText textKml) { this.graphicsLayer = graphicsLayer; this.ElementType = ElementTypeEnum.Text; //图元类型 this.Description = textKml.Description; //图元描述 #region 位置 IPoint point = new PointClass() { X = textKml.Position.Lng, Y = textKml.Position.Lat, Z = textKml.Position.Alt }; (point as IZAware).ZAware = true; //base.Geometry = point; #endregion #region 符号 base.FixedAspectRatio = true; //表明是否固定界限比例 //this.ReferenceScale = 100;//设置固定比例,不知道具体作用 base.AnchorPoint = point; //锚 base.Text = textKml.Content; base.Height = textKml.Size; base.FontName = textKml.Font; base.AxisRotation = esriT3DRotationAxis.esriT3DRotateAxisX; //旋转轴 base.RotationAngle = -90; //旋转角度 Color _color = textKml.Color; IRgbColor color = new RgbColorClass() { Red = _color.R, Green = _color.G, Blue = _color.B }; fillSymbol = new SimpleFillSymbolClass(); fillSymbol.Color = color; base.Symbol = fillSymbol; this.fontColor = textKml.Color; this.fontSize = textKml.Size; #endregion isFlash = false; flashTimer = new System.Timers.Timer(); flashTimer.Elapsed += new System.Timers.ElapsedEventHandler(flashTimer_Elapsed); flashTimer.Interval = 500; }
/// <summary> /// 构造函数 /// </summary> /// <param name="kml">kml 对象</param> /// <param name="_mapControl">地图控件</param> public Text_Mgis(Kml kml, AxHOSOFTMapControl _mapControl) { this.mapControl = _mapControl; KmlText kmlText = kml.Placemark.Graph as KmlText; if (kml.Placemark.Name == null || kmlText.Content == string.Empty) { return; } this.symbolName = kml.Placemark.Name; this.textPosition = kmlText.Position; this.context = kmlText.Content; System.Drawing.Color c = kmlText.Color; mapControl.MgsDrawSymTextByJBID(symbolName, context, (float)kmlText.Position.Lng, (float)kmlText.Position.Lat); mapControl.MgsUpdateSymSize(symbolName, (float)kmlText.Size); mapControl.MgsUpdateSymColor(symbolName, c.R, c.G, c.B, c.A); mapControl.update(); this.ElementType = ElementTypeEnum.Text; flashTimer = new Timer(); flashTimer.Elapsed += new ElapsedEventHandler(flashTimer_Elapsed); flashTimer.Interval = 500; }
/// <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; }
///// <summary> ///// 构造函数 ///// </summary> ///// <param name="kmlText"></param> ///// <param name="layer"></param> //public Text_ArcMap(KmlText kmlText, CompositeGraphicsLayerClass compositeGraphicsLayer) //{ // System.Drawing.Color c = System.Drawing.Color.FromArgb(kmlText.Color); // bTextColor = c; // base.Color = new RgbColorClass() { Red = c.R, Green = c.G, Blue = c.B }; // base.Size = kmlText.Size; // bOutLineSize = kmlText.Size; // base.FontName = kmlText.Font; // base.Text = kmlText.Content; // base.Geometry = new PointClass() { X = kmlText.Position.Lng, Y = kmlText.Position.Lat }; // this.Description = kmlText.Description; // position = new MapLngLat(); // position = kmlText.Position;//坐标点 // pIsFlash = false; // flashTimer = new System.Timers.Timer(); // flashTimer.Elapsed += new System.Timers.ElapsedEventHandler(flashTimer_Elapsed); //} public Text_ArcMap(AxMapControl _mapControl, KmlText kmlText, FactoryArcMap _mapFactory) { this.mapControl = _mapControl; this.mapFactory = _mapFactory; //System.Drawing.Color c = System.Drawing.Color.Red; if (mapControl.InvokeRequired) { mapControl.Invoke((Action) delegate() { System.Drawing.Color c = kmlText.Color; textSymbol = new TextSymbolClass(); font = new stdole.StdFontClass(); font.Name = kmlText.Font; font.Size = (decimal)kmlText.Size; switch (kmlText.FontStyle) { case FontStyle.Bold: font.Bold = true; font.Italic = false; font.Strikethrough = false; font.Underline = false; break; case FontStyle.Italic: font.Bold = false; font.Italic = true; font.Strikethrough = false; font.Underline = false; break; case FontStyle.Strikeout: font.Bold = false; font.Italic = false; font.Strikethrough = true; font.Underline = false; break; case FontStyle.Underline: font.Bold = false; font.Italic = false; font.Strikethrough = false; font.Underline = true; break; } textSymbol.Font = font as stdole.IFontDisp; textSymbol.Color = new RgbColorClass() { Red = c.R, Green = c.G, Blue = c.B }; //textSymbol.Color.RGB = c.B * 65536 + c.G * 256 + c.G; base.Symbol = textSymbol; base.Text = kmlText.Content; base.ScaleText = true; base.Geometry = new PointClass() { X = kmlText.Position.Lng, Y = kmlText.Position.Lat }; }); } else { System.Drawing.Color c = kmlText.Color; textSymbol = new TextSymbolClass(); font = new stdole.StdFontClass(); font.Name = kmlText.Font; font.Size = (decimal)kmlText.Size; switch (kmlText.FontStyle) { case FontStyle.Bold: font.Bold = true; font.Italic = false; font.Strikethrough = false; font.Underline = false; break; case FontStyle.Italic: font.Bold = false; font.Italic = true; font.Strikethrough = false; font.Underline = false; break; case FontStyle.Strikeout: font.Bold = false; font.Italic = false; font.Strikethrough = true; font.Underline = false; break; case FontStyle.Underline: font.Bold = false; font.Italic = false; font.Strikethrough = false; font.Underline = true; break; } textSymbol.Font = font as stdole.IFontDisp; textSymbol.Color = new RgbColorClass() { Red = c.R, Green = c.G, Blue = c.B }; //textSymbol.Color.RGB = c.B * 65536 + c.G * 256 + c.G; base.Symbol = textSymbol; base.Text = kmlText.Content; base.ScaleText = true; base.Geometry = new PointClass() { X = kmlText.Position.Lng, Y = kmlText.Position.Lat }; } this.Description = kmlText.Description; //记录 bTextColor = kmlText.Color;; bOutLineSize = kmlText.Size; position = new MapLngLat(); position = kmlText.Position;//坐标点 flashTimer = new System.Timers.Timer(); flashTimer.Elapsed += new System.Timers.ElapsedEventHandler(flashTimer_Elapsed); flashTimer.Interval = 1000; }