几何对象Gemetry及DrawShape方法的注意事项

几何对象Gemetry及DrawShape方法的注意事项 

由 
 发布于 2007年9月26日 

DrawShape 方法只支持以下对象,而Line等对象不被支持 

Geometry objects implementing IEnvelope, IMultiPatch, IMultiPoint, IPoint, IPolygon and IPolyline are supported 

DrawShape draws the supplied geometry onto the display. Use the DrawShape method within the esriViewForeground phase of the IMapControlEvents2::OnAfterDraw event.

FlashShape flashes the supplied geometry onto the display.

 

DrawShape 方法只支持以下对象,而Line等对象不被支持

Geometry objects implementing IEnvelope, IMultiPatch, IMultiPoint, IPoint, IPolygon and IPolyline are supported

 

public partial class Form1 : Form
{
    ILine m_line;
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
    {
        if (e.button == 1)
        {
            IPoint fromPoint = new PointClass();
            fromPoint.PutCoords(100, 100);
            IPoint toPoint = new PointClass();
            toPoint.PutCoords(150, 150);
            ILine line = new LineClass();
            line.PutCoords(fromPoint, toPoint);
            Console.WriteLine(line.Length.ToString());
            m_line = line;
            axMapControl1.FullExtent = line.Envelope;
            IEnvelope pRect = new EnvelopeClass();
            pRect = axMapControl1.Extent;
            pRect.Expand(2, 2, true);
            axMapControl1.Extent = pRect;
            axMapControl1.Refresh(esriViewDrawPhase.esriViewForeground, Type.Missing, Type.Missing);
        }
        if (e.button == 2)
        {
            axMapControl1.Extent = axMapControl1.TrackRectangle();
        }


    }

    private IRgbColor GetRGBColor(int red, int green, int blue)
    {
        //Create rgb color and grab hold of the IRGBColor interface
        IRgbColor rGB = new RgbColorClass();
        //Set rgb color properties
        rGB.Red = red;
        rGB.Green = green;
        rGB.Blue = blue;
        rGB.UseWindowsDithering = true;
        return rGB;
    }

    private void axMapControl1_OnAfterDraw(object sender, IMapControlEvents2_OnAfterDrawEvent e)
    {
        if (e.viewDrawPhase == (int)esriViewDrawPhase.esriViewForeground & m_line != null)
        {
            ILineSymbol lineSymbol = new SimpleLineSymbolClass();
            //Set line symbol properties
            lineSymbol.Color = GetRGBColor(0, 0, 0);
            lineSymbol.Width = 2;
            object oLineSymbol = lineSymbol;
            IPolyline m_Polyline = new PolylineClass();
            ISegmentCollection pSeg = m_Polyline as ISegmentCollection;
            object Missing = Type.Missing;
            pSeg.AddSegment((ISegment)m_line, ref Missing, ref Missing);
            axMapControl1.DrawShape(m_Polyline, ref oLineSymbol);
        }

    }
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值