Beispiel #1
0
        public void CreateTextElment(double x, double y, int index)
        {
            IMxDocument doc = ArcMap.Document;
            IMap        map = doc.FocusMap;

            IPoint pPoint = new PointClass();
            //IMap pMap = axMapControl.Map;
            IMap               pMap        = doc.FocusMap;
            IActiveView        pActiveView = pMap as IActiveView;
            IGraphicsContainer pGraphicsContainer;
            IElement           pElement  = new MarkerElementClass();
            IElement           pTElement = new TextElementClass();

            pGraphicsContainer = (IGraphicsContainer)pActiveView;
            IFormattedTextSymbol pTextSymbol     = new TextSymbolClass();
            IBalloonCallout      pBalloonCallout = CreateBalloonCallout(x, y);
            IRgbColor            pColor          = new RgbColorClass();

            pColor.Red        = 150;
            pColor.Green      = 0;
            pColor.Blue       = 0;
            pTextSymbol.Color = pColor;
            ITextBackground pTextBackground;

            pTextBackground                  = (ITextBackground)pBalloonCallout;
            pTextSymbol.Background           = pTextBackground;
            ((ITextElement)pTElement).Symbol = pTextSymbol;
            ((ITextElement)pTElement).Text   = index.ToString();
            pPoint.X = x + 420;
            pPoint.Y = y + 420;
            //axMapControl.CenterAt(pPoint);
            pTElement.Geometry = pPoint;
            pGraphicsContainer.AddElement(pTElement, 1);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Beispiel #2
0
        public ITextElement createTextElement(double x_longitude, double y_latitude, string text_content)
        {
            IBalloonCallout      bc          = CreateBalloonCallout(x_longitude, y_latitude);
            IRgbColor            color_rgb   = new RgbColorClass();
            ITextSymbol          text_symbol = new TextSymbolClass();
            IFormattedTextSymbol ftext_symbol;
            IPoint       point = new PointClass();
            ITextElement text_elt = new TextElementClass();
            double       width, height;
            IElement     e;

            color_rgb.Green   = 255;
            text_symbol.Color = color_rgb;

            ftext_symbol            = text_symbol as IFormattedTextSymbol;
            ftext_symbol.Background = bc as ITextBackground;

            //fts.Size = 8;
            text_symbol.Size = 8;

            width  = this.axMapControl1.Extent.Width / 13;
            height = this.axMapControl1.Extent.Height / 20;
            point.PutCoords(x_longitude + width, y_latitude + height);

            //IMarkerElement me = new MarkerElementClass();
            text_elt.Symbol = text_symbol;
            text_elt.Text   = text_content;

            e          = text_elt as IElement;
            e.Geometry = point;


            return(text_elt);
        }
Beispiel #3
0
        private void CreatePoint(double x, double y)
        {
            IPoint             pPoint      = new PointClass();
            IMap               pMap        = axMapControl.Map;
            IActiveView        pActiveView = pMap as IActiveView;
            IGraphicsContainer pGraphicsContainer;
            IElement           pElement = new MarkerElementClass();

            pGraphicsContainer = (IGraphicsContainer)pActiveView;
            IFormattedTextSymbol pTextSymbol     = new TextSymbolClass();
            IBalloonCallout      pBalloonCallout = CreateBalloonCallout(x, y);
            IRgbColor            pColor          = new RgbColorClass();

            pColor.Red        = 150;
            pColor.Green      = 0;
            pColor.Blue       = 0;
            pTextSymbol.Color = pColor;
            ITextBackground pTextBackground;

            pTextBackground                 = (ITextBackground)pBalloonCallout;
            pTextSymbol.Background          = pTextBackground;
            ((ITextElement)pElement).Symbol = pTextSymbol;
            ((ITextElement)pElement).Text   = "测试";
            pPoint.X          = x;
            pPoint.Y          = y;
            pElement.Geometry = pPoint;
            pGraphicsContainer.AddElement(pElement, 1);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Beispiel #4
0
        /// <summary>
        /// 创建文本提示框
        /// </summary>
        /// <param name="x">提示框标识的位置X坐标</param>
        /// <param name="y">提示框标识的位置Y坐标</param>
        public void CreateTextElment(AxMapControl axMapControl1, double x, double y, string strText)
        {
            IPoint             pPoint      = new PointClass();
            IMap               pMap        = axMapControl1.Map;
            IActiveView        pActiveView = pMap as IActiveView;
            IGraphicsContainer pGraphicsContainer;
            IElement           pElement  = new MarkerElementClass();
            IElement           pTElement = new TextElementClass();

            pGraphicsContainer = (IGraphicsContainer)pActiveView;
            IFormattedTextSymbol pTextSymbol     = new TextSymbolClass();
            IBalloonCallout      pBalloonCallout = CreateBalloonCallout(x, y);
            IRgbColor            pColor          = new RgbColorClass();

            pColor.Red        = 150;
            pColor.Green      = 0;
            pColor.Blue       = 0;
            pTextSymbol.Color = pColor;
            ITextBackground pTextBackground;

            pTextBackground                  = (ITextBackground)pBalloonCallout;
            pTextSymbol.Background           = pTextBackground;
            ((ITextElement)pTElement).Symbol = pTextSymbol;
            ((ITextElement)pTElement).Text   = strText;

            IPoint p = new PointClass();

            //设置点的坐标
            p.PutCoords(x, y);
            IElementProperties   ipElemProp;
            IMarkerElement       ipMarkerElement = new MarkerElementClass();
            IPictureMarkerSymbol ipPicMarker     = new PictureMarkerSymbolClass();

            ipPicMarker.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, "D:\\pro\\ArcGisView\\ArcGisView\\1.bmp");
            ipPicMarker.Size = 24;
            IRgbColor ipRGBTrans = new RgbColorClass();

            ipRGBTrans.RGB = 0xffffff;
            ipPicMarker.BitmapTransparencyColor = ipRGBTrans as IColor;
            ipMarkerElement.Symbol = ipPicMarker as IMarkerSymbol;
            IElement ipElement = ipMarkerElement as IElement;

            ipElement.Geometry = p as IGeometry;
            axMapControl1.ActiveView.GraphicsContainer.AddElement(ipElement, 0);

            pPoint.X           = x + 42;
            pPoint.Y           = y + 42;
            pTElement.Geometry = pPoint;
            pGraphicsContainer.AddElement(pTElement, 1);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
Beispiel #5
0
        /// <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;
        }
Beispiel #6
0
        //创建一个文字气泡
        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 BetterMarker(ESRI.ArcGIS.Geometry.IPoint mapPoint, string Text, double MapScale)
        {
            _Callout = new BalloonCallout();

            _Callout.AnchorPoint = mapPoint;

            ITextElement         pTextElement = new TextElementClass();
            IElement             pElement;
            IFillSymbol          pFill        = new SimpleFillSymbolClass();
            ILineSymbol          pLine        = new SimpleLineSymbolClass();
            IFormattedTextSymbol pLabelSymbol = new TextSymbolClass();

            IRgbColor c = new RgbColorClass();

            c.Red   = 0;
            c.Green = 0;
            c.Blue  = 0;

            IRgbColor d = new RgbColorClass();

            d.Red   = 255;
            d.Green = 255;
            d.Blue  = 255;

            IRgbColor e = new RgbColorClass();

            e.Red   = 205;
            e.Green = 192;
            e.Blue  = 176;

            pLine.Color   = c;
            pFill.Color   = d;
            pFill.Outline = pLine;

            this._Callout.Symbol = pFill;
            this._Callout.Style  = esriBalloonCalloutStyle.esriBCSRoundedRectangle;


            pLabelSymbol.Background    = this._Callout as ITextBackground;
            pLabelSymbol.Size          = 10.5d;
            pLabelSymbol.ShadowColor   = e;
            pLabelSymbol.ShadowXOffset = 1.0d;
            pLabelSymbol.ShadowYOffset = 1.0d;

            pTextElement.Text   = Text;
            pTextElement.Symbol = pLabelSymbol as ITextSymbol;

            pElement = pTextElement as IElement;
            double delta = (.1 * MapScale) / 2;

            //switch (mMap.MapScale)
            //{
            //    case
            //}

            ESRI.ArcGIS.Geometry.IPoint p1 = new ESRI.ArcGIS.Geometry.PointClass();
            p1.X = mapPoint.X + delta;
            p1.Y = mapPoint.Y + delta;


            pElement.Geometry = p1;

            this._Element = pElement;
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        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;
        }