ArcEngine 测量 docx 下载本文

} catch { }

}

public override void OnMouseMove(int Button, int Shift, int X, int Y) {

if (m_NewLineFeedback == null) return;

IPoint pt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

m_NewLineFeedback.MoveTo(pt);

if (m_ptColl.PointCount == 0) return;

double d_Total = 0; double d_segment = 0;

IPoint lastPt = m_ptColl.get_Point(m_ptColl.PointCount - 1);

ILine line = new LineClass(); line.PutCoords(lastPt, pt); //节距离

d_segment = line.Length; _MsgInfo.Segment = d_segment; try {

IPolyline polyline = m_ptColl as IPolyline; if (polyline.IsEmpty)

{

d_Total = d_segment; } else {

d_Total = polyline.Length + d_segment; }

} catch {

}

//赋值给总长度

_MsgInfo.Total = d_Total; }

public override void OnDblClick() {

if (m_NewLineFeedback == null) return;

//绘制线与多边形几何图形时,双击结束绘制

try {

m_TraceLine = m_NewLineFeedback.Stop(); if (m_TraceLine == null) return; } catch

{ } finally {

Recycle(); } }

#endregion

//回收

public void Recycle() {

m_NewLineFeedback = null;

m_ptColl.RemovePoints(0, m_ptColl.PointCount); m_ptColl = null;

m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, m_hookHelper.ActiveView.Extent); }

///

/// 从组中删除所有元素 ///

///

void RemoveElementFromGroupElement(IGroupElement groupElement) {

if (groupElement == null || groupElement.ElementCount == 0)

return; try {

IGraphicsContainer g = m_hookHelper.ActiveView.GraphicsContainer;

for (int index = 0; index < groupElement.ElementCoun

t; index++) {

IElement tmp_Ele = groupElement.get_Element(index);

if (tmp_Ele is IGroupElement)

RemoveElementFromGroupElement(tmp_Ele as IGroupElement);

else { try {

groupElement.DeleteElement(tmp_Ele); } catch {

} finally {

tmp_Ele = null; } } }

//groupElement.ClearElements(); } catch { } finally {

//刷新

IEnvelope pEnvBounds = null;