• 博客园logo
  • 会员
  • 周边
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

gisoracle

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

ArcGis实现画矩形(RectangleFeedBack)

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;
        }

posted on 2015-09-18 10:38  gisai  阅读(6513)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3