private void AddLabel(string StrDisplayField) { pGeoFeatLayer.DisplayAnnotation = false; pMapControl.ActiveView.Refresh(); pGeoFeatLayer.DisplayField = StrDisplayField; IAnnotateLayerPropertiesCollection pAnnoProps = null; pAnnoProps = pGeoFeatLayer.AnnotationProperties; ILineLabelPosition pPosition = null; pPosition = new LineLabelPositionClass(); pPosition.Parallel = true; pPosition.Above = true; ILineLabelPlacementPriorities pPlacement = new LineLabelPlacementPrioritiesClass(); IBasicOverposterLayerProperties4 pBasic = new BasicOverposterLayerPropertiesClass(); pBasic.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline; pBasic.LineLabelPlacementPriorities = pPlacement; pBasic.LineLabelPosition = pPosition; pBasic.BufferRatio = 0; pBasic.FeatureWeight = esriBasicOverposterWeight.esriHighWeight; pBasic.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerPart; //pBasic.PlaceOnlyInsidePolygon = true;//仅在地物内部显示标注 deleted by chulili s20111018 界面上并没有这项设置,这句话应注释掉,否则像是错误 ILabelEngineLayerProperties pLabelEngine = null; pLabelEngine = new LabelEngineLayerPropertiesClass(); pLabelEngine.BasicOverposterLayerProperties = pBasic as IBasicOverposterLayerProperties; pLabelEngine.Expression = "[" + StrDisplayField + "]"; ITextSymbol pTextSymbol = null; pTextSymbol = pLabelEngine.Symbol; System.Drawing.Font pFont = null; pFont = LabelText.Font; IFontDisp pFontDisp = ESRI.ArcGIS.ADF.Converter.ToStdFont(pFont); pTextSymbol.Font = pFontDisp; IRgbColor pColor = new RgbColorClass(); pColor.Red = Convert.ToInt32(LabelText.ForeColor.R); pColor.Green = Convert.ToInt32(LabelText.ForeColor.G); pColor.Blue = Convert.ToInt32(LabelText.ForeColor.B); pTextSymbol.Color = pColor as IColor; pLabelEngine.Symbol = pTextSymbol; IAnnotateLayerProperties pAnnoLayerProps = null; pAnnoLayerProps = pLabelEngine as IAnnotateLayerProperties; pAnnoLayerProps.LabelWhichFeatures = esriLabelWhichFeatures.esriAllFeatures; pAnnoProps.Clear(); pAnnoProps.Add(pAnnoLayerProps); pGeoFeatLayer.DisplayAnnotation = true; pMapControl.ActiveView.Refresh(); }
private void InitVariablesAndControls(double textAngle, IColor textColor, IFontDisp textFont, double textSize, string insertText) { //控件初始化 txbxInsertText.Text = insertText; txbxInsertText.SelectAll(); cmbxFont.DataSource = System.Enum.GetNames(typeof(FontType)); cmbxFont.SelectedIndex = cmbxFont.FindString(textFont.Name); cmbxSize.DataSource = _sizeArr; cmbxSize.Text = textSize.ToString(); btnBold.FlatStyle = (textFont.Bold)? FlatStyle.Popup:FlatStyle.Flat; btnItalic.FlatStyle = (textFont.Italic) ? FlatStyle.Popup : FlatStyle.Flat; btnUnderLine.FlatStyle = (textFont.Underline) ? FlatStyle.Popup : FlatStyle.Flat; btnStrikethrough.FlatStyle = (textFont.Strikethrough) ? FlatStyle.Popup : FlatStyle.Flat; btnColor.BackColor = System.Drawing.Color.FromArgb((textColor as IRgbColor).Red, (textColor as IRgbColor).Green, (textColor as IRgbColor).Blue); nmrcUpDownAngle.Value = Convert.ToDecimal(textAngle); //变量初始化 _textAngle = textAngle; _textColor = textColor; _textFont = textFont; _textSize = textSize; _insertText = insertText; }
private IElement method_0(IActiveView iactiveView_0, string string_8, double double_2, double double_3, IEnvelope ienvelope_0) { ITextElement element = new TextElementClass(); ITextSymbol symbol = new TextSymbolClass { HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter, VerticalAlignment = esriTextVerticalAlignment.esriTVACenter }; IFontDisp font = symbol.Font; font.Size = 7.09M; symbol.Font = font; element.Symbol = symbol; element.Text = string_8; IElement element2 = element as IElement; IPoint origin = new PointClass(); IEnvelope bounds = new EnvelopeClass(); origin.PutCoords(double_2, double_3); element2.Geometry = origin; element2.QueryBounds(iactiveView_0.ScreenDisplay, bounds); if (bounds.Width > ienvelope_0.Width) { double sx = ienvelope_0.Width / bounds.Width; double sy = ienvelope_0.Height / bounds.Height; (element2 as ITransform2D).Scale(origin, sx, sy); } return(element2); }
public System.Drawing.Font GetFontFromIFontDisp(IFontDisp obj) { string name = obj.Name; float size = (float)obj.Size; FontStyle pFontStyle = FontStyle.Regular; if (obj.Bold) { pFontStyle = FontStyle.Bold; } if (obj.Italic) { pFontStyle = pFontStyle | FontStyle.Italic; } if (obj.Strikethrough) { pFontStyle = pFontStyle | FontStyle.Strikeout; } if (obj.Underline) { pFontStyle = pFontStyle | FontStyle.Underline; } System.Drawing.Font pFont = new System.Drawing.Font(name, size, pFontStyle); return(pFont); }
//加载窗体,遍历图层 private void FrmLabels_Load(object sender, EventArgs e) { //从右键菜单选项中添加标注的情况 if (cbxLayers.Text.Trim() != "") { List <string> attList = new List <string>(); attList = get_FieldsString(pFeatureClass); foreach (string s in attList) { cbxFields.Properties.Items.Add(s); } cbxFields.SelectedIndex = 0; } for (int i = 0; i < pMap.LayerCount; i++) { if (pMap.Layer[i] is FeatureLayer) { cbxLayers.Properties.Items.Add(pMap.Layer[i].Name); } } //初始化字体 pFontDisp = new stdole.StdFontClass() as stdole.IFontDisp; pFontDisp.Name = "Tahoma"; pFontDisp.Size = 9; MyColor.Blue = 255; MyColor.Red = 0; MyColor.Green = 0; richTextBox1.SelectionAlignment = HorizontalAlignment.Center; richTextBox1.ForeColor = pColor; }
public System.Drawing.Font GetFontFromIFontDisp(IFontDisp fontDisp) { string name = fontDisp.Name; float size = Convert.ToSingle(fontDisp.Size); FontStyle fontStyle = FontStyle.Regular; if (fontDisp.Bold) { fontStyle = FontStyle.Bold; } if (fontDisp.Italic) { fontStyle = fontStyle | FontStyle.Italic; } if (fontDisp.Strikethrough) { fontStyle = fontStyle | FontStyle.Strikeout; } if (fontDisp.Underline) { fontStyle = fontStyle | FontStyle.Underline; } System.Drawing.Font font = new System.Drawing.Font(name, size, fontStyle); return(font); }
/// <summary> /// 设置存储在地图上的注记的字体和大小 /// </summary> /// <param name="map"></param> /// <param name="graphicsLayerName"></param> /// <param name="fontName">注记字体(此值为""、空白字符或null,则不改变注记字体)</param> /// <param name="size">注记大小(此值小于等于0,则不改变注记大小)</param> public static void SetAnnotationFontOnMap(this IMap map, string graphicsLayerName, string fontName = null, int size = 0) { IGraphicsLayer graphicsLayer = map.GetGraphicsLayer(graphicsLayerName); IGraphicsContainer graphicContainer = graphicsLayer as IGraphicsContainer; var txtElements = graphicContainer.GetTextElements(); foreach (var txtElement in txtElements) { ITextSymbol txtSymbol = txtElement.Symbol; //注意不能使用下面这一句,直接设置txtElement.Symbol.Size = size 是无效的,原因未知 //txtElement.Symbol.Size = size; if (size > 0) { txtSymbol.Size = size; } if (!string.IsNullOrEmpty(fontName) && fontName.Trim() != string.Empty) { System.Drawing.Font font = new System.Drawing.Font(fontName, (float)txtSymbol.Size); IFontDisp fontDisp = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(font) as IFontDisp; txtSymbol.Font = fontDisp; } txtElement.Symbol = txtSymbol; graphicContainer.UpdateElement(txtElement as IElement); } }
private void InitializeMembers() { this.m_lhDC = 0; this.m_lOldPen = 0; this.m_lPen = 0; this.m_lOldBrush = 0; this.m_lBrushTop = 0; this.m_lBrushLeft = 0; this.m_lBrushRight = 0; this.m_dDeviceRadius = 0; this.m_trans = null; this.m_NumeratorTextSymbol = new TextSymbol(); this.m_LineSymbol = new SimpleLineSymbol(); this.m_DenominatorTextSymbol = new TextSymbol(); this.m_NumeratorText = "AaBbYyZz"; this.m_DenominatorText = "AaBbYyZz"; this.m_NumeratorTextSymbol.Text = this.m_NumeratorText; this.m_NumeratorTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter; this.m_NumeratorTextSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom; this.m_DenominatorTextSymbol.Text = this.m_DenominatorText; this.m_DenominatorTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter; this.m_DenominatorTextSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop; this.m_lROP2 = esriRasterOpCode.esriROPCopyPen; this.m_Angle = 0; this.m_pColor = new RgbColor(); this.m_pFont = new StdFont() as IFontDisp; this.m_HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; this.m_RightToLeft = false; this.m_Size = 0; this.m_Text = ""; this.m_VerticalAlignment = esriTextVerticalAlignment.esriTVACenter; this.m_bRotWithTrans = true; }
public JoinTableElement() { this.LineSymbol = new CartographicLineSymbol { Color = new RgbColor { Red = 0, Blue = 0, Green = 0 }, Cap = esriLineCapStyle.esriLCSSquare, Join = esriLineJoinStyle.esriLJSMitre }; this.TextSymbol = new TextSymbol { HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter, VerticalAlignment = esriTextVerticalAlignment.esriTVACenter }; IFontDisp font = this.TextSymbol.Font; font.Size = 7.09m; this.TextSymbol.Font = font; this.Row1Col1Text = ""; this.Row1Col2Text = ""; this.Row1Col3Text = ""; this.Row2Col1Text = ""; this.Row2Col3Text = ""; this.Row3Col1Text = ""; this.Row3Col2Text = ""; this.Row3Col3Text = ""; }
public TableElement() { this.LineSymbol = new CartographicLineSymbol { Color = new RgbColor { Red = 0, Blue = 0, Green = 0 }, Join = esriLineJoinStyle.esriLJSMitre, Cap = esriLineCapStyle.esriLCSSquare }; this.TextSymbol = new TextSymbol { HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft, VerticalAlignment = esriTextVerticalAlignment.esriTVACenter }; IFontDisp font = this.TextSymbol.Font; font.Size = 7.09m; this.TextSymbol.Font = font; this.Width = 4.0; this.Height = 4.0; this.RowNumber = 2; this.ColumnNumber = 4; this.HasInnerHorizontalLine = true; this.HasInnerVerticalLine = true; this.HasLeftBoundLine = true; this.HasLowerBoundLine = true; this.HasRightBoundLine = true; this.HasUpperBoundLine = true; }
//加载窗体 private void FrmTitle_Load(object sender, EventArgs e) { pFontDisp = new stdole.StdFontClass() as stdole.IFontDisp; pFontDisp.Name = "Tahoma"; pFontDisp.Size = 9; pTextSymbol.Font = pFontDisp; this.richTextBox1.SelectionAlignment = HorizontalAlignment.Center; }
public static ITextSymbol CreateTextSymbol(Color pColor, IFontDisp pFont, double pSize, string sText) { ITextSymbol symbol = new TextSymbolClass(); symbol.Color = ColorHelper.CreateColor(pColor); symbol.Font = pFont; symbol.Size = pSize; symbol.Text = sText; return(symbol); }
/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { if (txtText.Text.Trim().Length == 0) { XtraMessageBox.Show("文本内容不能为空,请确认后再试!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //设置字体 if (font == null) { FontDialog fontDialog = new FontDialog(); font = fontDialog.Font; } IFontDisp fontDisp = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(font) as IFontDisp; textSymbol.Font = fontDisp; //设置颜色 IColor color = new RgbColorClass(); color.RGB = (fontColor.B) * 65536 + (fontColor.G) * 256 + fontColor.R; textSymbol.Color = color; //添加或更新文本 switch (textElementEditType) { case TextElementEditType.New: textElement = new TextElementClass(); textElement.Text = txtText.Text; textElement.Symbol = textSymbol; IElement element = textElement as IElement; element.Geometry = textPoint; IGraphicsContainer graphicsContainer = activeView as IGraphicsContainer; graphicsContainer.AddElement(element, 0); break; case TextElementEditType.Modify: textElement.Text = txtText.Text; textElement.Symbol = textSymbol; break; } //刷新 activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); DialogResult = DialogResult.OK; }
private void ExportSLD(bool labelStatus) { if (labelStatus == true) { annotateLPC = geoFeatureLayer.AnnotationProperties; annotateLPC.QueryItem(0, out annotateLP, out elementCol, out elementCol2); leProps = (ILabelEngineLayerProperties)annotateLP; labelField = leProps.Expression.Replace(@"[", "").Replace(@"]", ""); textSymbol = leProps.Symbol; labelFont = textSymbol.Font; labelFontFamily = labelFont.Name; labelSize = textSymbol.Size.ToString().Replace(",", "."); simpleSldXmlWithLabel = String.Format(SLDExporterResource.SimpleSLDwithLabel, textBoxGSsldName.Text, fillColorHEX, outlineColorHEX, outlineWidth, labelField, labelFontFamily, labelSize); } else { simpleSldXmlWithoutLabel = String.Format(SLDExporterResource.SimpleSLDwithoutLabel, textBoxGSsldName.Text, fillColorHEX, outlineColorHEX, outlineWidth); } }
public static ITextSymbol MakeTextSymbol(string string_0, double double_0) { try { ISimpleTextSymbol symbol = new TextSymbol() as ISimpleTextSymbol; IFontDisp disp = (IFontDisp) new StdFont(); disp.Name = string_0; symbol.Font = disp; symbol.Angle = 0.0; symbol.RightToLeft = false; symbol.Size = double_0; symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom; symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; return(symbol); } catch { return(null); } }
/// <summary> /// ÉèÖÃÊôÐÔ±ê×¢ /// </summary> /// <param name="pGeoFeatureLayer">ͼ²ã</param> /// <param name="vLabelField">ÊôÐÔ×Ö¶Î</param> /// <param name="vMapFrameScale">ͼ²ã±ÈÀý³ß</param> /// <param name="vMapRefrenceScale">²Î¿¼±ÈÀý³ß</param> private void SetLableToGeoFeatureLayer(IGeoFeatureLayer pGeoFeatureLayer, string vLabelField, int vMapFrameScale, double vMapRefrenceScale) { IAnnotateLayerPropertiesCollection pAnnoLayerProperCol = pGeoFeatureLayer.AnnotationProperties; IAnnotateLayerProperties pAnnoLayerProper; IElementCollection placedElements; IElementCollection unplacedElements; //µÃµ½µ±Ç°²ãµÄµ±Ç°±ê×¢ÊôÐÔ pAnnoLayerProperCol.QueryItem(0, out pAnnoLayerProper, out placedElements, out unplacedElements); ILabelEngineLayerProperties pLabelEngineLayerProper = (ILabelEngineLayerProperties)pAnnoLayerProper; IBasicOverposterLayerProperties4 pBasicOverposterLayerProper = (IBasicOverposterLayerProperties4)pLabelEngineLayerProper.BasicOverposterLayerProperties; //±ê×¢µÄ×ÖÌå ITextSymbol pTextSymbol = pLabelEngineLayerProper.Symbol; IRgbColor pRGBColor = new RgbColorClass(); pRGBColor.Red = 0; pRGBColor.Blue = 255; pRGBColor.Green = 0; pTextSymbol.Color = pRGBColor; stdole.StdFont pStdFont = new stdole.StdFontClass(); IFontDisp pFont = (IFontDisp)pStdFont; pFont.Name = "ËÎÌå"; if (vMapRefrenceScale != 0) { double size = (vMapFrameScale / 3) * vMapFrameScale / vMapRefrenceScale; pFont.Size = (decimal)size; } pTextSymbol.Font = pFont; //±ê×¢ÄÚÈÝ pLabelEngineLayerProper.Expression = "[" + vLabelField + "]"; pBasicOverposterLayerProper.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerPart; //±ê×¢µÄ·½ÏòÐÅÏ¢ pBasicOverposterLayerProper.PolygonPlacementMethod = esriOverposterPolygonPlacementMethod.esriAlwaysHorizontal; //±ê×¢µÄÓ뼸ºÎͼÐεĴóС¹Øϵ pBasicOverposterLayerProper.PlaceOnlyInsidePolygon = false; //¿ªÆô±ê×¢ pGeoFeatureLayer.DisplayAnnotation = true; }
private ITextElement method_11(string string_0, double double_0, decimal decimal_0, string string_1, int int_0, IPoint ipoint_0) { ITextSymbol symbol = new TextSymbolClass { HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft, VerticalAlignment = esriTextVerticalAlignment.esriTVACenter, Angle = double_0, Size = Convert.ToDouble(decimal_0) }; IFontDisp disp = (IFontDisp) new StdFontClass(); disp.Size = decimal_0; disp.Name = string_1; disp.Bold = false; disp.Italic = false; disp.Underline = false; disp.Strikethrough = false; symbol.Font = disp; IRgbColor color = new RgbColorClass(); color = this.method_13(int_0); symbol.Color = color; ITextElement element = new TextElementClass { ScaleText = false, Text = string_0, Symbol = symbol }; IElement element2 = (IElement)element; if (ipoint_0 != null) { element2.Geometry = ipoint_0; } return(element); }
public static ITextSymbol MakeTextSymbol(string string_0, double double_0) { ITextSymbol textSymbol; try { ISimpleTextSymbol textSymbolClass = (ISimpleTextSymbol)(new TextSymbol()); IFontDisp stdFontClass = (IFontDisp)(new StdFont()); stdFontClass.Name = string_0; textSymbolClass.Font = stdFontClass; RgbColor rgbColorClass = new RgbColor(); textSymbolClass.Angle = 0; textSymbolClass.RightToLeft = false; textSymbolClass.Size = double_0; textSymbolClass.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom; textSymbolClass.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; textSymbol = textSymbolClass; } catch { textSymbol = null; } return(textSymbol); }
private ITextSymbol GetDefaultTextSymbol() { try { ITextSymbol symbol = null; symbol = new TextSymbolClass { Angle = double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "Angle")), Color = this.DefaultFontColor, Size = double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "Size")), Text = UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "Text") }; if (UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "HorizontalAlignment") == esriTextHorizontalAlignment.esriTHACenter.ToString()) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter; } else if (UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "HorizontalAlignment") == esriTextHorizontalAlignment.esriTHAFull.ToString()) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHAFull; } else if (UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "HorizontalAlignment") == esriTextHorizontalAlignment.esriTHALeft.ToString()) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; } else if (UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "HorizontalAlignment") == esriTextHorizontalAlignment.esriTHARight.ToString()) { symbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight; } if (UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "HorizontalAlignment") == esriTextVerticalAlignment.esriTVABaseline.ToString()) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABaseline; } else if (UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "HorizontalAlignment") == esriTextVerticalAlignment.esriTVABottom.ToString()) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom; } else if (UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "HorizontalAlignment") == esriTextVerticalAlignment.esriTVACenter.ToString()) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter; } else if (UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "HorizontalAlignment") == esriTextVerticalAlignment.esriTVATop.ToString()) { symbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop; } IFontDisp font = null; if (symbol.Font == null) { font = new StdFontClass() as IFontDisp; } else { font = symbol.Font; } font.Name = UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "FontName"); font.Size = decimal.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "FontSize")); font.Bold = bool.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "FontBold")); font.Italic = bool.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "FontItalic")); font.Underline = bool.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "FontUnderline")); font.Strikethrough = bool.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "FontStrikethrough")); symbol.Font = font; IFormattedTextSymbol symbol2 = null; symbol2 = symbol as IFormattedTextSymbol; if (esriTextDirection.esriTDAngle.ToString() == UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "Direction")) { symbol2.Direction = esriTextDirection.esriTDAngle; } else if (esriTextDirection.esriTDHorizontal.ToString() == UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "Direction")) { symbol2.Direction = esriTextDirection.esriTDHorizontal; } else if (esriTextDirection.esriTDVertical.ToString() == UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "Direction")) { symbol2.Direction = esriTextDirection.esriTDVertical; } ISimpleTextSymbol symbol3 = null; symbol3 = symbol as ISimpleTextSymbol; symbol3.XOffset = double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "XOffset")); symbol3.YOffset = double.Parse(UtilFactory.GetConfigOpt().GetConfigValue2("TextSymbol", "YOffset")); return(symbol); } catch (Exception exception) { this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.SymbolFun", "GetDefaultTextSymbol", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); return(null); } }
/// <summary> /// 从图层对应节点的XML中读取当前层的标注设置 /// </summary> /// <param name="pAnnoLayerProper"></param> public static void ReadLabelConfigFromXML(ref IAnnotateLayerProperties pAnnoLayerProper, XmlNode nodeLayerXml, string pFeatureType) { //设置标注的相关信息 ; ILabelEngineLayerProperties pLabelEngineLayerProperties = null; if (pAnnoLayerProper == null) { pLabelEngineLayerProperties = new LabelEngineLayerProperties() as ILabelEngineLayerProperties; pAnnoLayerProper = pLabelEngineLayerProperties as IAnnotateLayerProperties; } else { pLabelEngineLayerProperties = pAnnoLayerProper as ILabelEngineLayerProperties; } IAnnotationExpressionEngine pAnnoVBScriptEngine = new AnnotationVBScriptEngineClass(); pLabelEngineLayerProperties.ExpressionParser = pAnnoVBScriptEngine; IBasicOverposterLayerProperties4 pBasicOverposterLayerProperties = pLabelEngineLayerProperties.BasicOverposterLayerProperties as IBasicOverposterLayerProperties4; switch (pFeatureType) { case "esriGeometryPoint": pBasicOverposterLayerProperties.FeatureType = esriBasicOverposterFeatureType.esriOverposterPoint; break; case "esriGeometryPolyline": pBasicOverposterLayerProperties.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline; break; case "esriGeometryPolygon": pBasicOverposterLayerProperties.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolygon; break; } ITextSymbol pTextSymbol = pLabelEngineLayerProperties.Symbol; IFontDisp pFont = pTextSymbol.Font; foreach (XmlNode nd in nodeLayerXml) { if (nd.Name == "AttrLabel") { //读取共同的标注设置信息 pFont.Name = nd.Attributes["FontName"].Value; pFont.Size = Convert.ToDecimal(nd.Attributes["FontSize"].Value.ToLower()); if (nd.Attributes["FontBold"].Value != "") { pFont.Bold = Convert.ToBoolean(nd.Attributes["FontBold"].Value.ToLower()); } if (nd.Attributes["FontItalic"].Value != "") { pFont.Italic = Convert.ToBoolean(nd.Attributes["FontItalic"].Value.ToLower()); } if (nd.Attributes["FontUnderLine"].Value != "") { pFont.Underline = Convert.ToBoolean(nd.Attributes["FontUnderLine"].Value.ToLower()); } pTextSymbol.Font = pFont; IColor pColor = new RgbColorClass(); if (nd.Attributes["FontBoldColor"].Value != "") { pColor.RGB = Convert.ToInt32(nd.Attributes["FontBoldColor"].Value); } else { pColor.RGB = 36054566; //pColor.Green = 0; //pColor.Blue = 0; pTextSymbol.Color = pColor as IColor; } pTextSymbol.Color = pColor; if (nd.Attributes["Expression"].Value != "") { pLabelEngineLayerProperties.Expression = "[" + nd.Attributes["Expression"].Value + "]"; } if (nd.Attributes["MaxScale"].Value != "" && nd.Attributes["MaxScale"].Value != null) { pAnnoLayerProper.AnnotationMaximumScale = Convert.ToDouble(nd.Attributes["MaxScale"].Value); } if (nd.Attributes["MinScale"].Value != "" && nd.Attributes["MinScale"].Value != null) { pAnnoLayerProper.AnnotationMinimumScale = Convert.ToDouble(nd.Attributes["MinScale"].Value); } if (nd.Attributes["NumLabelsOption"].Value == "esriOneLabelPerName") { pBasicOverposterLayerProperties.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerName; } else if (nd.Attributes["NumLabelsOption"].Value == "esriOneLabelPerPart") { pBasicOverposterLayerProperties.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerPart; } else if (nd.Attributes["NumLabelsOption"].Value == "esriOneLabelPerShape") { pBasicOverposterLayerProperties.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerShape; } //下面按不同要素类型读取不同的标注设置信息 //点要素 if (pBasicOverposterLayerProperties.FeatureType == esriBasicOverposterFeatureType.esriOverposterPoint) { pBasicOverposterLayerProperties.PointPlacementOnTop = Convert.ToBoolean(nd.Attributes["PointPlacementOnTop"].Value.ToLower()); if (nd.Attributes["PointPlacementMethod"].Value == "esriAroundPoint") { pBasicOverposterLayerProperties.PointPlacementMethod = esriOverposterPointPlacementMethod.esriAroundPoint; IPointPlacementPriorities pPointPlacementPriorities = pBasicOverposterLayerProperties.PointPlacementPriorities; string strPlacement; try { //读取标注位置的设置 strPlacement = nd.Attributes["PointPlacementPriorities"].Value; SetPlacementPriotities(pPointPlacementPriorities, strPlacement); pBasicOverposterLayerProperties.PointPlacementPriorities = pPointPlacementPriorities; } catch { //MessageBox.Show("该图层XML中不存在PointPlacementPriorities属性!"); } } else if (nd.Attributes["PointPlacementMethod"].Value == "esriOnTopPoint") { pBasicOverposterLayerProperties.PointPlacementMethod = esriOverposterPointPlacementMethod.esriOnTopPoint; } else if (nd.Attributes["PointPlacementMethod"].Value == "esriSpecifiedAngles") { double[] dArray = new double[1]; string sAngle = nd.Attributes["PointPlacementAngles"].Value; if (sAngle.Contains(",") == false) { dArray[0] = Convert.ToDouble(sAngle); } else { string[] sAngles = sAngle.Split(new char[] { ',' }); dArray = new double[sAngles.Length]; for (int i = 0; i < sAngles.Length; i++) { dArray[i] = Convert.ToDouble(sAngles[i]); } } pBasicOverposterLayerProperties.PointPlacementAngles = dArray; } else if (nd.Attributes["PointPlacementMethod"].Value == "esriRotationField") { pBasicOverposterLayerProperties.PointPlacementMethod = esriOverposterPointPlacementMethod.esriRotationField; pBasicOverposterLayerProperties.RotationField = nd.Attributes["RotationField"].Value; if (nd.Attributes["RotationType"].Value == "esriRotateLabelArithmetic") { pBasicOverposterLayerProperties.RotationType = esriLabelRotationType.esriRotateLabelArithmetic; } else if (nd.Attributes["RotationType"].Value == "esriRotateLabelGeographic") { pBasicOverposterLayerProperties.RotationType = esriLabelRotationType.esriRotateLabelGeographic; } pBasicOverposterLayerProperties.PerpendicularToAngle = Convert.ToBoolean(nd.Attributes["PerpendicularToAngle"].Value); } } //线要素 else if (pBasicOverposterLayerProperties.FeatureType == esriBasicOverposterFeatureType.esriOverposterPolyline) { ILineLabelPosition pLineLabelPosition = pBasicOverposterLayerProperties.LineLabelPosition; if (nd.Attributes["Above"] != null) { pLineLabelPosition.Above = Convert.ToBoolean(nd.Attributes["Above"].Value); } if (nd.Attributes["AtEnd"] != null) { pLineLabelPosition.AtEnd = Convert.ToBoolean(nd.Attributes["AtEnd"].Value); } if (nd.Attributes["AtStart"] != null) { pLineLabelPosition.AtStart = Convert.ToBoolean(nd.Attributes["AtStart"].Value); } if (nd.Attributes["Below"] != null) { pLineLabelPosition.Below = Convert.ToBoolean(nd.Attributes["Below"].Value); } if (nd.Attributes["Horizontal"] != null) { pLineLabelPosition.Horizontal = Convert.ToBoolean(nd.Attributes["Horizontal"].Value); } if (nd.Attributes["InLine"] != null) { pLineLabelPosition.InLine = Convert.ToBoolean(nd.Attributes["InLine"].Value); } if (nd.Attributes["Left"] != null) { pLineLabelPosition.Left = Convert.ToBoolean(nd.Attributes["Left"].Value); } if (nd.Attributes["Offset"] != null) { pLineLabelPosition.Offset = Convert.ToDouble(nd.Attributes["Offset"].Value); } if (nd.Attributes["OnTop"] != null) { pLineLabelPosition.OnTop = Convert.ToBoolean(nd.Attributes["OnTop"].Value); } if (nd.Attributes["Parallel"] != null) { pLineLabelPosition.Parallel = Convert.ToBoolean(nd.Attributes["Parallel"].Value); } if (nd.Attributes["Perpendicular"] != null) { pLineLabelPosition.Perpendicular = Convert.ToBoolean(nd.Attributes["Perpendicular"].Value); } if (nd.Attributes["ProduceCurvedLabels"] != null) { pLineLabelPosition.ProduceCurvedLabels = Convert.ToBoolean(nd.Attributes["ProduceCurvedLabels"].Value); } if (nd.Attributes["Right"] != null) { pLineLabelPosition.Right = Convert.ToBoolean(nd.Attributes["Right"].Value); } } //面要素 else if (pBasicOverposterLayerProperties.FeatureType == esriBasicOverposterFeatureType.esriOverposterPolygon) { if (nd.Attributes["PolygonPlacementMethod"].Value == "esriAlwaysHorizontal") { pBasicOverposterLayerProperties.PolygonPlacementMethod = esriOverposterPolygonPlacementMethod.esriAlwaysHorizontal; } else if (nd.Attributes["PolygonPlacementMethod"].Value == "esriAlwaysStraight") { pBasicOverposterLayerProperties.PolygonPlacementMethod = esriOverposterPolygonPlacementMethod.esriAlwaysStraight; } else if (nd.Attributes["PolygonPlacementMethod"].Value == "esriMixedStrategy") { pBasicOverposterLayerProperties.PolygonPlacementMethod = esriOverposterPolygonPlacementMethod.esriMixedStrategy; } pBasicOverposterLayerProperties.PlaceOnlyInsidePolygon = Convert.ToBoolean(nd.Attributes["PlaceOnlyInsidePolygon"].Value); } } } }
private void AddLabel(string StrDisplayField) { pGeoFeatLayer.DisplayAnnotation = false; pMapControl.ActiveView.Refresh(); pGeoFeatLayer.DisplayField = StrDisplayField; IAnnotateLayerPropertiesCollection pAnnoProps = null; pAnnoProps = pGeoFeatLayer.AnnotationProperties; ILineLabelPosition pPosition = null; pPosition = new LineLabelPositionClass(); pPosition.Parallel = true; pPosition.Above = true; ILineLabelPlacementPriorities pPlacement = new LineLabelPlacementPrioritiesClass(); IBasicOverposterLayerProperties4 pBasic = new BasicOverposterLayerPropertiesClass(); pBasic.FeatureType = esriBasicOverposterFeatureType.esriOverposterPolyline; pBasic.LineLabelPlacementPriorities = pPlacement; pBasic.LineLabelPosition = pPosition; pBasic.BufferRatio = 0; pBasic.FeatureWeight = esriBasicOverposterWeight.esriHighWeight; if (this.rdbPerName.Checked) { pBasic.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerName; //每个名称标注一次 } else if (this.rdbPerPart.Checked) { pBasic.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerPart; //每个部分标注一次 } else { pBasic.NumLabelsOption = esriBasicNumLabelsOption.esriOneLabelPerShape; //每个地物标注一次 } //pBasic.NumLabelsOption = esriBasicNumLabelsOption.esriNoLabelRestrictions ; //pBasic.PlaceOnlyInsidePolygon = true; //仅在地物内部显示标注 deleted by chulili s20111018 界面上并没有这项设置,这句话应注释掉,否则像是错误 ILabelEngineLayerProperties pLabelEngine = null; pLabelEngine = new LabelEngineLayerPropertiesClass(); pLabelEngine.BasicOverposterLayerProperties = pBasic as IBasicOverposterLayerProperties; pLabelEngine.Expression = "[" + StrDisplayField + "]"; ITextSymbol pTextSymbol = null; pTextSymbol = pLabelEngine.Symbol; System.Drawing.Font pFont = null; pFont = LabelText.Font; IFontDisp pFontDisp = ESRI.ArcGIS.ADF.Converter.ToStdFont(pFont); pTextSymbol.Font = pFontDisp; IRgbColor pColor = new RgbColorClass(); pColor.Red = Convert.ToInt32(LabelText.ForeColor.R); pColor.Green = Convert.ToInt32(LabelText.ForeColor.G); pColor.Blue = Convert.ToInt32(LabelText.ForeColor.B); pTextSymbol.Color = pColor as IColor; pLabelEngine.Symbol = pTextSymbol; IAnnotateLayerProperties pAnnoLayerProps = null; pAnnoLayerProps = pLabelEngine as IAnnotateLayerProperties; pAnnoLayerProps.LabelWhichFeatures = esriLabelWhichFeatures.esriAllFeatures; //最大\最小比例尺 try { if (this.txtMaxLabelScale.Text.Trim() != "") { pAnnoLayerProps.AnnotationMaximumScale = Convert.ToDouble(this.txtMaxLabelScale.Text); } if (this.txtMinLabelScale.Text.Trim() != "") { pAnnoLayerProps.AnnotationMinimumScale = Convert.ToDouble(this.txtMinLabelScale.Text); } } catch (Exception err) {} pAnnoProps.Clear(); pAnnoProps.Add(pAnnoLayerProps); pGeoFeatLayer.DisplayAnnotation = this.chkIsLabel.Checked; (pMapControl.Map as IActiveView).Refresh(); }
public static ITextSymbol CreateTextSymbol(Color pColor, IFontDisp pFont, double pSize, string sText) { ITextSymbol symbol = new TextSymbolClass(); symbol.Color = ColorHelper.CreateColor(pColor); symbol.Font = pFont; symbol.Size = pSize; symbol.Text = sText; return symbol; }
/// <summary> /// /// </summary> /// <param name="textAngle">角度</param> /// <param name="textColor">颜色</param> /// <param name="textFont">字体</param> /// <param name="textSize">大小</param> /// <param name="insertText">文本</param> public InsertTextForm(double textAngle, IColor textColor, IFontDisp textFont, double textSize, string insertText) { InitializeComponent(); InitVariablesAndControls(textAngle, textColor, textFont, textSize, insertText); }
/// <summary> /// Build Cache Backgroud worker /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { int size = int.Parse(this.tbxSize.Text); IFeatureClass fc_poi = m_fcName.Open() as IFeatureClass; IGeoDataset ds_poi = fc_poi as IGeoDataset; int xmin = (int)Math.Floor(ds_poi.Extent.XMin); int ymin = (int)Math.Floor(ds_poi.Extent.YMin); int xmax = (int)Math.Ceiling(ds_poi.Extent.XMax); int ymax = (int)Math.Ceiling(ds_poi.Extent.YMax); List <JsonObject> ls_fields_cache = new List <JsonObject>(); if (!(fc_poi.Extension is IAnnotationClassExtension)) { for (int i = 0; i < fc_poi.Fields.FieldCount; i++) { IField field = fc_poi.Fields.get_Field(i); JsonObject js_f = new JsonObject(); js_f.AddString("name", field.Name); js_f.AddString("type", Enum.GetName(typeof(esriFieldType), field.Type)); js_f.AddString("alias", field.AliasName); if (field.Type == esriFieldType.esriFieldTypeString) { js_f.AddString("length", field.Length.ToString()); } else { js_f.AddString("length", ""); } ls_fields_cache.Add(js_f); } } IDatabase client = m_redis.GetDatabase(); int grid_id = 0; string ns = "poi:" + this.tbxCacheName.Text + ":"; for (int y = ymin; y <= ymax; y += size) { for (int x = xmin; x <= xmax; x += size) { List <String> str_poi_grid = new List <String>(); List <JsonObject> ls_features = new List <JsonObject>(); //String str_response = client.StringGet(ns+"response"); //JsonObject response = new JsonObject(str_response); JsonObject response = new JsonObject(); IEnvelope box = new EnvelopeClass(); box.XMin = x; box.YMin = y; box.XMax = x + size; box.YMax = y + size; ISpatialFilter filter_poi = new SpatialFilterClass(); filter_poi.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; filter_poi.Geometry = box; filter_poi.SubFields = "*"; IFeatureCursor cur_poi = fc_poi.Search(filter_poi, true); IFeature fea_poi = cur_poi.NextFeature(); while (fea_poi != null) { JsonObject js_fea = new JsonObject(); if (!(fea_poi is IAnnotationFeature)) { JsonObject js_attributes = new JsonObject(); int i = 0; foreach (JsonObject js_field in ls_fields_cache) { object value = fea_poi.get_Value(i); string fieldtype; js_field.TryGetString("type", out fieldtype); string fieldname; js_field.TryGetString("name", out fieldname); #region if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeString)) { js_attributes.AddString(fieldname, value.ToString()); } else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeOID)) { js_attributes.AddLong(fieldname, long.Parse(value.ToString())); } else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeInteger)) { if (value.ToString() == "") { value = 0; } js_attributes.AddLong(fieldname, long.Parse(value.ToString())); } else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeSmallInteger)) { if (value.ToString() == "") { value = 0; } js_attributes.AddLong(fieldname, long.Parse(value.ToString())); } else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeDouble)) { if (value.ToString() == "") { value = 0; } js_attributes.AddDouble(fieldname, double.Parse(value.ToString())); } else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeDate)) { if (value.ToString() == "") { value = DateTime.MinValue; } js_attributes.AddDate(fieldname, DateTime.Parse(value.ToString())); } else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeSingle)) { if (value.ToString() == "") { value = 0; } js_attributes.AddBoolean(fieldname, bool.Parse(value.ToString())); } #endregion i++; } js_fea.AddJsonObject("attributes", js_attributes); js_fea.AddJsonObject("geometry", Conversion.ToJsonObject(fea_poi.Shape)); } else { IAnnotationFeature anno_fea = fea_poi as IAnnotationFeature; ITextElement ele = anno_fea.Annotation as ITextElement; //string text = ele.Text.Replace(System.Environment.NewLine, " "); string text = ele.Text; ITextSymbol sym = ele.Symbol; IFontDisp font = sym.Font; double symsize = sym.Size; string fontname = font.Name; decimal fontsize = font.Size; string.Format(@"a"":"""); JsonObject js_symbol = new JsonObject( string.Format(@"{{""type"" : ""esriTS"",""color"": [255,255,255],""haloSize"" : 0,""haloColor"" : [255,255,255,0],""verticalAlignment"" : ""bottom"",""horizontalAlignment"" : ""center"",""size"": {0},""angle"": 0,""xoffset"": 0,""yoffset"": 0,""font"" : {{""family"" : ""{2}"",""size"" : {3},""style"" : ""normal"",""weight"" : ""normal"",""decoration"" : ""none""}},""text"":""{1}""}}", symsize, text, fontname, fontsize)); js_fea.AddJsonObject("symbol", js_symbol); IArea pshp = fea_poi.Shape as IArea; js_fea.AddJsonObject("geometry", Conversion.ToJsonObject(pshp.Centroid)); } ls_features.Add(js_fea); fea_poi = cur_poi.NextFeature(); } response.AddArray("features", ls_features.ToArray()); client.StringSet(ns + grid_id.ToString(), response.ToJson()); ReleaseCOMObject(cur_poi); grid_id++; progressBar1.BeginInvoke((Action)(() => { progressBar1.Increment(1); })); } } MessageBox.Show("Build Cache Successfully!"); this.button1.BeginInvoke((Action)(() => { ListCaches(); this.button1.Enabled = true; })); }
private void btnOk_Click(object sender, EventArgs e) { if (txtAnnoText.Text.Trim().Equals("输入文本")) { this.DialogResult = System.Windows.Forms.DialogResult.Cancel; return; } if (m_pTextSymbol == null) { m_pTextSymbol = new TextSymbolClass(); } //得到注记字体格式 IFontDisp pFontDisp = m_pTextSymbol.Font; pFontDisp.Name = cmbTextFont.Text; pFontDisp.Bold = toolBarStyle.Buttons["toolBlod"].Pushed; pFontDisp.Italic = toolBarStyle.Buttons["toolItalic"].Pushed; pFontDisp.Underline = toolBarStyle.Buttons["toolUnderline"].Pushed; pFontDisp.Size = numTextSize.Value; IRgbColor pRGBColor = new RgbColorClass(); pRGBColor.Red = colorAnno.Color.R;//yjl修改,之前颜色始终为灰 pRGBColor.Green = colorAnno.Color.G; pRGBColor.Blue = colorAnno.Color.B; m_pTextSymbol.Color = pRGBColor as IColor; m_pTextSymbol.Font = pFontDisp; //得到注记对齐格式 if (toolBarAlign.Buttons["toolLeft"].Pushed) { m_pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; } else if (toolBarAlign.Buttons["toolCenter"].Pushed) { m_pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter; } else if (toolBarAlign.Buttons["toolRight"].Pushed) { m_pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight; } else { m_pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHAFull; } m_pTextSymbol.Angle = (double)this.anGle.Value; if (canFill) { if (m_pLineSymbol == null) { m_pLineSymbol = new SimpleLineSymbolClass(); } if (m_pFillSymbol == null) { m_pFillSymbol = new SimpleFillSymbolClass(); } pRGBColor = new RgbColorClass(); pRGBColor.Red = l_ColorForLine.ForeColor.R; pRGBColor.Green = l_ColorForLine.ForeColor.G; pRGBColor.Blue = l_ColorForLine.ForeColor.B; m_pLineSymbol.Color = pRGBColor as IColor; pRGBColor.Red = l_ColorForPolygon.BackColor.R; pRGBColor.Green = l_ColorForPolygon.BackColor.G; pRGBColor.Blue = l_ColorForPolygon.BackColor.B; m_pFillSymbol.Color = pRGBColor as IColor; try { if (!string.IsNullOrEmpty(txt_LineWidth.Text)) { m_pLineSymbol.Width = (Convert.ToDouble(txt_LineWidth.Text) * 72) / 25.4; } } catch { } m_pFillSymbol.Outline = m_pLineSymbol; } this.DialogResult = DialogResult.OK; }
private void updateUI() { //加载字体名称 InstalledFontCollection pFontCollection = new InstalledFontCollection(); FontFamily[] pFontFamily = pFontCollection.Families; for (int i = 0; i < pFontFamily.Length; i++) { string pFontName = pFontFamily[i].Name; this.cmbBoxFontName.Items.Add(pFontName); } //大小、角度、字体名 ITextSymbol pTextSymbol = pTextElement.Symbol; this.txtAddText.Text = pTextSymbol.Text; this.cmbBoxFontName.Text = pTextSymbol.Font.Name; this.TextAngle.Value = pTextSymbol.Angle; this.FontSize.Value = Convert.ToDouble(pTextSymbol.Font.Size); //字符间距、行间距 IFormattedTextSymbol pFormattedTextSymbol = pTextSymbol as IFormattedTextSymbol; double dbCharSpacing = pFormattedTextSymbol.CharacterSpacing; double dbLineLeading = pFormattedTextSymbol.Leading; dbiCharSpacing.Value = dbCharSpacing; dbiLineLeading.Value = dbLineLeading; //颜色 IColor pTextColor = pTextSymbol.Color; Color pColor = ColorTranslator.FromOle(pTextColor.RGB); FontColor.SelectedColor = pColor; //样式 IFontDisp pFont = pTextSymbol.Font; this.toolBtnBold.Checked = pFont.Bold; this.toolBtnIntend.Checked = pFont.Italic; this.toolBtnUnderline.Checked = pFont.Underline; this.toolBtnStrikethrough.Checked = pFont.Strikethrough; //文字对齐方式 esriTextHorizontalAlignment pHorAlign = pTextSymbol.HorizontalAlignment; if (pHorAlign == esriTextHorizontalAlignment.esriTHACenter) { this.toolBtnLeft.Checked = false; this.toolBtnRight.Checked = false; this.toolBtnCenter.Checked = true; this.toolBtnBoth.Checked = false; } else if (pHorAlign == esriTextHorizontalAlignment.esriTHAFull) { this.toolBtnLeft.Checked = false; this.toolBtnRight.Checked = false; this.toolBtnCenter.Checked = false; this.toolBtnBoth.Checked = true; } else if (pHorAlign == esriTextHorizontalAlignment.esriTHALeft) { this.toolBtnLeft.Checked = true; this.toolBtnRight.Checked = false; this.toolBtnCenter.Checked = false; this.toolBtnBoth.Checked = false; } else if (pHorAlign == esriTextHorizontalAlignment.esriTHARight) { this.toolBtnLeft.Checked = false; this.toolBtnRight.Checked = true; this.toolBtnCenter.Checked = false; this.toolBtnBoth.Checked = false; } else { ; } }