示例#1
0
        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);
        }
示例#2
0
        //设置文字气泡位置和背景属性
        public IBalloonCallout createBalloonCallout(double x, double y)
        {
            IRgbColor p_rgbcolor = new RgbColorClass();  //设置浅黄色
            {
                p_rgbcolor.Red   = 255;
                p_rgbcolor.Green = 255;
                p_rgbcolor.Blue  = 200;
            }
            ISimpleFillSymbol p_simplefillsymbol = new SimpleFillSymbolClass(); //设置填充符号
            {
                p_simplefillsymbol.Color = p_rgbcolor;
                p_simplefillsymbol.Style = esriSimpleFillStyle.esriSFSSolid;
            }
            IPoint p_point = new PointClass();   //获取鼠标的位置
            {
                p_point.PutCoords(x, y);
            }
            IBalloonCallout p_ballooncallout = new BalloonCalloutClass();  //新建并设置文字气泡对象

            {
                p_ballooncallout.Style           = esriBalloonCalloutStyle.esriBCSRoundedRectangle;
                p_ballooncallout.Symbol          = p_simplefillsymbol;
                p_ballooncallout.LeaderTolerance = 10;
                p_ballooncallout.AnchorPoint     = p_point;
            }
            return(p_ballooncallout);
        }
示例#3
0
        /// <summary>
        /// Adds a Call Out
        /// </summary>
        /// <param name="point"></param>
        /// <param name="LocatorDescription"></param>
        private void AddCallout(ESRI.ArcGIS.Geometry.Point point, String LocatorDescription)
        {
            try
            {
                IMxDocument mxDocument = ArcMap.Application.Document as IMxDocument;
                try
                {
                    //Register if not already registered
                    IActiveViewEvents_Event check = mxDocument.ActiveView as IActiveViewEvents_Event;
                    if (check != this.activeViewEvents)
                    {
                        this.activeViewEvents       = mxDocument.ActiveView as IActiveViewEvents_Event;
                        activeViewEvents.AfterDraw -= AfterDrawEventHandler;
                        activeViewEvents.AfterDraw += AfterDrawEventHandler;
                    }
                }
                catch (Exception)
                {
                }

                IMap        map        = mxDocument.FocusMap;
                IActiveView activeView = mxDocument.ActiveView;
                this.CurrentEnvelope = activeView.Extent;
                IFormattedTextSymbol formattedTextSymbol = new TextSymbolClass();
                ICallout             callout             = new BalloonCalloutClass();

                (callout as IBalloonCallout).Style = esriBalloonCalloutStyle.esriBCSRoundedRectangle;
                formattedTextSymbol.Background     = callout as ITextBackground;
                callout.AnchorPoint     = point;
                callout.LeaderTolerance = 0.0;

                ITextElement textElement = new TextElementClass();
                string       CalloutText = LocatorDescription.Replace("|LOCATOR_SEPARATOR|", System.Environment.NewLine);
                textElement.Text = CalloutText;
                IElement textElementAsElement = textElement as IElement;
                IPoint   textPoint            = (point as IClone).Clone() as IPoint;
                textPoint.PutCoords(point.X - (activeView.Extent.Width / 30), point.Y + (activeView.Extent.Width / 30));
                textElementAsElement.Geometry = textPoint;

                //Apply the properties
                textElement.Symbol = formattedTextSymbol;
                (textElement as IElementProperties).Name = LOCATOR_ELEMENT_NAME;

                //Add the Element to the view
                IGraphicsContainer graphicsContainer = map as IGraphicsContainer;
                graphicsContainer.AddElement(textElement as IElement, 0);
                textElementAsElement.Activate(activeView.ScreenDisplay);

                activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                this.CalloutAdded = true;
            }
            catch (Exception ex)
            {
                ShowError(ex);
            }
        }
示例#4
0
        /// <summary>
        /// 添加标注信息
        /// </summary>
        /// <param name="pPoint"></param>
        public void AddCallout(IPoint pPoint, string strText)
        {
            IActiveView        pActiveView;
            IGraphicsContainer pGraphicsContainer;
            IPoint             pPntText = new PointClass();

            pPntText.PutCoords(pPoint.X + 3, pPoint.Y + 3);
            pActiveView        = m_pMapControl.ActiveView;
            pGraphicsContainer = pActiveView.GraphicsContainer;

            IElement             pElement;
            IFormattedTextSymbol pTextSymbol  = new TextSymbolClass();
            ITextElement         pTextElement = new TextElementClass();

            pElement          = (IElement)pTextElement;
            pTextElement.Text = strText;
            pElement.Geometry = pPntText;

            IRgbColor pRgbClr = new RgbColorClass();

            pRgbClr.Red   = 255;
            pRgbClr.Blue  = 255;
            pRgbClr.Green = 255;

            ISimpleFillSymbol pSmplFill = new SimpleFillSymbolClass();

            pSmplFill.Color = pRgbClr;
            pSmplFill.Style = esriSimpleFillStyle.esriSFSHollow;

            IBalloonCallout pBllnCallout = new BalloonCalloutClass();

            pBllnCallout.Style           = esriBalloonCalloutStyle.esriBCSRoundedRectangle;
            pBllnCallout.Symbol          = pSmplFill;
            pBllnCallout.LeaderTolerance = 5;
            pBllnCallout.AnchorPoint     = pPoint;

            pRgbClr.Red   = 255;
            pRgbClr.Blue  = 0;
            pRgbClr.Green = 0;

            pTextSymbol.Background = (ITextBackground)pBllnCallout;
            Color  color  = ColorTranslator.FromHtml(SystemInfo.Instance.TextColor);
            IColor pColor = new RgbColorClass();

            pColor.RGB        = color.B * 65536 + color.G * 256 + color.R;
            pTextSymbol.Color = pColor;
            pTextSymbol.Size  = SystemInfo.Instance.TextSize;
            pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
            pTextElement.Symbol             = pTextSymbol;
            pGraphicsContainer.AddElement(pElement, 1);

            //pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
        public void AddCallout(IPoint pPoint, string strText)
        {
            DF2DApplication app = DF2DApplication.Application;

            m_ActiveView = app.Current2DMapControl.ActiveView;
            IGraphicsContainer pGraphicsContainer = m_ActiveView.GraphicsContainer;
            IPoint             pPointText         = new PointClass();

            pPointText.PutCoords(pPoint.X + 1.5, pPoint.Y + 1.5);

            ITextElement         pTextElement = new TextElementClass();
            IFormattedTextSymbol pTextSymbol  = new TextSymbolClass();

            IElement pElement = pTextElement as IElement;

            pTextElement.Text      = strText;
            pTextElement.ScaleText = true;
            pElement.Geometry      = pPointText;

            IRgbColor pRgbColor = GetRGBColor(255, 255, 0);

            ISimpleFillSymbol pSmplFill = new SimpleFillSymbolClass();

            pSmplFill.Color = pRgbColor;
            pSmplFill.Style = esriSimpleFillStyle.esriSFSHollow;

            IBalloonCallout pBalloonCallout = new BalloonCalloutClass();

            pBalloonCallout.Symbol          = pSmplFill;
            pBalloonCallout.Style           = esriBalloonCalloutStyle.esriBCSOval;
            pBalloonCallout.AnchorPoint     = pPointText;
            pBalloonCallout.LeaderTolerance = 5;

            pRgbColor = GetRGBColor(255, 0, 0);

            pTextSymbol.Background = pBalloonCallout as ITextBackground;
            pTextSymbol.Color      = pRgbColor;
            pTextSymbol.Size       = (app.Current2DMapControl.MapScale / 100) * 5;
            //pTextSymbol.Size = 25;
            pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;

            pTextElement.Symbol = pTextSymbol;


            pGraphicsContainer.AddElement(pElement, 1);
        }
示例#6
0
        private void GetFacilityInterdicted(IFeatureWorkspace featureWorkspace, int[] r)
        {
            int           p            = 22;
            IFeatureClass featureClass = featureWorkspace.OpenFeatureClass("Hospitals");
            IFeature      pFeature;

            for (int i = 1; i <= p; i++)
            {
                pFeature = featureClass.GetFeature(i) as IFeature;
                IFeatureBuffer pFeatureBuffer = pFeature as IFeatureBuffer;
                pFeatureBuffer.set_Value(pFeature.Fields.FindField("interdicted"), r[i - 1]);
            }
            IMap pMap = this.axMapControl.Map;
            IGraphicsContainer pGraphicsContainerXL = pMap as IGraphicsContainer;

            //add interdicted points
            for (int i = 0; i < p; i++)
            {
                if (r[i] == 1)
                {
                    pFeature = featureClass.GetFeature(i) as IFeature;
                    IPoint       pPoint   = pFeature.Shape as IPoint;
                    ITextElement pTextEle = new TextElementClass();
                    IElement     pElement = pTextEle as IElement;
                    //text
                    pTextEle.Text      = "interdicted";
                    pTextEle.ScaleText = true;
                    pElement.Geometry  = pPoint;
                    //BalloonCallout
                    IBalloonCallout pBalloonCallout = new BalloonCalloutClass();
                    pBalloonCallout.Style       = esriBalloonCalloutStyle.esriBCSRoundedRectangle;
                    pBalloonCallout.AnchorPoint = pPoint;
                    IFormattedTextSymbol pTextSymbol = new TextSymbolClass();
                    pTextSymbol.Background          = pBalloonCallout as ITextBackground;
                    pTextSymbol.Direction           = esriTextDirection.esriTDAngle;
                    pTextSymbol.Angle               = 15;
                    pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
                    pTextSymbol.VerticalAlignment   = esriTextVerticalAlignment.esriTVATop;
                    pTextEle.Symbol = pTextSymbol;
                    pGraphicsContainerXL.AddElement(pTextEle as IElement, 0);
                }
            }
            axMapControl.Refresh();
        }
        /// <summary>
        /// Creates a Balloon Callout with the given text and background color for the given feature.
        /// </summary>
        /// <param name="feature">The feature for which to create the callout.</param>
        /// <param name="displayText">The text to display.</param>
        /// <param name="bgColor">The background color of the callout</param>
        /// <returns>Returns an element with a callout symbol.</returns>
        public static IElement CreateBalloonCalloutForFeature(IFeature feature, string displayText, string bgColor)
        {
            ITextElement element = new TextElementClass();
                if (feature != null)
                {
                    IPoint anchor = new PointClass();
                    try
                    {
                        if (feature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                            ((IPolyline)feature.ShapeCopy).QueryPoint(esriSegmentExtension.esriNoExtension, .5, true, anchor);
                        else if (feature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
                            anchor.PutCoords(feature.ShapeCopy.Envelope.XMax, feature.ShapeCopy.Envelope.YMax);
                    }
                    catch (Exception ex)
                    {
                       // _logger.LogException(ex, "There was an error getting the shape from the feature.");
                        anchor = null;
                    }
                    if (anchor != null || !anchor.IsEmpty)
                    {
                        IBalloonCallout balloon = new BalloonCalloutClass();
                        balloon.AnchorPoint = anchor;
                        balloon.LeaderTolerance = .5;
                        balloon.Style = esriBalloonCalloutStyle.esriBCSRoundedRectangle;
                        balloon.Symbol = GenerateGenericFillSymbol(bgColor, esriSimpleFillStyle.esriSFSSolid);

                        IFormattedTextSymbol txtSym = new TextSymbolClass();
                        txtSym.Background = balloon as ITextBackground;
                        txtSym.Size = 10;

                        if (string.IsNullOrEmpty(displayText))
                            displayText = feature.OID.ToString();

                        ((IElement)element).Geometry = feature.ShapeCopy;//offSet;
                        element.Text = displayText;
                        element.Symbol = txtSym;
                    }
                }

                return element as IElement;
        }
示例#8
0
        public IBalloonCallout CreateBalloonCallout(double x, double y)
        {
            IRgbColor         color_rgb      = new RgbColorClass();
            ISimpleFillSymbol simpleFillSbl  = new SimpleFillSymbolClass();
            IPoint            point          = new PointClass();;
            IBalloonCallout   balloonCallout = new BalloonCalloutClass(); // 气球类型的插图编号

            color_rgb.Red   = 255;
            color_rgb.Green = 255;
            color_rgb.Blue  = 200;

            simpleFillSbl.Color = color_rgb;
            simpleFillSbl.Style = esriSimpleFillStyle.esriSFSSolid;
            point.PutCoords(x, y);

            balloonCallout.Style           = esriBalloonCalloutStyle.esriBCSRoundedRectangle;
            balloonCallout.Symbol          = simpleFillSbl;
            balloonCallout.LeaderTolerance = 10;
            balloonCallout.AnchorPoint     = point;

            return(balloonCallout);
        }
示例#9
0
        /// <summary>
        /// 创建balloon型提示框
        /// </summary>
        /// <param name="x">提示框所在位置X坐标</param>
        /// <param name="y">提示框所在位置Y坐标</param>
        /// <returns></returns>
        public IBalloonCallout CreateBalloonCallout(double x, double y)
        {
            IRgbColor pRgbClr = new RgbColorClass();

            pRgbClr.Red   = 255;
            pRgbClr.Blue  = 255;
            pRgbClr.Green = 255;
            ISimpleFillSymbol pSmplFill = new SimpleFillSymbolClass();

            pSmplFill.Color = pRgbClr;
            pSmplFill.Style = esriSimpleFillStyle.esriSFSSolid;
            IBalloonCallout pBllnCallout = new BalloonCalloutClass();

            pBllnCallout.Style           = esriBalloonCalloutStyle.esriBCSRoundedRectangle;
            pBllnCallout.Symbol          = pSmplFill;
            pBllnCallout.LeaderTolerance = 1;
            IPoint pPoint = new ESRI.ArcGIS.Geometry.PointClass();

            pPoint.X = x;
            pPoint.Y = y;
            pBllnCallout.AnchorPoint = pPoint;
            return(pBllnCallout);
        }
示例#10
0
        public IElement AddCallout(IMapControl2 mapControl, IPoint pPoint, string strText, IRgbColor color)
        {
            IPoint pPointText = new PointClass();

            pPointText.PutCoords(pPoint.X + 1.5, pPoint.Y + 1.5);

            ITextElement         pTextElement = new TextElementClass();
            IFormattedTextSymbol pTextSymbol  = new TextSymbolClass();

            IElement pElement = pTextElement as IElement;

            pTextElement.Text      = strText;
            pTextElement.ScaleText = true;
            pElement.Geometry      = pPointText;

            ISimpleFillSymbol pSmplFill = new SimpleFillSymbolClass();

            pSmplFill.Color = color;
            pSmplFill.Style = esriSimpleFillStyle.esriSFSHollow;

            IBalloonCallout pBalloonCallout = new BalloonCalloutClass();

            pBalloonCallout.Symbol          = pSmplFill;
            pBalloonCallout.Style           = esriBalloonCalloutStyle.esriBCSOval;
            pBalloonCallout.AnchorPoint     = pPointText;
            pBalloonCallout.LeaderTolerance = 5;


            pTextSymbol.Background = pBalloonCallout as ITextBackground;
            pTextSymbol.Color      = color;
            pTextSymbol.Size       = (mapControl.MapScale / 100) * 5;
            //pTextSymbol.Size = 25;
            pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
            pTextElement.Symbol             = pTextSymbol;

            return(pElement);
        }
        private void ShowCallout(IPoint loc, string text)
        {
            try
            {
                ITextElement         pTextElement = new TextElementClass();
                IElement             pElement;
                IBalloonCallout      pCallout     = new BalloonCalloutClass();
                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;

                pCallout.Symbol      = pFill;
                pCallout.Style       = esriBalloonCalloutStyle.esriBCSRoundedRectangle;
                pCallout.AnchorPoint = loc;

                pLabelSymbol.Background    = pCallout 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 * mMap.MapScale) / 2;
                //switch (mMap.MapScale)
                //{
                //    case
                //}

                IPoint p1 = new PointClass();
                p1.X = loc.X + delta;
                p1.Y = loc.Y + delta;


                pElement.Geometry = p1;



                graphicsContainer = mDoc.ActiveView as IGraphicsContainer;

                graphicsContainer.AddElement(pElement, 0);
                pElement.Activate(mDoc.ActiveView.ScreenDisplay);

                mDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pElement, null);
                mMap.ClearSelection();

                Timer t = new Timer();
                t.Interval = 2000;
                t.Tick    += new EventHandler(t_Tick);
                t.Start();
            }
            catch (Exception ex) { log.WriteError(ex, TAG, System.Security.Principal.WindowsIdentity.GetCurrent().Name, null); }
        }
示例#12
0
        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);
        }
示例#13
0
 public IBalloonCallout CreateBalloonCallout(double x, double y)
 {
     IRgbColor pRgbClr = new RgbColorClass();
     pRgbClr.Red = 255;
     pRgbClr.Blue = 255;
     pRgbClr.Green = 255;
     ISimpleFillSymbol pSmplFill = new SimpleFillSymbolClass();
     pSmplFill.Color = pRgbClr;
     pSmplFill.Style = esriSimpleFillStyle.esriSFSSolid;
     IBalloonCallout pBllnCallout = new BalloonCalloutClass();
     pBllnCallout.Style = esriBalloonCalloutStyle.esriBCSRectangle;
     pBllnCallout.Symbol = pSmplFill;
     pBllnCallout.LeaderTolerance = 1;
     IPoint pPoint = new ESRI.ArcGIS.Geometry.PointClass();
     pPoint.X = x;
     pPoint.Y = y;
     pBllnCallout.AnchorPoint = pPoint;
     return pBllnCallout;
 }
示例#14
0
        //TextSymbol
        private void button18_Click(object sender, EventArgs e)
        {
            ITextSymbol textSymbol = new TextSymbolClass();

            System.Drawing.Font drawFont = new System.Drawing.Font("宋体", 16, FontStyle.Bold);
            stdole.IFontDisp    fontDisp = (stdole.IFontDisp)(new stdole.StdFontClass());
            textSymbol.Font  = fontDisp;
            textSymbol.Color = getRGB(0, 255, 0);
            textSymbol.Size  = 20;
            IPolyline polyline = new PolylineClass();
            IPoint    point    = new PointClass();

            point.PutCoords(1, 1);
            polyline.FromPoint = point;
            point.PutCoords(10, 10);
            polyline.ToPoint = point;
            ITextPath textPath = new BezierTextPathClass();
            //创建简单标注
            ILineSymbol lineSymbol = new SimpleLineSymbolClass();

            lineSymbol.Color = getRGB(255, 0, 0);
            lineSymbol.Width = 5;
            ISimpleTextSymbol simpleTextSymbol = textSymbol as ISimpleTextSymbol;

            simpleTextSymbol.TextPath = textPath;
            object      oLineSymbol = lineSymbol;
            object      oTextSymbol = textSymbol;
            IActiveView activeView  = this.axMapControl1.ActiveView;

            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(oLineSymbol as ISymbol);
            activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
            activeView.ScreenDisplay.SetSymbol(oTextSymbol as ISymbol);
            activeView.ScreenDisplay.DrawText(polyline as IGeometry, "简单标注");;
            activeView.ScreenDisplay.FinishDrawing();

            //创建气泡标注(两中风格,一种是有锚点,一种是marker方式)
            //锚点方式
            ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();

            simpleFillSymbol.Color = getRGB(0, 255, 0);
            simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
            IBalloonCallout balloonCallout = new BalloonCalloutClass();

            balloonCallout.Style           = esriBalloonCalloutStyle.esriBCSRectangle;
            balloonCallout.Symbol          = simpleFillSymbol;
            balloonCallout.LeaderTolerance = 10;

            point.PutCoords(5, 5);
            balloonCallout.AnchorPoint = point;

            IGraphicsContainer   graphicsContainer   = activeView as IGraphicsContainer;
            IFormattedTextSymbol formattedTextSymbol = new TextSymbolClass();

            formattedTextSymbol.Color = getRGB(0, 0, 255);
            point.PutCoords(10, 5);
            ITextBackground textBackground = balloonCallout as ITextBackground;

            formattedTextSymbol.Background = textBackground;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(formattedTextSymbol as ISymbol);
            activeView.ScreenDisplay.DrawText(point as IGeometry, "气泡1");
            activeView.ScreenDisplay.FinishDrawing();


            //marker方式
            textSymbol                     = new TextSymbolClass();
            textSymbol.Color               = getRGB(255, 0, 0);
            textSymbol.Angle               = 0;
            textSymbol.RightToLeft         = false;
            textSymbol.VerticalAlignment   = esriTextVerticalAlignment.esriTVABaseline;
            textSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHAFull;


            IMarkerTextBackground markerTextBackground = new MarkerTextBackgroundClass();

            markerTextBackground.ScaleToFit = true;
            markerTextBackground.TextSymbol = textSymbol;

            IRgbColor            rgbColor            = new RgbColorClass();
            IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass();
            //string fileName = @"E:\vs2005\第五章\lesson2\lesson2\data\qq.bmp";
            string path     = Directory.GetCurrentDirectory();
            string fileName = path + @"\qq.bmp";

            pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, fileName);
            pictureMarkerSymbol.Angle = 0;
            pictureMarkerSymbol.BitmapTransparencyColor = rgbColor;
            pictureMarkerSymbol.Size    = 20;
            pictureMarkerSymbol.XOffset = 0;
            pictureMarkerSymbol.YOffset = 0;

            markerTextBackground.Symbol = pictureMarkerSymbol as IMarkerSymbol;

            formattedTextSymbol       = new TextSymbolClass();
            formattedTextSymbol.Color = getRGB(255, 0, 0);
            fontDisp.Size             = 10;
            fontDisp.Bold             = true;
            formattedTextSymbol.Font  = fontDisp;

            point.PutCoords(15, 5);

            formattedTextSymbol.Background = markerTextBackground;
            activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            activeView.ScreenDisplay.SetSymbol(formattedTextSymbol as ISymbol);
            activeView.ScreenDisplay.DrawText(point as IGeometry, "气泡2");
            activeView.ScreenDisplay.FinishDrawing();
        }
示例#15
0
        private void AddCallOutElement(IPolyline pPolyline)
        {
            IGraphicsContainer pGraphicCtn = m_pActiveView.GraphicsContainer;

            try
            {
                frmEdit frmCallOut       = new frmEdit(true);
                PublicClass.POINTAPI pos = new PublicClass.POINTAPI();
                PublicClass.GetCursorPos(ref pos);
                frmCallOut.Location = new System.Drawing.Point(pos.x, pos.y); // * pScreen.BitsPerPixel
                int scrW = Screen.PrimaryScreen.WorkingArea.Width;            //主显示宽度
                int scrH = Screen.PrimaryScreen.WorkingArea.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;

                IBalloonCallout pCallout = new BalloonCalloutClass();
                pCallout.Symbol        = frmCallOut.m_pFillSymbol;
                pCallout.AnchorPoint   = pPolyline.FromPoint;
                pTextSymbol.Background = (ITextBackground)pCallout;

                pTextElement.Symbol = pTextSymbol as ITextSymbol;
                IElement pElement = (IElement)pTextElement;
                pElement.Geometry = pPolyline.ToPoint;

                //刷新显示
                frmCallOut.Dispose();
                IGraphicsContainerSelect pGraphicsSel = pGraphicCtn as IGraphicsContainerSelect;
                pGraphicsSel.UnselectAllElements();
                pGraphicsSel.SelectElement(pElement);
                pGraphicCtn.AddElement(pElement, 0);
                m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("添加文本注记失败:" + ex.Message, "提示");
                return;
            }
        }