コード例 #1
0
ファイル: Form1.cs プロジェクト: This-my-life/Group_Three
 public Form1()
 {
     InitializeComponent();
     axTOCControl1.SetBuddyControl(axMapControl1);
     tool    = Tools.Pointer;
     toolbtn = new ToolBtn(axMapControl1);
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: This-my-life/Group_Three
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            switch (tool)
            {
            case Tools.DrawPolygon:
                //缓冲区代码
                this.createDrawPolygon();
                break;

            case Tools.PointBuffer:
                //缓冲区代码
                this.createPointBuffer();
                break;

            case Tools.ZoomIn:
                toolbtn.zoomIn();
                break;

            case Tools.ZoomOut:
                toolbtn.zoomOut();
                break;

            case Tools.Pan:
                toolbtn.pan();
                break;

            case Tools.Distance:
                IGeometry        pline = axMapControl1.TrackLine();
                IPointCollection pc    = pline as IPointCollection;
                if (pc != null)
                {
                    double totalLen = 0.0;
                    int    iCount   = pc.PointCount;
                    for (int j = 0; j < iCount - 1; j++)
                    {
                        IPoint pt1 = pc.get_Point(j);
                        IPoint pt2 = pc.get_Point(j + 1);
                        totalLen += ToolBtn.Distance(pt1.X, pt1.Y, pt2.X, pt2.Y);
                    }
                    MessageBox.Show(String.Format("{0}米", totalLen));
                }
                break;

            case Tools.Area:
                IGeometry            pPoly = axMapControl1.TrackPolygon();
                ITopologicalOperator pTopo = pPoly as ITopologicalOperator;
                pTopo.Simplify();
                ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironment();
                ISpatialReference        earthref = spatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
                pPoly.SpatialReference = earthref;
                IPointCollection pPc = pPoly as IPointCollection;
                IPoint           pt  = pPc.get_Point(0);
                int dh     = (int)((pt.X + 6.0) / 6);
                int wikiid = 21413 + (dh - 13);
                pPoly.Project(spatialReferenceFactory.CreateProjectedCoordinateSystem(wikiid));
                IArea pArea = pPoly as IArea;
                MessageBox.Show(string.Format("{0}平方米", pArea.Area));
                break;

            case Tools.Overlap:
                break;

            case Tools.DrawPoint:
                IElement pEle;
                IPoint   p = new ESRI.ArcGIS.Geometry.Point();
                p.X = e.mapX;
                p.Y = e.mapY;
                IGraphicsContainer pGra    = axMapControl1.Map as IGraphicsContainer;
                IMarkerElement     pMakEle = new MarkerElement() as IMarkerElement;
                pEle = pMakEle as IElement;
                IMarkerSymbol pMakSym   = new SimpleMarkerSymbol();
                RgbColor      pRgbColor = new RgbColor();
                pRgbColor.Red   = 0;
                pRgbColor.Green = 0;
                pRgbColor.Blue  = 255;
                pMakSym.Color   = pRgbColor;
                pMakEle.Symbol  = pMakSym;
                pEle.Geometry   = p;
                pGra.AddElement(pEle, 0);
                axMapControl1.Refresh(esriViewDrawPhase.esriViewGraphics, null, null);
                break;

            default:
                break;
            }
        }