Exemple #1
0
        //绘制单个点操作
        public void DrawPoint(IActiveView activeView, IPoint p, bool red)
        {
            if (activeView == null)
            {
                return;
            }

            ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;
            screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache);
            ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();
            simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCross;
            simpleMarkerSymbol.Size  = 15;
            if (red)
            {
                simpleMarkerSymbol.Color = redColor;
            }
            else
            {
                simpleMarkerSymbol.Color = greenColor;
            }

            ESRI.ArcGIS.Display.ISymbol symbol = simpleMarkerSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic cast.
            screenDisplay.SetSymbol(symbol);
            ESRI.ArcGIS.Display.IDisplayTransformation displayTransformation = screenDisplay.DisplayTransformation;
            screenDisplay.DrawPoint(p);
            screenDisplay.FinishDrawing();
        }
Exemple #2
0
 private void SetupDeviceRatio(int hDC, ESRI.ArcGIS.Display.IDisplayTransformation displayTransform)
 {
     if (displayTransform != null)
     {
         if (displayTransform.Resolution != 0)
         {
             m_dDeviceRatio = displayTransform.Resolution / 72;
             //  Check the ReferenceScale of the display transformation. If not zero, we need to
             //  adjust the Size, XOffset and YOffset of the Symbol we hold internally before drawing.
             if (displayTransform.ReferenceScale != 0)
                 m_dDeviceRatio = m_dDeviceRatio * displayTransform.ReferenceScale / displayTransform.ScaleRatio;
         }
     }
     else
     {
         // If we dont have a displaytransformation, calculate the resolution
         // from the actual device.
         if (hDC != 0)
         {
             // Get the resolution from the device context hDC.
             m_dDeviceRatio = System.Convert.ToDouble(Utility.GetDeviceCaps(hDC, Utility.LOGPIXELSX)) / 72;
         }
         else
         {
             // If invalid hDC assume we're drawing to the screen.
             m_dDeviceRatio = 1 / (Utility.TwipsPerPixelX() / 20); // 1 Point = 20 Twips.
         }
     }
 }
Exemple #3
0
 private void Terminate()
 {
     //  Which variables do we really need to dereference here, just the transformation,
     //  or any other globals as well??
     m_trans = null;
     m_colorTop = null;
     m_colorLeft = null;
     m_colorRight = null;
     m_colorBorder = null;
 }
Exemple #4
0
 private double PointsToMap(ESRI.ArcGIS.Geometry.ITransformation displayTransform, double dPointSize)
 {
     double tempPointsToMap = 0;
     ESRI.ArcGIS.Display.IDisplayTransformation tempTransform = null;
     if (displayTransform == null)
         tempPointsToMap = dPointSize * m_dDeviceRatio;
     else
     {
         tempTransform = (IDisplayTransformation)displayTransform;
         tempPointsToMap = tempTransform.FromPoints(dPointSize);
     }
     return tempPointsToMap;
 }
Exemple #5
0
        protected override void OnMouseDown(MouseEventArgs arg)
        {
            IMap   map;
            IPoint clickedPoint = dockableDEMWindow.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);

            map = dockableDEMWindow.ActiveMap;

            IActiveView activeView = (IActiveView)map;
            IRubberBand rubberEnv  = new RubberEnvelopeClass();
            IGeometry   geom       = rubberEnv.TrackNew(activeView.ScreenDisplay, null);
            IArea       area       = (IArea)geom;

            //Extra logic to cater for the situation where the user simply clicks a point on the map
            //or where envelope is so small area is zero
            if ((geom.IsEmpty == true) || (area.Area == 0))
            {
                //create a new envelope
                IEnvelope tempEnv = new EnvelopeClass();

                //create a small rectangle
                ESRI.ArcGIS.esriSystem.tagRECT RECT = new tagRECT();
                RECT.bottom = 0;
                RECT.left   = 0;
                RECT.right  = 5;
                RECT.top    = 5;

                //transform rectangle into map units and apply to the tempEnv envelope
                ESRI.ArcGIS.Display.IDisplayTransformation dispTrans = activeView.ScreenDisplay.DisplayTransformation;
                dispTrans.TransformRect(tempEnv, ref RECT, 4); //4 = esriDisplayTransformationEnum.esriTransformToMap)
                tempEnv.CenterAt(clickedPoint);
                geom = (IGeometry)tempEnv;
            }

            //Set the spatial reference of the search geometry to that of the Map
            ISpatialReference spatialReference = map.SpatialReference;

            geom.SpatialReference = spatialReference;

            dockableDEMWindow.SelectTilesByArea(geom);

            //map.SelectByShape(geom, null, false);
            //activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, activeView.Extent);

            if (arg.Button == System.Windows.Forms.MouseButtons.Left)
            {
                dockableDEMWindow?.ArcMap_OnMouseDown(arg.X, arg.Y);
            }
        }
Exemple #6
0
        private void QueryBoundsFromGeom(int hDC, ref ESRI.ArcGIS.Display.IDisplayTransformation transform, ref ESRI.ArcGIS.Geometry.IPolygon boundary, ref ESRI.ArcGIS.Geometry.IPoint point)
        {
            // Calculate Size, XOffset and YOffset of the shape in Map units.
            double dMapXOffset = 0;
            double dMapSize = 0;
            double dMapYOffset = 0;

            dMapSize = PointsToMap(transform, m_dSize);
            if (m_dXOffset != 0)
                dMapXOffset = PointsToMap(transform, m_dXOffset);
            if (m_dYOffset != 0)
                dMapYOffset = PointsToMap(transform, m_dYOffset);
            point.PutCoords(point.X + dMapXOffset, point.Y + dMapYOffset);

            // Set up the device ratio.
            SetupDeviceRatio(hDC, transform);

            ESRI.ArcGIS.Geometry.IPointCollection ptColl = null;
            ESRI.ArcGIS.Geometry.ISegmentCollection segColl = null;
            double dVal = 0; // dVal is the measurement of the short side of a Triangles are based on.
            double dRad = 0;
            ptColl = (IPointCollection)boundary;
            segColl = (ISegmentCollection)boundary;
            dRad = dMapSize / 2;
            dVal = System.Math.Sqrt((dRad * dRad) / 2);
            object missing = System.Reflection.Missing.Value;
            ptColl.AddPoint(Utility.CreatePoint(point.X + dVal, point.Y - dVal), ref missing, ref missing);
            ptColl.AddPoint(Utility.CreatePoint(point.X - dVal, point.Y - dVal), ref missing, ref missing);
            ptColl.AddPoint(Utility.CreatePoint(point.X - dVal, point.Y + dVal), ref missing, ref missing);

            IPoint p = ptColl.get_Point(0);
            segColl.AddSegment((ISegment)Utility.CreateCircArc(point, ptColl.get_Point(2), ref p), ref missing, ref missing);

            //  Account for rotation also.
            ESRI.ArcGIS.Geometry.ITransform2D trans2D = null;
            if ((m_dAngle + m_dMapRotation) != 0)
            {
                trans2D = boundary as ITransform2D;
                trans2D.Rotate(point, Utility.Radians(m_dAngle + m_dMapRotation));
            }
        }
Exemple #7
0
        private void InitializeMembers()
        {
            // Set up default values as far as possible.
            m_lhDC = 0;
            m_lOldPen = 0;
            m_lPen = 0;
            m_lOldBrush = 0;
            m_lBrushTop = 0;
            m_lBrushLeft = 0;
            m_lBrushRight = 0;
            m_dDeviceRadius = 0;

            m_trans = null;

            //  LogoMarkerSymbol custom property defaults.
            IColor color = null;

            color = (IColor)ESRI.ArcGIS.ADF.Converter.ToRGBColor(Color.Red);
            m_colorTop = ((IClone)color).Clone() as IColor;
            color = (IColor)ESRI.ArcGIS.ADF.Converter.ToRGBColor(Color.OrangeRed);
            m_colorLeft = ((IClone)color).Clone() as IColor;
            color = (IColor)ESRI.ArcGIS.ADF.Converter.ToRGBColor(Color.Pink);
            m_colorRight = ((IClone)color).Clone() as IColor;
            color = (IColor)ESRI.ArcGIS.ADF.Converter.ToRGBColor(Color.Black);
            m_colorBorder = ((IClone)color).Clone() as IColor;

            //  ISymbol property defaults.
            m_lROP2 = esriRasterOpCode.esriROPCopyPen;

            //  IMarkerSymbol property defaults.
            m_dSize = 10;
            m_dAngle = 0;
            m_dXOffset = 0;
            m_dYOffset = 0;

            //  ISymbolRotation property defaults.
            m_bRotWithTrans = true;

        }
Exemple #8
0
        //绘制线操作
        public void DrawLine(IActiveView activeView, IPoint fromP, IPoint toP)
        {
            if (activeView == null)
            {
                return;
            }
            IPolyline polyline = new PolylineClass();

            polyline.FromPoint = fromP;
            polyline.ToPoint   = toP;
            ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;
            screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache);
            ILineSymbol lineSymbol = new SimpleLineSymbolClass();

            lineSymbol.Color = blackColor;
            lineSymbol.Width = 1;
            ESRI.ArcGIS.Display.ISymbol symbol = lineSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic cast.
            screenDisplay.SetSymbol(symbol);
            ESRI.ArcGIS.Display.IDisplayTransformation displayTransformation = screenDisplay.DisplayTransformation;
            IGeometry pGeo = polyline;

            screenDisplay.DrawPolyline(pGeo);
            screenDisplay.FinishDrawing();
        }
Exemple #9
0
        public void DrawPoint(ESRI.ArcGIS.Carto.IActiveView activeView, System.Int32 x, System.Int32 y)
        {
            if (activeView == null)
            {
                return;
            }
            ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;


            // Constant
            screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast
            ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass();

            ESRI.ArcGIS.Display.ISymbol symbol = simpleMarkerSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic Cast
            screenDisplay.SetSymbol(symbol);
            ESRI.ArcGIS.Display.IDisplayTransformation displayTransformation = screenDisplay.DisplayTransformation;

            // x and y are in device coordinates
            ESRI.ArcGIS.Geometry.IPoint point = displayTransformation.ToMapPoint(x, y);


            screenDisplay.DrawPoint(point);
            screenDisplay.FinishDrawing();
        }
 private void Terminate()
 {
     //  Which variables do we really need to dereference here, just the transformation,
     //  or any other globals as well??
     m_trans = null;
     m_colorTop = null;
     m_colorLeft = null;
     m_colorRight = null;
     m_colorBorder = null;
 }
        private void InitializeMembers()
        {
            // Set up default values as far as possible.
            m_lhDC = 0;
            m_lOldPen = 0;
            m_lPen = 0;
            m_lOldBrush = 0;
            m_lBrushTop = 0;
            m_lBrushLeft = 0;
            m_lBrushRight = 0;
            m_dDeviceRadius = 0;

            m_trans = null;

            //  LogoMarkerSymbol custom property defaults.
            IColor color = null;

            color = (IColor)ESRI.ArcGIS.ADF.Converter.ToRGBColor(Color.Red);
            m_colorTop = ((IClone)color).Clone() as IColor;
            color = (IColor)ESRI.ArcGIS.ADF.Converter.ToRGBColor(Color.OrangeRed);
            m_colorLeft = ((IClone)color).Clone() as IColor;
            color = (IColor)ESRI.ArcGIS.ADF.Converter.ToRGBColor(Color.Pink);
            m_colorRight = ((IClone)color).Clone() as IColor;
            color = (IColor)ESRI.ArcGIS.ADF.Converter.ToRGBColor(Color.Black);
            m_colorBorder = ((IClone)color).Clone() as IColor;

            //  ISymbol property defaults.
            m_lROP2 = esriRasterOpCode.esriROPCopyPen;

            //  IMarkerSymbol property defaults.
            m_dSize = 10;
            m_dAngle = 0;
            m_dXOffset = 0;
            m_dYOffset = 0;

            //  ISymbolRotation property defaults.
            m_bRotWithTrans = true;
        }