博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
AE创建气泡式的提示框(VB.Net和C#源码)
阅读量:6229 次
发布时间:2019-06-21

本文共 4307 字,大约阅读时间需要 14 分钟。

 
 下面是用AE创建气泡式提示框的方法:
  
 1、VB.Net源码
  ''' <summary>
  ''' 创建文本提示框
  ''' </summary>
  ''' <param name="x">提示框标识的位置X坐标</param>
  ''' <param name="y">提示框标识的位置Y坐标</param>
  ''' <param name="pTextString">提示框中显示的文本</param>
  ''' <param name="pPoint">提示框箭头指向的点</param>
  ''' <param name="pGraphicsContainer">包含提示框的graphicscontainer</param>
  ''' <returns></returns>
  ''' <remarks></remarks>
  Public Function CreateTextElement(ByVal x As Double, ByVal y As Double, ByVal pTextString As String, Optional ByVal pPoint As IPoint = Nothing, Optional ByVal pGraphicsContainer As IGraphicsContainer = Nothing) As IElement
    Dim pElement As IElement = New MarkerElementClass()
    Dim pTElement As IElement = New TextElementClass()
    Dim pTextSymbol As IFormattedTextSymbol = New TextSymbolClass()
    Dim pBalloonCallout As IBalloonCallout = CreateBalloonCallout(x, y)
    Dim pColor As IRgbColor = New RgbColorClass()
    pColor.Red = 150
    pColor.Green = 0
    pColor.Blue = 0
    pTextSymbol.Color = pColor
    Dim pTextBackground As ITextBackground
    pTextBackground = pBalloonCallout
    pTextSymbol.Background = pTextBackground
    pTextSymbol.Size = 8
    CType(pTElement, ITextElement).Symbol = pTextSymbol
    CType(pTElement, ITextElement).Text = pTextString
    If pPoint Is Nothing Then pPoint = New Point : pPoint.PutCoords(x + Const_Dis, y + Const_Dis)
    pTElement.Geometry = pPoint
    pGraphicsContainer.AddElement(pTElement, 1)
    Return pTElement
  End Function
  ''' <summary>
  ''' 创建balloon型提示框
  ''' </summary>
  ''' <param name="x">提示框所在位置X坐标</param>
  ''' <param name="y">提示框所在位置Y坐标</param>
  ''' <returns></returns>
  ''' <remarks></remarks>
  
Public Function CreateBalloonCallout(ByVal x As Double, ByVal y As Double) As IBalloonCallout
    Dim pRgbClr As IRgbColor = New RgbColorClass()
    pRgbClr.Red = 255
    pRgbClr.Blue = 255
    pRgbClr.Green = 255
    Dim pSmplFill As ISimpleFillSymbol = New SimpleFillSymbolClass()
    pSmplFill.Color = pRgbClr
    pSmplFill.Style = esriSimpleFillStyle.esriSFSSolid
    Dim pBllnCallout As IBalloonCallout = New BalloonCalloutClass()
    pBllnCallout.Style = esriBalloonCalloutStyle.esriBCSRoundedRectangle
    pBllnCallout.Symbol = pSmplFill
    pBllnCallout.LeaderTolerance = 1
    Dim pPoint As IPoint = New ESRI.ArcGIS.Geometry.PointClass()
    pPoint.X = x
    pPoint.Y = y
    pBllnCallout.AnchorPoint = pPoint
    Return pBllnCallout
  End Function
  2、C#源码
 
       public void CreateTextElment(double x, double y)
        {
            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 = "测试";
            pPoint.X = x + 42;
            pPoint.Y = y + 42;
            pTElement.Geometry = pPoint;
            pGraphicsContainer.AddElement(pTElement, 1);
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
        }
       
        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;
        }
版权说明

  如果标题未标有<转载、转>等字则属于作者原创,欢迎转载,其版权归作者和博客园共有。 

  作      者:温景良
  文章出处:  或  

分类:  ,
       
0
0
上一篇:
下一篇:
posted @  2008-12-10 17:19   Views( 1285) Comments( 2)   
  
 
2010-01-14 17:23 |   
这个怎么用,能不能说清楚一些呢,最好有个demo下载。
  
[
楼主
2010-01-14 19:08 |   
yush:这个怎么用,能不能说清楚一些呢,最好有个demo下载。
这个我是在网上找的,就这代码,试了好像不太管用
最新IT新闻:
· 
· 
· 
· 
· 
» 
最新知识库文章:
· 
· 
· 
· 
· 
» 
本文转自
博客园博客,原文链接:http://www.cnblogs.com/wenjl520/archive/2008/12/10/1352134.html,如需转载请自行联系原作者
 
你可能感兴趣的文章
谈谈OpenNI 2的安装
查看>>
Ecshop 商品页配送方式添加 实现仿淘宝按地区显示运费
查看>>
SCAU 10685 ACMer不得不知道的事儿(一)-----续
查看>>
List Se 和Map的区别
查看>>
RTS打卡计划第四周
查看>>
C#_delegate - Pair<T> 静态绑定
查看>>
成都OpenPart——DevOps专场活动参与感
查看>>
Delphi xe6 android Popup控件的使用
查看>>
浅谈linux读写同步机制RCU
查看>>
三层架构设计理念
查看>>
spring的@Transactional
查看>>
java 中生成随机验证码
查看>>
计划任务启动停止控制台程序
查看>>
04-单表查询
查看>>
[ZJOI2006]皇帝的烦恼
查看>>
HTML5简介
查看>>
Read All About It-Attraction舞团
查看>>
[摘录]第1章 开局谈判技巧
查看>>
as 运算符
查看>>
基本数据类型对象包装类
查看>>