zoukankan      html  css  js  c++  java
  • ArcGis实现画矩形(RectangleFeedBack)

    private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
            {
                IPoint pPoint = new PointClass();
                pPoint.PutCoords(e.mapX, e.mapY);
                pFeedBack = new NewEnvelopeFeedbackClass();
                pFeedBack.Display = axMapControl1.ActiveView.ScreenDisplay;
                pFeedBack.Start(pPoint);
            }
            private void axMapControl1_OnMouseMove(object sender, IMapControlEvents2_OnMouseMoveEvent e)
            {
                IPoint pPoint = new PointClass();
                pPoint.PutCoords(e.mapX, e.mapY);
                pFeedBack.MoveTo(pPoint);
            }
            private void axMapControl1_OnMouseUp(object sender, IMapControlEvents2_OnMouseUpEvent e)
            {
                IGeometry pGeometry;
                pGeometry = pFeedBack.Stop();
                pFeedBack = null;
                IActiveView pActiveView = axMapControl1.ActiveView;
               
                AddRectangle(pGeometry, pActiveView);
            }
            private void AddRectangle(IGeometry pGeometry, IActiveView pActiveView)
            {
                ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass();
                pSimpleLineSymbol.Color = GetRGBColor(255, 215, 0);
                pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDash;
                pSimpleLineSymbol.Width = 2;
              
                ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass();
                pSimpleFillSymbol.Color = GetRGBColor(0, 80, 30);
                pSimpleFillSymbol.Outline = pSimpleLineSymbol;
                pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
                IElement pElement;
                pElement = new RectangleElementClass();
                pElement.Geometry = pGeometry;//同画圆不同,这里直接引用的pGeometry
                IFillShapeElement pFillShapeElement;
                pFillShapeElement = pElement as IFillShapeElement;
                pFillShapeElement.Symbol = pSimpleFillSymbol;
                IGraphicsContainer pGraphicsContainer = axMapControl1.ActiveView as IGraphicsContainer;
                pGraphicsContainer.AddElement((IElement)pFillShapeElement, 0);
                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            }
            private IRgbColor GetRGBColor(int red, int green, int blue)
            {
                IRgbColor rGBColor = new RgbColorClass();
                rGBColor.Red = red;
                rGBColor.Green = green;
                rGBColor.Blue = blue;
                return rGBColor;
            }
  • 相关阅读:
    LeetCode题解——冗余连接(并查集)——java实现
    两数之和的问题
    强引用、软引用、弱引用、虚引用——4中引用的理解
    手写死锁程序实例
    使用阻塞队列实现生产者消费者问题
    ABC三个线程交替打印10遍,要求A打印5次,B打印10次,C打印15次
    使用jstack查看线程情况解决cpu飙高问题
    ES 【elasticsearch】
    C# 正则
    领域驱动设计 浅析VO、DTO、DO、PO的概念、区别和用处等资料链接(草稿)
  • 原文地址:https://www.cnblogs.com/gisoracle/p/4818520.html
Copyright © 2011-2022 走看看