Esempio n. 1
0
 public override void OnMouseDown(int Button, int Shift, int X, int Y)
 {
     try
     {
         ClsMarkDraw.DeleteAllElementsWithName(m_hookHelper.FocusMap, sPolyOutlineName);
         ESRI.ArcGIS.Geometry.IPoint pMapPoint = new ESRI.ArcGIS.Geometry.PointClass();
         m_hookHelper.FocusMap.SpatialReference = m_psurface.Domain.SpatialReference;
         pMapPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
         if (pMapPoint == null)
         {
             return;
         }
         pMapPoint.Project(m_psurface.Domain.SpatialReference);
         pMapPoint.Z = m_psurface.GetElevation(pMapPoint);
         IGroupElement pGroup = null;
         ClsMarkDraw.AddSimpleGraphic(pMapPoint, ClsMarkDraw.getRGB(71, 61, 255), 3, sPolyOutlineName, m_hookHelper.FocusMap, pGroup);
         m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
         m_Geometry = pMapPoint;
         EndDtrawd(true);
     }
     catch
     {
         return;
     }
 }
Esempio n. 2
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            try
            {
                ESRI.ArcGIS.Geometry.IPoint pMapPoint = new ESRI.ArcGIS.Geometry.PointClass();;
                object before   = Type.Missing;
                object after    = Type.Missing;
                object StepSize = Type.Missing;
                m_hookHelper.FocusMap.SpatialReference = m_psurface.Domain.SpatialReference;
                pMapPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                if (pMapPoint == null)
                {
                    return;
                }
                pMapPoint.Project(m_psurface.Domain.SpatialReference);
                pMapPoint.Z = m_psurface.GetElevation(pMapPoint);

                //pMapPoint.SpatialReference = m_hookHelper.FocusMap.SpatialReference;
                //pDisplay = m_sceneHookHelper.SceneGraph as IDisplay3D;
                //pDisplay.FlashLocation(pMapPoint);//闪烁显示被点击的位置

                IGeometry pGeom = null;
                ClsMarkDraw.DeleteAllElementsWithName(m_hookHelper.FocusMap, sPolyOutlineName);
                //根据绘制对象类型的不同定义不同的类型
                switch (m_DrawType.ToString())
                {
                case "esriGeometryPoint":
                    m_Geometry = pMapPoint;
                    break;

                case "esriGeometryLine":
                    if (m_pPointColl == null)
                    {
                        m_pPointColl = new PolylineClass();
                        pGeom        = new PolylineClass();
                    }
                    m_pPointColl.AddPoint(pMapPoint, ref before, ref after);
                    break;

                case "esriGeometryPolygon":
                    if (m_pPointColl == null)
                    {
                        m_pPointColl = new PolygonClass();
                        pGeom        = new PolygonClass();
                    }
                    m_pPointColl.AddPoint(pMapPoint, ref before, ref after);
                    break;
                }

                //BeginDrawed(true);

                IGroupElement pGroup = null;
                if (m_pPointColl.PointCount == 1)
                {
                    //当为一个点时绘制点
                    ClsMarkDraw.AddSimpleGraphic(pMapPoint, ClsMarkDraw.getRGB(71, 61, 255), 3, sPolyOutlineName, m_hookHelper.FocusMap, pGroup);
                }
                else if (m_DrawType.ToString() == "esriGeometryLine")
                {
                    pGeom = m_pPointColl as IGeometry;
                    pGeom.SpatialReference = pMapPoint.SpatialReference;
                    m_psurface.InterpolateShape(pGeom, out pGeom, ref StepSize);
                    ClsMarkDraw.AddSimpleGraphic(pGeom, ClsMarkDraw.getRGB(71, 61, 255), 2, sPolyOutlineName, m_hookHelper.FocusMap, pGroup);
                    m_pPointColl = pGeom as IPointCollection;
                }
                else
                {
                    ITopologicalOperator pTopo = m_pPointColl as ITopologicalOperator;
                    pGeom = pTopo.Boundary;
                    pGeom.SpatialReference = pMapPoint.SpatialReference;
                    m_psurface.InterpolateShape(pGeom, out pGeom, ref StepSize);
                    ClsMarkDraw.AddSimpleGraphic(pGeom, ClsMarkDraw.getRGB(71, 61, 255), 2, sPolyOutlineName, m_hookHelper.FocusMap, pGroup);
                }

                m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            }
            catch
            {
                return;
            }
        }