示例#1
0
 private void RefreshTracker()
 {
     if (this.m_pCachedDisplay != null)
     {
         IGeometry geometry = new ESRI.ArcGIS.Geometry.Polygon() as IGeometry;
         this.QueryOutline(this.m_pCachedDisplay, geometry as IPolygon);
         this.m_pSelectionTracker.Geometry = geometry.Envelope;
     }
 }
示例#2
0
        public void QueryOutline(IDisplay Display, IPolygon Outline)
        {
            IPolygon boundary = new ESRI.ArcGIS.Geometry.Polygon() as IPolygon;

            boundary.SetEmpty();
            ((ISymbol)this.m_pFillSymbol1).QueryBoundary(Display.hDC, Display.DisplayTransformation, this.m_pGeometry,
                                                         boundary);
            ((IPointCollection)Outline).AddPointCollection((IPointCollection)boundary);
        }
示例#3
0
        public bool HitTest(double x, double y, double Tolerance)
        {
            IPoint other = new ESRI.ArcGIS.Geometry.Point();

            other.PutCoords(x, y);
            IRelationalOperator @operator = new ESRI.ArcGIS.Geometry.Polygon() as IRelationalOperator;

            this.QueryOutline(this.m_pCachedDisplay, @operator as IPolygon);
            return([email protected](other));
        }
示例#4
0
        public void QueryBounds(IDisplay Display, IEnvelope Bounds)
        {
            IPolygon boundary = new ESRI.ArcGIS.Geometry.Polygon() as IPolygon;

            boundary.SetEmpty();
            ((ISymbol)this.m_pFillSymbol1).QueryBoundary(Display.hDC, Display.DisplayTransformation, this.m_pGeometry,
                                                         boundary);
            Bounds.XMin             = boundary.Envelope.XMin;
            Bounds.XMax             = boundary.Envelope.XMax;
            Bounds.YMin             = boundary.Envelope.YMin;
            Bounds.YMax             = boundary.Envelope.YMax;
            Bounds.SpatialReference = boundary.Envelope.SpatialReference;
        }
示例#5
0
        public void Transform(esriTransformDirection direction, ITransformation transformation)
        {
            object           before = Missing.Value;
            IPointCollection points = new ESRI.ArcGIS.Geometry.Polygon();

            points.AddPoint(this.m_pGeometry.LowerLeft, ref before, ref before);
            points.AddPoint(this.m_pGeometry.LowerRight, ref before, ref before);
            points.AddPoint(this.m_pGeometry.UpperRight, ref before, ref before);
            points.AddPoint(this.m_pGeometry.UpperLeft, ref before, ref before);
            (points as IPolygon).Close();
            (points as IGeometry).SpatialReference = this.m_pGeometry.SpatialReference;
            (points as ITransform2D).Transform(direction, transformation);
            IEnvelope envelope = (points as IPolygon).Envelope;

            this.m_pGeometry = envelope;
            this.RefreshTracker();
        }
示例#6
0
        //获得一个环的形状
        private static ESRI.ArcGIS.Geometry.Polygon MakePolygonFromRing(ESRI.ArcGIS.Geometry.IRing pRing)
        {
            ESRI.ArcGIS.Geometry.Polygon pResPolygon = null;

            ESRI.ArcGIS.Geometry.IPolygon pPolygon = null;
            try
            {
                pPolygon = new ESRI.ArcGIS.Geometry.PolygonClass();
                ESRI.ArcGIS.Geometry.IGeometryCollection pGeometryCollection;
                pGeometryCollection = pPolygon as ESRI.ArcGIS.Geometry.IGeometryCollection;
                object missing = Type.Missing;
                pGeometryCollection.AddGeometry(pRing, ref missing, ref missing);
                pResPolygon = pPolygon as ESRI.ArcGIS.Geometry.Polygon;
                return(pResPolygon);
            }
            catch (Exception err)
            {
                pResPolygon = null;
                pPolygon    = null;
            }
            return(null);
        }
示例#7
0
        private Image SymbolToBitmap(IGradientFillSymbol iSymbol, int iStyle, int iWidth, int iHeight)
        {
            IntPtr    iHDC      = new IntPtr();
            Bitmap    iBitmap   = new Bitmap(iWidth, iHeight);
            Graphics  iGraphics = System.Drawing.Graphics.FromImage(iBitmap);
            tagRECT   itagRECT;
            IEnvelope iEnvelope = new EnvelopeClass() as IEnvelope;
            IDisplayTransformation iDisplayTransformation;
            IPoint iPoint;
            IGeometryCollection iPolyline;
            IGeometryCollection iPolygon;
            IRing iRing;
            ISegmentCollection iSegmentCollection;
            IGeometry          iGeometry = null;
            object             Missing   = Type.Missing;

            iEnvelope.PutCoords(0, 0, iWidth, iHeight);
            itagRECT.left          = 0;
            itagRECT.right         = iWidth;
            itagRECT.top           = 0;
            itagRECT.bottom        = iHeight;
            iDisplayTransformation = new DisplayTransformationClass();
            iDisplayTransformation.VisibleBounds = iEnvelope;
            iDisplayTransformation.Bounds        = iEnvelope;
            iDisplayTransformation.set_DeviceFrame(ref itagRECT);
            iDisplayTransformation.Resolution = iGraphics.DpiX / 100000;
            iHDC = iGraphics.GetHdc();
            //获取Geometry;

            if (iSymbol is ESRI.ArcGIS.Display.IMarkerSymbol)
            {
                switch (iStyle)
                {
                case 0:
                    iPoint = new ESRI.ArcGIS.Geometry.Point();
                    iPoint.PutCoords(iWidth / 2, iHeight / 2);
                    iGeometry = iPoint;
                    break;

                default:
                    break;
                }
            }
            else
            {
                if (iSymbol is ESRI.ArcGIS.Display.ILineSymbol)
                {
                    iSegmentCollection = new ESRI.ArcGIS.Geometry.Path() as ISegmentCollection;
                    iPolyline          = new ESRI.ArcGIS.Geometry.Polyline() as IGeometryCollection;
                    switch (iStyle)
                    {
                    case 0:
                        iSegmentCollection.AddSegment(CreateLine(0, iHeight / 2, iWidth, iHeight / 2) as ISegment, ref Missing, ref Missing);

                        iPolyline.AddGeometry(iSegmentCollection as IGeometry, ref Missing, ref Missing);
                        iGeometry = iPolyline as IGeometry;
                        break;

                    case 1:
                        iSegmentCollection.AddSegment(CreateLine(0, iHeight / 4, iWidth / 4, 3 * iHeight / 4) as ISegment, ref Missing, ref Missing);
                        iSegmentCollection.AddSegment(CreateLine(iWidth / 4, 3 * iHeight / 4, 3 * iWidth / 4, iHeight / 4) as ISegment, ref Missing, ref Missing);
                        iSegmentCollection.AddSegment(CreateLine(3 * iWidth / 4, iHeight / 4, iWidth, 3 * iHeight / 4) as ISegment, ref Missing, ref Missing);
                        iPolyline.AddGeometry(iSegmentCollection as IGeometry, ref Missing, ref Missing);
                        iGeometry = iPolyline as IGeometry;
                        break;

                    default:
                        break;
                    }
                }
                else
                if (iSymbol is ESRI.ArcGIS.Display.IFillSymbol)
                {
                    iSegmentCollection = new ESRI.ArcGIS.Geometry.Ring() as ISegmentCollection;
                    iPolygon           = new ESRI.ArcGIS.Geometry.Polygon() as IGeometryCollection;
                    switch (iStyle)
                    {
                    case 0:
                        iSegmentCollection.AddSegment(CreateLine(5, iHeight - 5, iWidth - 6, iHeight - 5) as ISegment, ref Missing, ref Missing);
                        iSegmentCollection.AddSegment(CreateLine(iWidth - 6, iHeight - 5, iWidth - 6, 6) as ISegment, ref Missing, ref Missing);
                        iSegmentCollection.AddSegment(CreateLine(iWidth - 6, 6, 5, 6) as ISegment, ref Missing, ref Missing);
                        iRing = iSegmentCollection as IRing;
                        iRing.Close();
                        iPolygon.AddGeometry(iSegmentCollection as IGeometry, ref Missing, ref Missing);
                        iGeometry = iPolygon as IGeometry;
                        break;

                    default:
                        break;
                    }
                }
                else
                if (iSymbol is ESRI.ArcGIS.Display.ISimpleTextSymbol)
                {
                    switch (iStyle)
                    {
                    case 0:
                        iPoint = new ESRI.ArcGIS.Geometry.Point();
                        iPoint.PutCoords(iWidth / 2, iHeight / 2);
                        iGeometry = iPoint;
                        break;

                    default:
                        break;
                    }
                }
            }////////////////////////
            if (iGeometry == null)
            {
                MessageBox.Show("几何对象不符合!", "错误");
                return(null);
            }
            ISymbol pOutputSymbol = iSymbol as ISymbol;

            pOutputSymbol.SetupDC(iHDC.ToInt32(), iDisplayTransformation);
            pOutputSymbol.Draw(iGeometry);
            pOutputSymbol.ResetDC();
            iGraphics.ReleaseHdc(iHDC);
            iGraphics.Dispose();
            return(iBitmap);
        }