Exemplo n.º 1
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();
        }
Exemplo n.º 2
0
        public static ITextSymbol get_TextSymbol(
			IColor a_Color,
			IColor a_Background,
			string a_Font,
			double a_Size,
			esriTextHorizontalAlignment a_Align,
			esriTextVerticalAlignment a_VAlign)
        {
            ITextSymbol theReturn = new TextSymbolClass();
            theReturn.Color = a_Color;
            theReturn.HorizontalAlignment = a_Align;
            theReturn.VerticalAlignment = a_VAlign;
            theReturn.Size = a_Size;

            IMarkerTextBackground theBackground = new MarkerTextBackgroundClass();
            theBackground.Symbol = GraphicsHelper.get_SimplePointSymbol(a_Background, a_Size+1, esriSimpleMarkerStyle.esriSMSCircle);
            theBackground.ScaleToFit = true;

            IFormattedTextSymbol theFTextSym = (IFormattedTextSymbol)theReturn;
            theFTextSym.Background = theBackground;

            return theReturn;
        }