Esempio n. 1
0
        public void SelectByPolygon(int IndexOfLayer, RubberPolygonClass Polygon)
        {
            int            ConstantNum     = 255;
            IActiveView    CurrentView     = axMapControl1.ActiveView;
            IScreenDisplay MyScreenDispaly = CurrentView.ScreenDisplay;

            MyScreenDispaly.StartDrawing(MyScreenDispaly.hDC, (System.Int16)esriScreenCache.esriNoScreenCache);
            IRgbColor MYRGBCOLOR = new RgbColorClass();

            MYRGBCOLOR.Red = ConstantNum;
            IColor            MyColor             = MYRGBCOLOR;
            ISimpleFillSymbol MySimpleFillPolygon = new SimpleFillSymbolClass();

            MySimpleFillPolygon.Color = MyColor;
            ISymbol     MySymbol      = MySimpleFillPolygon as ISymbol;
            IRubberBand MyIRubberBand = Polygon;
            IGeometry   MyGeometry    = MyIRubberBand.TrackNew(MyScreenDispaly, MySymbol);

            MyScreenDispaly.SetSymbol(MySymbol);
            MyScreenDispaly.DrawPolygon(MyGeometry);
            MyScreenDispaly.FinishDrawing();
            ISpatialFilter MyISpatialFilter = new SpatialFilterClass();

            MyISpatialFilter.Geometry   = MyGeometry;
            MyISpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
            IFeatureLayer     SelectedLayer   = axMapControl1.ActiveView.FocusMap.get_Layer(IndexOfLayer) as IFeatureLayer;
            IFeatureSelection SelectedFeature = SelectedLayer as IFeatureSelection;

            SelectedFeature.SelectFeatures(MyISpatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
            ISelectionSet MyISelectionSet = SelectedFeature.SelectionSet;

            axMapControl1.ActiveView.Refresh();
        }
Esempio n. 2
0
        public void SelectByLine(int IndexOfLayer, RubberLineClass Line)
        {
            int            ConstantNum      = 255;
            IActiveView    CurrentView      = axMapControl1.ActiveView;
            IScreenDisplay CurScreenDisplay = CurrentView.ScreenDisplay;

            CurScreenDisplay.StartDrawing(CurScreenDisplay.hDC, (System.Int16)esriScreenCache.esriNoScreenCache);
            IRgbColor RGBCOLORS = new ESRI.ArcGIS.Display.RgbColorClass();

            RGBCOLORS.Red = ConstantNum;
            IColor            MyColor            = RGBCOLORS;
            ISimpleFillSymbol MySimpleFillSymbol = new SimpleFillSymbolClass();

            MySimpleFillSymbol.Color = MyColor;
            ISymbol     MySymbol      = MySimpleFillSymbol as ISymbol;
            IRubberBand MyIRubberBand = Line;
            IGeometry   MyGeometry    = MyIRubberBand.TrackNew(CurScreenDisplay, MySymbol);

            CurScreenDisplay.SetSymbol(MySymbol);
            CurScreenDisplay.DrawPolygon(MyGeometry);
            CurScreenDisplay.FinishDrawing();
            ISpatialFilter MySpatialFilter = new SpatialFilterClass();

            MySpatialFilter.Geometry   = MyGeometry;
            MySpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
            IFeatureLayer     SelectedLayer    = axMapControl1.ActiveView.FocusMap.get_Layer(IndexOfLayer) as IFeatureLayer;
            IFeatureSelection SelectedFeatures = SelectedLayer as IFeatureSelection;

            SelectedFeatures.SelectFeatures(MySpatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
            ISelectionSet FinalSelection = SelectedFeatures.SelectionSet;

            axMapControl1.ActiveView.Refresh();
        }
Esempio n. 3
0
 protected override void OnActivate()
 {
     //initialize variables.
     docGeometry  = null;
     m_RubberBand = null;
     base.OnActivate();
 }
Esempio n. 4
0
 //绘制多边形
 public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
 {
     {
         rubberBand = new RubberPolygonClass();
         IGeometry polygon = rubberBand.TrackNew(this.m_pMapControl.ActiveView.ScreenDisplay, null);
         if (polygon != null)
         {
             IFillShapeElement pElemFillShp;
             ISimpleFillSymbol pSFSym;
             IRgbColor         pRGB;
             IElement          element = new PolygonElementClass();
             element.Geometry = polygon;
             pElemFillShp     = (IFillShapeElement)element;
             pRGB             = new RgbColorClass();
             pRGB.Red         = 255;
             pRGB.Green       = 0;
             pRGB.Blue        = 0;
             pSFSym           = new SimpleFillSymbolClass();
             Color  color  = ColorTranslator.FromHtml(SystemInfo.Instance.FillColor);
             IColor pColor = new RgbColorClass();
             pColor.RGB          = color.B * 65536 + color.G * 256 + color.R;
             pSFSym.Color        = pColor;
             pSFSym.Style        = esriSimpleFillStyle.esriSFSSolid;
             pElemFillShp.Symbol = pSFSym;
             pGraphicsContainer  = this.m_pMapControl.ActiveView as IGraphicsContainer;
             pGraphicsContainer.AddElement(element, 0);
             m_pActiveView.Refresh();
         }
         base.OnMouseDown(button, shift, x, y, mapX, mapY);
     }
 }
    protected override void OnActivate()
    {

      //initialize variables.
      docGeometry = null;
      m_RubberBand = null;
      base.OnActivate();
    }
Esempio n. 6
0
 public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
 {
     {
         rubberBand = new RubberCircleClass();
         IGeometry polygon = rubberBand.TrackNew(this.m_pMapControl.ActiveView.ScreenDisplay, null);
         if (polygon != null)
         {
             AddCreateElement(polygon, this.m_pMapControl.ActiveView);
             this.m_pMapControl.ActiveView.Refresh();
         }
     }
     base.OnMouseDown(button, shift, x, y, mapX, mapY);
 }
    protected override void OnMouseDown(MouseEventArgs Args)//int Button, int Shift, int X, int Y)
    {
      m_RubberBand = new RubberRectangularPolygonClass();


      if (Args.Button.ToString() == "Left")  //left click
      {
        //create a new rubberband polygon.
        docGeometry = m_RubberBand.TrackNew(ArcMap.Document.ActiveView.ScreenDisplay, null);

        //zoom to the selected envelope as long as it is not zero.
        if (!docGeometry.IsEmpty)
        {
          if (docGeometry.Envelope.Height != 0 && docGeometry.Envelope.Width != 0)
          {
            ArcMap.Document.ActiveView.Extent = docGeometry.Envelope;

            //refresh to show changes.
            ArcMap.Document.ActiveView.Refresh();
          }
        }

      }
      else if (Args.Button.ToString() == "Right") //right click
      {
        //zoom out either to previous extent, or to the full extent of the active view.
        if (ArcMap.Document.ActiveView.ExtentStack.CanUndo())
        {
          //if we can, go to a previous zoom extent.
          ArcMap.Document.ActiveView.ExtentStack.Undo();
          ArcMap.Document.ActiveView.Refresh();

        }
        else
        {

          //or if no previous extents exist, go to the full extent of the active view.
          ArcMap.Document.ActiveView.Extent = ArcMap.Document.ActiveView.FullExtent.Envelope;
          ArcMap.Document.ActiveView.Refresh();
        }

      }
    }
Esempio n. 8
0
        protected override void OnMouseDown(MouseEventArgs Args)//int Button, int Shift, int X, int Y)
        {
            m_RubberBand = new RubberRectangularPolygonClass();


            if (Args.Button.ToString() == "Left") //left click
            {
                //create a new rubberband polygon.
                docGeometry = m_RubberBand.TrackNew(ArcMap.Document.ActiveView.ScreenDisplay, null);

                //zoom to the selected envelope as long as it is not zero.
                if (!docGeometry.IsEmpty)
                {
                    if (docGeometry.Envelope.Height != 0 && docGeometry.Envelope.Width != 0)
                    {
                        ArcMap.Document.ActiveView.Extent = docGeometry.Envelope;

                        //refresh to show changes.
                        ArcMap.Document.ActiveView.Refresh();
                    }
                }
            }
            else if (Args.Button.ToString() == "Right") //right click
            {
                //zoom out either to previous extent, or to the full extent of the active view.
                if (ArcMap.Document.ActiveView.ExtentStack.CanUndo())
                {
                    //if we can, go to a previous zoom extent.
                    ArcMap.Document.ActiveView.ExtentStack.Undo();
                    ArcMap.Document.ActiveView.Refresh();
                }
                else
                {
                    //or if no previous extents exist, go to the full extent of the active view.
                    ArcMap.Document.ActiveView.Extent = ArcMap.Document.ActiveView.FullExtent.Envelope;
                    ArcMap.Document.ActiveView.Refresh();
                }
            }
        }
 public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
 {
     if (_uc.DrawShape == 1)
     {
         //rubberBand = new RubberCircleClass();
         //IGeometry geo = rubberBand.TrackNew(this.m_ActiveView.ScreenDisplay, null);
         DF2DApplication app = DF2DApplication.Application;
         IGeometry       geo = app.Current2DMapControl.TrackCircle();
         if (geo != null)
         {
             AddCircleElement(geo, this.m_ActiveView);
             this.m_ActiveView.Refresh();
             m_Geo = geo;
         }
     }
     else if (_uc.DrawShape == 2)
     {
         rubberBand = new RubberRectangularPolygonClass();
         IGeometry geo = rubberBand.TrackNew(m_Display, null);
         if (geo != null)
         {
             AddRectangleElement(geo, this.m_ActiveView);
             this.m_ActiveView.Refresh();
             m_Geo = geo;
         }
     }
     else
     {
         rubberBand = new RubberPolygonClass();
         IGeometry geo = rubberBand.TrackNew(m_Display, null);
         if (geo != null)
         {
             AddPolygonElement(geo, this.m_ActiveView);
             this.m_ActiveView.Refresh();
             m_Geo = geo;
         }
     }
     try
     {
         WaitForm.Start("正在分析...", "请稍后");
         //h = _uc.H;
         pFc = GetGCD();
         h   = GetH(m_Geo, pFc);
         AddHField(pFc);
         beforeGeo = GetBeforeGeo(pFc, m_Geo);
         if (beforeGeo == null)
         {
             WaitForm.Stop(); _gc.DeleteAllElements(); return;
         }
         afterGeo = GetAfterGeo(pFc, m_Geo);
         if (afterGeo == null)
         {
             WaitForm.Stop(); _gc.DeleteAllElements(); return;
         }
         SurfaceProcess(beforeGeo, afterGeo);
         WaitForm.Stop();
         this._uc.SurfaceArea = "地表面积:" + surfaceArea;
         this._uc.ProjectArea = "投影面积:" + projectArea;
         this._uc.Dig         = "挖方量:" + dig;
         this._uc.Fill        = "填方量:" + fill;
     }
     catch (System.Exception ex)
     {
         WaitForm.Stop();
     }
 }
Esempio n. 10
0
        /// <summary>
        /// 屏幕上绘画几何形状
        /// </summary>
        /// <param name="screenDisplay">ESRI屏幕显示接口</param>
        /// <param name="geomType">几何形状类型的枚举类</param>
        /// <returns>ESRI几何形状接口</returns>
        public static IGeometry ScreenTrackGeometry(IScreenDisplay screenDisplay, DsGeometryType geomType)
        {
            IGeometry trackGeom = null;

            if (screenDisplay != null)
            {
                IRubberBand rubberBand = null;
                switch (geomType)
                {
                case DsGeometryType.dsGTPoint:
                    rubberBand = new RubberPoint();
                    break;

                case DsGeometryType.dsGTLine:
                    rubberBand = new RubberLine();
                    break;

                case DsGeometryType.dsGTPolyline:
                    rubberBand = new RubberLine();
                    break;

                case DsGeometryType.dsGTRectangle:
                    rubberBand = new RubberEnvelope();
                    break;

                case DsGeometryType.dsGTCircle:
                    rubberBand = new RubberCircle();
                    break;

                case DsGeometryType.dsGTEllipse:
                    rubberBand = new RubberEnvelope();
                    break;

                case DsGeometryType.dsGTPolygon:
                    rubberBand = new RubberPolygon();
                    break;

                case DsGeometryType.dsGTRectangularPolygon:
                    rubberBand = new RubberRectangularPolygon();
                    break;

                default:
                    break;
                }
                if (rubberBand != null)
                {
                    trackGeom = rubberBand.TrackNew(screenDisplay, null);
                }
                if (geomType == DsGeometryType.dsGTEllipse)
                {
                    trackGeom = ConvertEnvelopeToEllipticArc(trackGeom);
                }
                else if ((geomType == DsGeometryType.dsGTLine) ||
                         (geomType == DsGeometryType.dsGTPolyline) ||
                         (geomType == DsGeometryType.dsGTPolygon))
                {
                    if (trackGeom is ITopologicalOperator)
                    {
                        (trackGeom as ITopologicalOperator).Simplify();
                    }
                }
            }
            return(trackGeom);
        }