ArcGISengine中气泡标注的添加、修改!

更新时间:2023-07-14 07:51:04 阅读: 评论:0

ArcGISengine中⽓泡标注的添加、修改!
ArcGIS engine中⽓泡标注,是我们在编辑图形中⼀个重要的⼯具,能提供注释功能,下⾯的介绍怎么来编程实现callout的添加,以及怎么去修改它们!
// 在Mapcontrol的mouDown中添加下列内容,来添加⽓泡注释功能:callout.
privatevoid axMapControl1_OnMouDown(object nder,IMapControlEvents2_OnMouDownEvent e)
{
axMapControl1.CurrentTool = null;
IPoint pPoint ;
pPoint = new PointClass();
宁波音乐厅pPoint.PutCoords(e.mapX, e.mapY);
IFormattedTextSymbol pTextSymbol = newTextSymbolClass();
pTextSymbol.Background =CreateBalloonCallout(e.mapX, e.mapY) asITextBackground;
pTextSymbol.Direction =esriTextDirection.esriTDAngle;
pTextSymbol.Angle = 15;
ITextElement pTextElement = newTextElementClass();
pTextElement.Symbol = pTextSymbol asITextSymbol;
pTextElement.Text = "MaDeSheng";
IElement ptexte = pTextElement asIElement;
pPoint = new PointClass();
pPoint.PutCoords(e.mapX * 0.90, e.mapY*1.1);
ptexte.Geometry = pPoint as IGeometry;
IMap pMap = axMapControl1.Map;
IGraphicsContainer pGraphicsContainer = pMap asIGraphicsContainer;
pGraphicsContainer.AddElement(pTextElement asIElement, 0);
this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPha.esriViewGraphics,null, null);
}
恍然大悟的拼音红颜⾊的部分是产⽣⽓泡背景,具体程序如下:
public IBalloonCalloutCreateBalloonCallout(double x, double y)
{
IRgbColor pRgbClr = newRgbColorClass();
pRgbClr.Red =225;
pRgbClr.Blue =225;
pRgbClr.Green =225;
ISimpleFillSymbol pSmplFill =new SimpleFillSymbolClass();
pSmplFill.Color =pRgbClr;
pSmplFill.Style =esriSimpleFillStyle.esriSFSSolid;
IBalloonCallout pBllnCallout= new BalloonCalloutClass();
//pBllnCallout.Style =esriBalloonCalloutStyle.esriBCSRectangle;
pBllnCallout.Style =esriBalloonCalloutStyle.esriBCSRoundedRectangle;
pBllnCallout.Symbol =pSmplFill;
pBllnCallout.LeaderTolerance= 5;
IPoint pPoint = newESRI.ArcGIS.Geometry.PointClass();
pPoint.X =x;
pPoint.Y =y;
pBllnCallout.AnchorPoint =pPoint;
returnpBllnCallout;
}
那么添加了之后如何修改呢?
双击事件!
private void axMapControl1_OnDoubleClick(objectnder, IMapControlEvents2_OnDoubleClickEvent e)
{
if(e.button ==1)
{
//标注的修改
带笔的成语
if(((axMapControl1.CurrentTool) as ICommand).Name =="ControlToolsGraphicEleme nt_SelectTool")//这⼀句的判断很⽜B,我当时考虑了半天才搞出来。难点呀!toolbarControl中要加载esriControls.ControlsSelectTool⼯具
{
IPoint pPoint = new PointClass();单相思什么意思
pPoint.PutCoords(e.mapX, e.mapY);
IMap pMap = axMapControl1.Map;
IGraphicsContainer pGraphicsContainer = pMap asIGraphicsContainer;
IEnumElement pEnumElement =pGraphicsContainer.LocateElements(pPoint, 10);
if (pEnumElement != null)
{
IElementpElement = pEnumElement.Next();
if(pElement is ITextElement)
{
ITextElement ptextElement =pElement as ITextElement;
labelEditCallout pLabelEditCallout = newlabelEditCallout(ptextElement.Text,ptextElement.Symbol);
pLabelEditCallout.ShowDialog();
ptextElement.Text =pLabelEditCallout.inputText;
ptextElement.Symbol =Symbol;
pGraphicsContainer.DeleteElement(pElement);
pGraphicsContainer.AddElement(pElement,0);
//这两句可以⽤pGraphicsContainer.UpdataElement(pElement);来代替
this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPha.esriViewGraphics,null, null);
}
}
}
}
}
labelEditCallout是我⾃⼰弄的⼀个修改样式,其实很简单的⼀个页⾯,截图如下:
具体,代码如下:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingESRI.ArcGIS.Display;
usingESRI.ArcGIS.Geometry;
namespaceEdit
{
public partial class labelEditCallout :Form
{
publicstring inputText = "";
publicITextSymbol textSymbol;
privatebool ModifFillColor = fal;
publiclabelEditCallout(string s,ITextSymbol texSy)
{
inputText =s;
textSymbol =texSy;
InitializeComponent();
}
privatevoid labelEditCallout_Load(object nder, EventArg)
{
textBox1.Text =inputText;
comboBox1.Items.Add("矩形框");
comboBox1.Items.Add("圆⾓矩形");
机动车验车新规定//comboBox1.Items.Add("Oval");
comboBox1.SelectedIndex = 1;
}
publicIColor ConvertColorToIColor(Color color)
{
IColor pColor = newRgbColorClass();
pColor.RGB = color.B * 65536+ color.G * 256 + color.R;
returnpColor;
}
privatevoid button2_Click(object nder, EventArgs e)
{
IBalloonCallout textBack =(((IFormattedTextSymbol)textSymbol).Background) asIBalloonCallout;          IFillSymbol pOldFill =textBack.Symbol;
IPoint pPoint =textBack.AnchorPoint;
ISimpleFillSymbol pSmplFill =new SimpleFillSymbolClass();
pSmplFill.Style =esriSimpleFillStyle.esriSFSSolid;
if(ModifFillColor)
{
pSmplFill.Color =ConvertColorToIColor(this.button1.BackColor);
}
el
pSmplFill.Color =pOldFill.Color;
IBalloonCallout pBllnCallout= new BalloonCalloutClass();
switch(comboBox1.Text)
{
ca"矩形框":
pBllnCallout.Style =esriBalloonCalloutStyle.esriBCSRectangle;
break;
ca"圆⾓矩形":
媳妇英文
pBllnCallout.Style =esriBalloonCalloutStyle.esriBCSRoundedRectangle;
break;
//ca"Oval":
/
/  pBllnCallout.Style =esriBalloonCalloutStyle.esriBCSOval;
//  break;
}
pBllnCallout.Symbol =pSmplFill;
pBllnCallout.LeaderTolerance= 5;
pBllnCallout.AnchorPoint =pPoint;
IFormattedTextSymbolpTextSymbol = new TextSymbolClass();
pTextSymbol.Direction =esriTextDirection.esriTDAngle;
pTextSymbol.Angle =15;成长中的一件事作文
pTextSymbol.Background =pBllnCallout as ITextBackground;北京各区分布图
textSymbol = pTextSymbol asITextSymbol;
inputText =textBox1.Text;
this.Clo();
}
//获取颜⾊
privatevoid button1_Click(object nder, EventArgs e)
{
lorDialog.ShowDialog() ==DialogResult.OK)
{
this.button1.BackColor =lorDialog.Color;
ModifFillColor = true;
}
}
privatevoid button3_Click(object nder, EventArgs e)
{
this.Clo();
}
}
}

本文发布于:2023-07-14 07:51:04,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1080907.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:添加   修改   注释   功能
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图