如何在MapControl界面添加双击事件实现标绘及符号样式更改

 

private void axMapControl1_OnDoubleClick(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnDoubleClickEvent e)
{
if (this._App.CurrentTool == "ESRITool") return;//实现对界面正在激活状态下工具的选取,不同tool实现不同双击事件
if (this._App.CurrentTool == "ESRIToolMe")
{
IPoint pPoint = new PointClass();
pPoint.PutCoords(e.mapX, e.mapY);

ILayer player = this.GetGraphLayer("标绘图层");
IGraphicsContainer pGraphicsContainer = player as IGraphicsContainer;
IEnumElement pEnumElement = pGraphicsContainer.LocateElements(pPoint, 1);
if (pEnumElement != null)
{
IElement pElement = pEnumElement.Next();
if (pElement is ITextElement)
{

ITextElement ptextElement = pElement as ITextElement;

FrmSymbolShow1 pLabelEditCallout = new FrmSymbolShow1("TEXT");
pLabelEditCallout.ShowDialog();

ptextElement.Symbol = pLabelEditCallout.StyleGalleryItem.Item as ITextSymbol;

pGraphicsContainer.DeleteElement(pElement);
pGraphicsContainer.AddElement(pElement, 0);
//这两句可以用pGraphicsContainer.UpdataElement(pElement);来代替
}
else if (pElement is ILineElement)
{
ILineElement ptextElement = pElement as ILineElement;

FrmSymbolShow1 pLabelEditCallout = new FrmSymbolShow1("LINE");
pLabelEditCallout.ShowDialog();

ptextElement.Symbol = pLabelEditCallout.StyleGalleryItem.Item as ILineSymbol;

pGraphicsContainer.DeleteElement(pElement);
pGraphicsContainer.AddElement(pElement, 0);
}
else if (pElement is IFillShapeElement)
{
IFillShapeElement ptextElement = pElement as IFillShapeElement;

FrmSymbolShow1 pLabelEditCallout = new FrmSymbolShow1("SHAPE");
pLabelEditCallout.ShowDialog();

ptextElement.Symbol = pLabelEditCallout.StyleGalleryItem.Item as IFillSymbol;

pGraphicsContainer.DeleteElement(pElement);
pGraphicsContainer.AddElement(pElement, 0);
}

_App.axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
}
}
if (this._App.CurrentTool != null)
{
try
{
this._App.MapControl.CurrentTool.Deactivate();
}
catch { }
this._App.MapControl.CurrentTool = null;
this._tool = this._App.ToolCol[this._App.CurrentTool];
this._tool.OnDblClick(e.button, e.shift, e.x, e.y);
}
}

转载于:https://www.cnblogs.com/lxc-binary/p/3193610.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值