Esempio n. 1
0
        private Bitmap DrawToPictureBox(ISymbol pSym, PictureBox pBox)
        {
            IPoint    pPoint    = null;
            IGeometry pGeometry = null;
            int       hDC;

            System.Drawing.Graphics pGraphics = null;
            pGraphics = System.Drawing.Graphics.FromHwnd(pBox.Handle);
            //clear drawing canvas
            pGraphics.FillRectangle(System.Drawing.Brushes.White, pBox.ClientRectangle);
            if (pSym is IMarkerSymbol)
            {
                pPoint = new PointClass();                         //the geometry of a MarkerSymbol
                pPoint.PutCoords(pBox.Width / 2, pBox.Height / 2); //center in middle of pBox
                pGeometry = pPoint;
            }
            if (pSym is ILineSymbol)
            {
                ISegmentCollection polyline  = new ESRI.ArcGIS.Geometry.PolylineClass();
                ISegment           line      = new ESRI.ArcGIS.Geometry.LineClass();
                IPoint             fromPoint = new PointClass();
                fromPoint.PutCoords(pBox.Left, pBox.Bottom);
                IPoint toPoint = new PointClass();
                toPoint.PutCoords(pBox.Right, pBox.Top);
                line.FromPoint = fromPoint;
                line.ToPoint   = toPoint;
                object missing = Type.Missing;
                polyline.AddSegment(line, ref missing, ref missing);
                pGeometry = polyline as IGeometry;
            }
            if (pSym is IFillSymbol)
            {
                IEnvelope pEnvelope = new EnvelopeClass();
                pEnvelope.PutCoords(pBox.Left, pBox.Top, pBox.Right, pBox.Bottom);
                pGeometry = pEnvelope;
            }

            hDC = GetDC(pBox.Handle.ToInt32());
            pSym.SetupDC(hDC, null);
            pSym.ROP2 = esriRasterOpCode.esriROPCopyPen;
            pSym.Draw(pGeometry);
            pSym.ResetDC();

            Bitmap   image = new Bitmap(pBox.Width, pBox.Height, pGraphics);
            Graphics g2    = Graphics.FromImage(image);
            //获得屏幕的句柄
            IntPtr dc3 = pGraphics.GetHdc();
            //获得位图的句柄
            IntPtr dc2 = g2.GetHdc();

            BitBlt(dc2, 0, 0, pBox.Width, pBox.Height, dc3, 0, 0, SRCCOPY);
            pGraphics.ReleaseHdc(dc3); //释放屏幕句柄
            g2.ReleaseHdc(dc2);        //释放位图句柄
            //image.Save("c:\\MyJpeg.Icon", ImageFormat.Bmp);
            return(image);
        }
Esempio n. 2
0
        private void DrawToTarget(ISymbol pSym, PictureBox pBox)
        {
            IPoint    pPoint    = null;
            IGeometry pGeometry = null;

            IDisplayTransformation pDisplayTrans = null;

            if (pSym is IMarkerSymbol)
            {
                pPoint = new PointClass();                         //the geometry of a MarkerSymbol
                pPoint.PutCoords(pBox.Width / 2, pBox.Height / 2); //center in middle of pBox
                pGeometry = pPoint;
            }
            if (pSym is ILineSymbol)
            {
                ISegmentCollection polyline  = new ESRI.ArcGIS.Geometry.PolylineClass();
                ISegment           line      = new ESRI.ArcGIS.Geometry.LineClass();
                IPoint             fromPoint = new PointClass();
                fromPoint.PutCoords(pBox.Left, pBox.Bottom);
                IPoint toPoint = new PointClass();
                toPoint.PutCoords(pBox.Right, pBox.Top);
                line.FromPoint = fromPoint;
                line.ToPoint   = toPoint;
                object missing = Type.Missing;
                polyline.AddSegment(line, ref missing, ref missing);
                pGeometry = polyline as IGeometry;
            }
            if (pSym is IFillSymbol)
            {
                IEnvelope pEnvelope = new EnvelopeClass();
                pEnvelope.PutCoords(pBox.Left, pBox.Top, pBox.Right, pBox.Bottom);
                pGeometry = pEnvelope;
            }
            pDisplayTrans = getTransformation(pBox) as IDisplayTransformation;
            pSym.SetupDC(pBox.Handle.ToInt32(), null);
            pSym.ROP2 = esriRasterOpCode.esriROPCopyPen;
            pSym.Draw(pGeometry);
            pSym.ResetDC();
        }
        private void DrawToTarget(ISymbol pSym, PictureBox pBox)
        {
            IPoint pPoint = null;
            IGeometry pGeometry = null;

            IDisplayTransformation pDisplayTrans = null;

            if (pSym is IMarkerSymbol)
            {
                pPoint = new PointClass();      //the geometry of a MarkerSymbol
                pPoint.PutCoords(pBox.Width / 2, pBox.Height / 2);       //center in middle of pBox
                pGeometry = pPoint;
            }
            if (pSym is ILineSymbol)
            {
                ISegmentCollection polyline = new ESRI.ArcGIS.Geometry.PolylineClass();
                ISegment line = new ESRI.ArcGIS.Geometry.LineClass();
                IPoint fromPoint = new PointClass();
                fromPoint.PutCoords(pBox.Left, pBox.Bottom);
                IPoint toPoint = new PointClass();
                toPoint.PutCoords(pBox.Right, pBox.Top);
                line.FromPoint = fromPoint;
                line.ToPoint = toPoint;
                object missing = Type.Missing;
                polyline.AddSegment(line, ref missing, ref missing);
                pGeometry = polyline as IGeometry;
            }
            if (pSym is IFillSymbol)
            {
                IEnvelope pEnvelope = new EnvelopeClass();
                pEnvelope.PutCoords(pBox.Left, pBox.Top, pBox.Right, pBox.Bottom);
                pGeometry = pEnvelope;
            }
            pDisplayTrans = getTransformation(pBox) as IDisplayTransformation;
            pSym.SetupDC(pBox.Handle.ToInt32(), null);
            pSym.ROP2 = esriRasterOpCode.esriROPCopyPen;
            pSym.Draw(pGeometry);
            pSym.ResetDC();
        }
        private Bitmap DrawToPictureBox(ISymbol pSym, PictureBox pBox)
        {
            IPoint pPoint = null;
            IGeometry pGeometry = null;
            int hDC;
            System.Drawing.Graphics pGraphics = null;
            pGraphics = System.Drawing.Graphics.FromHwnd(pBox.Handle);
            //clear drawing canvas
            pGraphics.FillRectangle(System.Drawing.Brushes.White, pBox.ClientRectangle);
            if (pSym is IMarkerSymbol)
            {
                pPoint = new PointClass();      //the geometry of a MarkerSymbol
                pPoint.PutCoords(pBox.Width / 2, pBox.Height / 2);       //center in middle of pBox
                pGeometry = pPoint;
            }
            if (pSym is ILineSymbol)
            {
                ISegmentCollection polyline = new ESRI.ArcGIS.Geometry.PolylineClass();
                ISegment line = new ESRI.ArcGIS.Geometry.LineClass();
                IPoint fromPoint = new PointClass();
                fromPoint.PutCoords(pBox.Left, pBox.Bottom);
                IPoint toPoint = new PointClass();
                toPoint.PutCoords(pBox.Right, pBox.Top);
                line.FromPoint = fromPoint;
                line.ToPoint = toPoint;
                object missing = Type.Missing;
                polyline.AddSegment(line, ref missing, ref missing);
                pGeometry = polyline as IGeometry;
            }
            if (pSym is IFillSymbol)
            {
                IEnvelope pEnvelope = new EnvelopeClass();
                pEnvelope.PutCoords(pBox.Left, pBox.Top, pBox.Right, pBox.Bottom);
                pGeometry = pEnvelope;
            }

            hDC = GetDC(pBox.Handle.ToInt32());
            pSym.SetupDC(hDC, null);
            pSym.ROP2 = esriRasterOpCode.esriROPCopyPen;
            pSym.Draw(pGeometry);
            pSym.ResetDC();

            Bitmap image = new Bitmap(pBox.Width, pBox.Height, pGraphics);
            Graphics g2 = Graphics.FromImage(image);
            //获得屏幕的句柄
            IntPtr dc3 = pGraphics.GetHdc();
            //获得位图的句柄
            IntPtr dc2 = g2.GetHdc();
            BitBlt(dc2, 0, 0, pBox.Width, pBox.Height, dc3, 0, 0, SRCCOPY);
            pGraphics.ReleaseHdc(dc3);//释放屏幕句柄
            g2.ReleaseHdc(dc2);//释放位图句柄
            //image.Save("c:\\MyJpeg.Icon", ImageFormat.Bmp);
            return image;
        }