private void AddBalloonCalloutLabel(string strName, string strText, IPoint pPointAnchor, IElementCollection pElementCollection) { ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass(); pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid; IRgbColor pRgbColorFillSymbol = new RgbColorClass(); pRgbColorFillSymbol.RGB = fColor; //pRgbColorFillSymbol.Red = Color.White.R; //pRgbColorFillSymbol.Green = Color.White.G; //pRgbColorFillSymbol.Blue = Color.White.B; //byte bt = 0; //pRgbColorFillSymbol.Transparency = bt; pSimpleFillSymbol.Color = pRgbColorFillSymbol; //IBalloonCallout 接口 IBalloonCallout pBalloonCallout = new BalloonCalloutClass(); //弹出标签的背景 pBalloonCallout.Style = _style; //选择弹出标签样式,请尝试另外两种样式 pBalloonCallout.Symbol = pSimpleFillSymbol; //填充 pBalloonCallout.LeaderTolerance = 1; pBalloonCallout.AnchorPoint = pPointAnchor; //定位点 //创建点标注 ITextSymbol pTextSymbol = new TextSymbolClass(); IFormattedTextSymbol pFormattedTextSymbol = pTextSymbol as IFormattedTextSymbol; pFormattedTextSymbol.Background = pBalloonCallout as ITextBackground;//设置背景 //字体相关设置 IRgbColor pRgbColorTextSymbol = new RgbColorClass();//字体颜色 pRgbColorTextSymbol.RGB = tColor; //pRgbColorTextSymbol.Red = 0; //pRgbColorTextSymbol.Green = 0; //pRgbColorTextSymbol.Blue = 0; pFormattedTextSymbol.Color = pRgbColorTextSymbol; pFormattedTextSymbol.Font.Name = "宋体"; pFormattedTextSymbol.Size = _FontSize; pFormattedTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;//对齐方式 pFormattedTextSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop; ISimpleTextSymbol pSimpleTextSymbol = pTextSymbol as ISimpleTextSymbol; pSimpleTextSymbol.XOffset = 15; pSimpleTextSymbol.YOffset = 0; //加点标签 ITextElement pTextElement = new TextElementClass(); pTextElement.Symbol = pFormattedTextSymbol as ITextSymbol; pTextElement.Text = strText;//显示的标注文本 IElement pElement = pTextElement as IElement; pElement.Geometry = pPointAnchor as IGeometry;//位置 pPointPosition IElementProperties pElementProperties = pElement as IElementProperties; pElementProperties.Name = strName;//IElement的名称 pElementCollection.Add(pElementProperties as IElement, -1); }
private void AddNormalTextElement(IPoint pPoint) { IGraphicsContainer pGraphicCtn = m_pAV.GraphicsContainer; try { frmEdit frmCallOut = new frmEdit(false); PublicClass.POINTAPI pos = new PublicClass.POINTAPI(); PublicClass.GetCursorPos(ref pos); int scrW = Screen.PrimaryScreen.Bounds.Width; //主显示宽度 int scrH = Screen.PrimaryScreen.Bounds.Height; //主显示高度 frmCallOut.Location = new System.Drawing.Point(pos.x, pos.y); // * pScreen.BitsPerPixel if (pos.x + frmCallOut.Width > scrW && pos.y + frmCallOut.Height > scrH) //超出显示器边界宽和高,则迂回 { frmCallOut.Location = new System.Drawing.Point(scrW - frmCallOut.Width, scrH - frmCallOut.Height); } if (pos.x + frmCallOut.Width > scrW && pos.y + frmCallOut.Height < scrH) //超出显示器边界宽,则迂回 { frmCallOut.Location = new System.Drawing.Point(scrW - frmCallOut.Width, pos.y); } if (pos.x + frmCallOut.Width < scrW && pos.y + frmCallOut.Height > scrH) //超出显示器边界高,则迂回 { frmCallOut.Location = new System.Drawing.Point(pos.x, scrH - frmCallOut.Height); } frmCallOut.ShowDialog(); if (frmCallOut.DialogResult == System.Windows.Forms.DialogResult.Cancel) { return; } ITextElement pTextElement = new TextElementClass(); pTextElement.ScaleText = true; pTextElement.Text = frmCallOut.AnnoText; IFormattedTextSymbol pTextSymbol = (IFormattedTextSymbol)frmCallOut.m_pTextSymbol; pTextElement.Symbol = pTextSymbol as ITextSymbol; IElement pElement = (IElement)pTextElement; pElement.Geometry = pPoint; //刷新显示 frmCallOut.Dispose(); IGraphicsContainerSelect pGraphicsSel = pGraphicCtn as IGraphicsContainerSelect; pGraphicsSel.UnselectAllElements(); pGraphicsSel.SelectElement(pElement); pGraphicCtn.AddElement(pElement, 0); m_pAV.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("添加文本注记失败:" + ex.Message, "提示"); return; } }
//生成线注记 public ITextElement MakeTextElement(ITextElement pTextElement, IPolyline pPolyline, int intCharacterWidthIndexValue) { ITextElement pMyTextElement = new TextElementClass(); pMyTextElement.Text = pTextElement.Text; ITextSymbol pTextSymbol = new TextSymbolClass(); //若果要旋转注记 if (!CommonFunction.MatchNumber(pMyTextElement.Text))//如果文字 { if (m_IsRotationTextAnno) { pTextSymbol.Angle = pTextElement.Symbol.Angle + Math.Atan(m_A1 / m_A2) * 180 / Math.PI - 90; } else { pTextSymbol.Angle = pTextElement.Symbol.Angle; } } else//若果数字 { if (m_IsRotationNumAnno) { pTextSymbol.Angle = pTextElement.Symbol.Angle + Math.Atan(m_A1 / m_A2) * 180 / Math.PI - 90; } else { pTextSymbol.Angle = pTextElement.Symbol.Angle; } } pTextSymbol.Color = pTextElement.Symbol.Color; pTextSymbol.Font = pTextElement.Symbol.Font; pTextSymbol.HorizontalAlignment = pTextElement.Symbol.HorizontalAlignment; pTextSymbol.RightToLeft = pTextElement.Symbol.RightToLeft; pTextSymbol.Size = pTextElement.Symbol.Size; pTextSymbol.Text = pTextElement.Symbol.Text; pTextSymbol.VerticalAlignment = pTextElement.Symbol.VerticalAlignment; IFormattedTextSymbol pFormattedTextSymbol = pTextSymbol as IFormattedTextSymbol; pFormattedTextSymbol.CharacterWidth = intCharacterWidthIndexValue; pMyTextElement.Symbol = pTextSymbol; IElement pElement; pElement = (IElement)pMyTextElement; pElement.Geometry = pPolyline; return(pMyTextElement); }
private bool method_2(IElement ielement_1, out ICallout icallout_0) { icallout_0 = null; try { if (ielement_1 is ITextElement) { ITextElement element = ielement_1 as ITextElement; ITextSymbol symbol = element.Symbol; if (!(symbol is IFormattedTextSymbol)) { return(false); } IFormattedTextSymbol symbol2 = symbol as IFormattedTextSymbol; ITextBackground background = symbol2.Background; if (background == null) { return(false); } if (!(background is ICallout)) { return(false); } icallout_0 = background as ICallout; return(true); } if (ielement_1 is IMarkerElement) { IMarkerElement element2 = ielement_1 as IMarkerElement; IMarkerSymbol symbol3 = element2.Symbol; if (!(symbol3 is IMarkerBackgroundSupport)) { return(false); } IMarkerBackgroundSupport support = symbol3 as IMarkerBackgroundSupport; IMarkerBackground background2 = support.Background; if (background2 == null) { return(false); } if (!(background2 is ICallout)) { return(false); } icallout_0 = background2 as ICallout; return(true); } } catch { } return(false); }
private void updateFromUI() { ITextSymbol pTmpTextSymbol = new TextSymbolClass(); //字体 IFontDisp pFont = new StdFontClass() as IFontDisp; pFont.Name = this.cmbBoxFontName.Text; pFont.Size = decimal.Parse(this.FontSize.Text); pFont.Bold = this.toolBtnBold.Checked; pFont.Italic = this.toolBtnIntend.Checked; pFont.Underline = this.toolBtnUnderline.Checked; pFont.Strikethrough = this.toolBtnStrikethrough.Checked; pTmpTextSymbol.Font = pFont; //颜色 if (this.FontColor.SelectedColor != null) { pTmpTextSymbol.Color = ClsGDBDataCommon.ColorToIColor(FontColor.SelectedColor); } //角度 pTmpTextSymbol.Angle = double.Parse(this.TextAngle.Text); //字体对齐方式 if (this.toolBtnLeft.Checked == true) { pTmpTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; } else if (this.toolBtnCenter.Checked == true) { pTmpTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter; } else if (this.toolBtnRight.Checked == true) { pTmpTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight; } else if (this.toolBtnBoth.Checked == true) { pTmpTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHAFull; } //字符间距、行间距 IFormattedTextSymbol pFormattedTextSymbol = pTmpTextSymbol as IFormattedTextSymbol; pFormattedTextSymbol.CharacterSpacing = dbiCharSpacing.Value; pFormattedTextSymbol.Leading = dbiLineLeading.Value; pTextElement.Symbol = pTmpTextSymbol; pTextElement.Text = this.txtAddText.Text; }
private bool SetDefaultTextSymbol(ITextSymbol pTextSymbol) { try { if (pTextSymbol == null) { return(false); } UtilFactory.GetConfigOpt().SetConfigValue("Angle", pTextSymbol.Angle.ToString()); this.DefaultFontColor = pTextSymbol.Color; UtilFactory.GetConfigOpt().SetConfigValue("Size", pTextSymbol.Size.ToString()); UtilFactory.GetConfigOpt().SetConfigValue("Text", pTextSymbol.Text.ToString()); UtilFactory.GetConfigOpt().SetConfigValue("HorizontalAlignment", pTextSymbol.HorizontalAlignment.ToString()); UtilFactory.GetConfigOpt().SetConfigValue("VerticalAlignment", pTextSymbol.VerticalAlignment.ToString()); if (pTextSymbol.Font != null) { UtilFactory.GetConfigOpt().SetConfigValue("FontName", pTextSymbol.Font.Name); UtilFactory.GetConfigOpt().SetConfigValue("FontSize", pTextSymbol.Font.Size.ToString()); UtilFactory.GetConfigOpt().SetConfigValue("FontBold", pTextSymbol.Font.Bold.ToString()); UtilFactory.GetConfigOpt().SetConfigValue("FontItalic", pTextSymbol.Font.Italic.ToString()); UtilFactory.GetConfigOpt().SetConfigValue("FontUnderline", pTextSymbol.Font.Underline.ToString()); UtilFactory.GetConfigOpt().SetConfigValue("FontStrikethrough", pTextSymbol.Font.Strikethrough.ToString()); } IFormattedTextSymbol symbol = null; symbol = pTextSymbol as IFormattedTextSymbol; UtilFactory.GetConfigOpt().SetConfigValue("Direction", symbol.Direction.ToString()); ISimpleTextSymbol symbol2 = null; symbol2 = pTextSymbol as ISimpleTextSymbol; UtilFactory.GetConfigOpt().SetConfigValue("XOffset", symbol2.XOffset.ToString()); UtilFactory.GetConfigOpt().SetConfigValue("YOffset", symbol2.YOffset.ToString()); return(true); } catch (Exception exception) { this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.SymbolFun", "SetDefaultTextSymbol", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); return(false); } }
/// <summary> /// Actives the view events_ after draw. /// </summary> /// <param name="display">The display.</param> /// <param name="drapwPhase">The drapw phase.</param> /// <remarks>Fixes an issue where as you zoom in the tail on the callout gets longer.</remarks> private void activeViewEvents_AfterDraw(IDisplay display, esriViewDrawPhase drapwPhase) { IMxDocument mxDocument = (IMxDocument)ArcMap.Application.Document; if (this.CalloutAdded) { if (this.CurrentEnvelope != null) { if (this.CurrentEnvelope.Width != mxDocument.ActiveView.Extent.Width || this.CurrentEnvelope.Height != mxDocument.ActiveView.Extent.Height) { IGraphicsContainer graphicsContainer = (IGraphicsContainer)mxDocument.FocusMap; graphicsContainer.Reset(); IElement graphic = graphicsContainer.Next(); while (graphic != null) { IElementProperties properties = graphic as IElementProperties; if (properties != null) { if (properties.Name == DataHubExtension.LOCATOR_ELEMENT_NAME) { ITextElement textElement = graphic as ITextElement; IFormattedTextSymbol formattedTextSymbol = textElement.Symbol as IFormattedTextSymbol; IBalloonCallout balloonCallout = formattedTextSymbol.Background as IBalloonCallout; IPoint newPoint = new PointClass(); newPoint.PutCoords(balloonCallout.AnchorPoint.X - (mxDocument.ActiveView.Extent.Width / 30), balloonCallout.AnchorPoint.Y + (mxDocument.ActiveView.Extent.Width / 30)); graphic.Geometry = newPoint; break; } } graphic = graphicsContainer.Next(); } } } } this.CurrentEnvelope = mxDocument.ActiveView.Extent; }
//创建一个文字气泡 public ITextElement createTextElement(double x, double y, string text) { //设置文字气泡背景位置与属性 IBalloonCallout p_ballooncallout = createBalloonCallout(x, y); //新建并设置文字气泡边框、大小 IRgbColor p_rgbcolor = new RgbColorClass(); { p_rgbcolor.Green = 255; } ITextSymbol p_textsymbol = new TextSymbolClass(); { p_textsymbol.Color = p_rgbcolor; } IFormattedTextSymbol p_formattedtextsymbol = p_textsymbol as IFormattedTextSymbol; { p_formattedtextsymbol.Background = p_ballooncallout as ITextBackground; } p_textsymbol.Size = 8; //设置气泡位置 IPoint p_point = new PointClass(); { double p_width = axMapControl1.Extent.Width / 13; double p_height = axMapControl1.Extent.Height / 20; p_point.PutCoords(x + p_width, y + p_height); } //创建element设置text属性 ITextElement p_textelement = new TextElementClass(); p_textelement.Symbol = p_textsymbol; p_textelement.Text = text; IElement p_element = p_textelement as IElement; p_element.Geometry = p_point; return(p_textelement); }
//生成点注记 public ITextElement MakeTextElement(ITextElement pTextElement, double ptX, double ptY, int intCharacterWidthIndexValue) { ITextElement pMyTextElement = new TextElementClass(); pMyTextElement.Text = pTextElement.Text; ITextSymbol pTextSymbol = new TextSymbolClass(); Console.WriteLine(pMyTextElement.Text); //若果要旋转注记 if (CommonFunction.MatchNumber(pMyTextElement.Text))//如果数字 { if (m_IsRotationNumAnno) { pTextSymbol.Angle = pTextElement.Symbol.Angle + Math.Atan(m_A1 / m_A2) * 180 / Math.PI - 90; } else { pTextSymbol.Angle = pTextElement.Symbol.Angle; } } else//若果文字 { string str = pMyTextElement.Text; if (IsChina(str)) { if (m_IsRotationTextAnno) { pTextSymbol.Angle = pTextElement.Symbol.Angle + Math.Atan(m_A1 / m_A2) * 180 / Math.PI - 90; } else { pTextSymbol.Angle = pTextElement.Symbol.Angle; } } else { if (Char.IsLetter(str[0])) //若果为点号(D12345)或 规格注记(DL2或 DN 12345 { if (str.Contains(" ") || Char.IsLetter(str[1])) //规格注记====则必须旋转! { pTextSymbol.Angle = pTextElement.Symbol.Angle + Math.Atan(m_A1 / m_A2) * 180 / Math.PI - 90; } else//点号=根据设置来确定是否旋转 { if (m_IsRotationNumAnno) { pTextSymbol.Angle = pTextElement.Symbol.Angle + Math.Atan(m_A1 / m_A2) * 180 / Math.PI - 90; } else { pTextSymbol.Angle = pTextElement.Symbol.Angle; } } } } } pTextSymbol.Color = pTextElement.Symbol.Color; pTextSymbol.Font = pTextElement.Symbol.Font; pTextSymbol.HorizontalAlignment = pTextElement.Symbol.HorizontalAlignment; pTextSymbol.RightToLeft = pTextElement.Symbol.RightToLeft; pTextSymbol.Size = pTextElement.Symbol.Size; pTextSymbol.Text = pTextElement.Symbol.Text; pTextSymbol.VerticalAlignment = pTextElement.Symbol.VerticalAlignment; IFormattedTextSymbol pFormattedTextSymbol = pTextSymbol as IFormattedTextSymbol; pFormattedTextSymbol.CharacterWidth = intCharacterWidthIndexValue; pMyTextElement.Symbol = pTextSymbol; IElement pElement; pElement = (IElement)pMyTextElement; IPoint pPoint = new PointClass(); pPoint.PutCoords(ptX, ptY); pElement.Geometry = pPoint; return(pMyTextElement); }
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 { ; } }
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); } }
private void PreviewColorSet() { PreviewImage(m_styleGalleryItem); grpSymbol.Tag = m_styleGalleryItem.Item; Color pColor; IRgbColor pRgbColor; if (m_styleGalleryItem.Item is IMarkerSymbol) { IMarkerSymbol pMrkSymbol = (IMarkerSymbol)m_styleGalleryItem.Item; pRgbColor = PublicClass.GetRGBColor(pMrkSymbol.Color); pColor = Color.FromArgb(pRgbColor.Transparency, pRgbColor.Red, pRgbColor.Green, pRgbColor.Blue); colorPoint.Color = pColor; colorPoint.ForeColor = pColor; if (pRgbColor.Transparency == 0) { colorPoint.Color = Color.Transparent; colorPoint.ForeColor = Color.Transparent; } numPtSize.Value = (decimal)pMrkSymbol.Size; numPtXOffSet.Value = (decimal)pMrkSymbol.XOffset; numPtYOffSet.Value = (decimal)pMrkSymbol.YOffset; SetGroupVisible(1); } else if (m_styleGalleryItem.Item is ILineSymbol) { ILineSymbol pLineSymbol = (ILineSymbol)m_styleGalleryItem.Item; pRgbColor = PublicClass.GetRGBColor(pLineSymbol.Color); pColor = Color.FromArgb(pRgbColor.Transparency, pRgbColor.Red, pRgbColor.Green, pRgbColor.Blue); colorLine.Color = pColor; colorLine.ForeColor = pColor; if (pRgbColor.Transparency == 0) { colorLine.Color = Color.Transparent; colorLine.ForeColor = Color.Transparent; } numLineWidth.Value = (decimal)pLineSymbol.Width; ILineProperties pLineProp = pLineSymbol as ILineProperties; if (pLineProp != null) { numLineOffSet.Value = (decimal)pLineProp.Offset; } else { numLineOffSet.Value = 0; } SetGroupVisible(2); } else if (m_styleGalleryItem.Item is IFillSymbol) { IFillSymbol pFillSymbol = (IFillSymbol)m_styleGalleryItem.Item; pRgbColor = PublicClass.GetRGBColor(pFillSymbol.Color); pColor = Color.FromArgb(pRgbColor.Transparency, pRgbColor.Red, pRgbColor.Green, pRgbColor.Blue); colorPolygon.Color = pColor; colorPolygon.ForeColor = pColor; if (pRgbColor.Transparency == 0) { colorPolygon.Color = Color.Transparent; colorPolygon.ForeColor = Color.Transparent;; } if (pFillSymbol.Outline != null) { ILineSymbol pOutLine = pFillSymbol.Outline; pRgbColor = PublicClass.GetRGBColor(pOutLine.Color); pColor = Color.FromArgb(pRgbColor.Transparency, pRgbColor.Red, pRgbColor.Green, pRgbColor.Blue); colorBorder.Color = pColor; colorBorder.ForeColor = pColor; if (pRgbColor.Transparency == 0) { colorBorder.Color = Color.Transparent; colorBorder.ForeColor = Color.Transparent; } numOutLineWidth.Value = (decimal)pOutLine.Width; } else { btnOutLineColor.BackColor = this.BackColor; numOutLineWidth.Value = 0; } SetGroupVisible(3); } else if (m_styleGalleryItem.Item is ITextSymbol) { ITextSymbol pTextSymbol = (ITextSymbol)m_styleGalleryItem.Item; pRgbColor = PublicClass.GetRGBColor(pTextSymbol.Color); pColor = Color.FromArgb(pRgbColor.Transparency, pRgbColor.Red, pRgbColor.Green, pRgbColor.Blue); colorAnno.Color = pColor; colorAnno.ForeColor = pColor; SetGroupVisible(4); stdole.IFontDisp pFontDisp = pTextSymbol.Font; toolBarStyle.Buttons["toolBlod"].Pushed = pFontDisp.Bold; toolBarStyle.Buttons["toolItalic"].Pushed = pFontDisp.Italic; toolBarStyle.Buttons["toolUnderline"].Pushed = pFontDisp.Underline; ToolBarButton btn; for (int i = 0; i < toolBarAlign.Buttons.Count; i++) { btn = toolBarAlign.Buttons[i]; btn.Pushed = false; } if (pTextSymbol.HorizontalAlignment == esriTextHorizontalAlignment.esriTHALeft) { btn = toolBarAlign.Buttons["toolLeft"]; btn.Pushed = true; } else if (pTextSymbol.HorizontalAlignment == esriTextHorizontalAlignment.esriTHACenter) { btn = toolBarAlign.Buttons["toolCenter"]; btn.Pushed = true; } else if (pTextSymbol.HorizontalAlignment == esriTextHorizontalAlignment.esriTHARight) { btn = toolBarAlign.Buttons["toolRight"]; btn.Pushed = true; } else { btn = toolBarAlign.Buttons["toolFull"]; btn.Pushed = true; } cmbTextFont.Text = pFontDisp.Name; numTextSize.Value = (decimal)pTextSymbol.Size; anGle.Value = (decimal)pTextSymbol.Angle; IFormattedTextSymbol pFTextSymbol = pTextSymbol as IFormattedTextSymbol; if (pFTextSymbol != null) { if (pFTextSymbol.Background != null) { if (pFTextSymbol.Background is IBalloonCallout) { fillGroup.Visible = true; IBalloonCallout pBallCallout = pFTextSymbol.Background as IBalloonCallout; IFillSymbol pFillSymbol = pBallCallout.Symbol; if (pFillSymbol != null) { pRgbColor = pFillSymbol.Color as IRgbColor; l_ColorForPolygon.BackColor = ColorTranslator.FromOle(pRgbColor.RGB); ILineSymbol pLineSymbol = pFillSymbol.Outline; if (pLineSymbol != null) { pRgbColor = pLineSymbol.Color as IRgbColor; l_ColorForLine.ForeColor = ColorTranslator.FromOle(pRgbColor.RGB); txt_LineWidth.Text = pLineSymbol.Width.ToString(); } } } } } } else { SetGroupVisible(5); } cmbTextFont.SelectedIndexChanged += new EventHandler(cmbTextFont_SelectedIndexChanged); numTextSize.ValueChanged += new EventHandler(numTextSize_ValueChanged); txt_LineWidth.TextChanged += new EventHandler(txt_LineWidth_TextChanged); anGle.ValueChanged += new EventHandler(anGle_ValueChanged); }
private void ChangeTextSymbol() { ITextSymbol pTextSymbol = grpSymbol.Tag as ITextSymbol; if (pTextSymbol == null) { return; } //得到注记颜色 System.Drawing.Color pColor = btnTextColor.BackColor; pColor = colorAnno.Color; if (colorAnno.Color == Color.Transparent) { pTextSymbol.Color.Transparency = 0; } else { pTextSymbol.Color.Transparency = 255; } pTextSymbol.Color = PublicClass.GetRGBColor(pColor.R, pColor.G, pColor.B); //得到注记字体格式 stdole.IFontDisp pFontDisp = (stdole.IFontDisp)(new stdole.StdFontClass()); 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; pTextSymbol.Font = pFontDisp; //得到注记对齐格式 if (toolBarAlign.Buttons["toolLeft"].Pushed) { pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; } else if (toolBarAlign.Buttons["toolCenter"].Pushed) { pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter; } else if (toolBarAlign.Buttons["toolRight"].Pushed) { pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHARight; } else { pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHAFull; } pTextSymbol.Angle = (double)anGle.Value; //设置背景 IFormattedTextSymbol pFTextSymbol = pTextSymbol as IFormattedTextSymbol; if (pFTextSymbol != null) { if (pFTextSymbol.Background != null) { if (pFTextSymbol.Background is IBalloonCallout) { IBalloonCallout pBallCallout = pFTextSymbol.Background as IBalloonCallout; IFillSymbol pFillSymbol = pBallCallout.Symbol; if (pFillSymbol != null) { pFillSymbol.Color = PublicClass.GetRGBColor(l_ColorForPolygon.BackColor.R, l_ColorForPolygon.BackColor.G, l_ColorForPolygon.BackColor.B); ILineSymbol pLineSymbol = pFillSymbol.Outline; if (pLineSymbol != null) { pLineSymbol.Color = PublicClass.GetRGBColor(l_ColorForLine.ForeColor.R, l_ColorForLine.ForeColor.G, l_ColorForLine.ForeColor.B); if (!string.IsNullOrEmpty(txt_LineWidth.Text)) { pLineSymbol.Width = double.Parse(txt_LineWidth.Text); } pFillSymbol.Outline = pLineSymbol; } } } } } grpSymbol.Tag = pTextSymbol; IStyleGalleryItem item = new ServerStyleGalleryItemClass(); item.Name = "tempSymbol"; item.Item = pTextSymbol; PreviewImage(item); m_styleGalleryItem = item; }