コード例 #1
0
 public void OnMouseDown(int button, int shift, int x, int y)
 {
     try
     {
         //转换鼠标点击位置起始点为地图坐标
         m_startPt = m_activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
         if (m_EngineEditor == null)
         {
             return;
         }
         if (m_EngineEditor.EditState != esriEngineEditState.esriEngineStateEditing)
         {
             return;
         }
         if (m_EngineEditLayers == null)
         {
             return;
         }
         IFeatureLayer pFeatLyr = m_EngineEditLayers.TargetLayer;
         if (pFeatLyr == null)
         {
             return;
         }
         //获取要移动几何对象
         IFeatureCursor pFeatCur = MapManager.GetSelectedFeatures(pFeatLyr);
         if (pFeatCur == null)
         {
             MessageBox.Show("请选择要移动要素!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
         IFeature pFeature = pFeatCur.NextFeature();
         //当移动的对象为空时,首先进行对象实例化
         if (m_moveGeoFeedBack == null)
         {
             m_moveGeoFeedBack = new MoveGeometryFeedbackClass();
         }
         m_moveGeoFeedBack.Display = m_activeView.ScreenDisplay;
         while (pFeature != null)
         {
             m_moveGeoFeedBack.AddGeometry(pFeature.Shape);
             pFeature = pFeatCur.NextFeature();
         }
         //添加起始点
         m_moveGeoFeedBack.Start(m_startPt);
         System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatCur);
     }
     catch (Exception ex)
     {
         //SysLogHelper.WriteOperationLog("要素移动错误", ex.Source, "数据编辑");
     }
 }
コード例 #2
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1 || m_MapControl.Map.SelectionCount == 0)
            {
                return;
            }
            MoData.v_bVertexSelectionTracker = false;

            m_pNewLineFeedback      = new NewLineFeedbackClass();
            m_pMoveGeometryFeedback = new MoveGeometryFeedbackClass();
            IDisplayFeedback pDisplayFeedback = m_pMoveGeometryFeedback as IDisplayFeedback;

            pDisplayFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay;

            m_pPtStart = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            m_pNewLineFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay;
            m_pNewLineFeedback.Start(m_pPtStart);

            //只刷新选中的地物
            IEnumFeature pEnumFeature = m_MapControl.Map.FeatureSelection as IEnumFeature;
            IInvalidArea pInvalidArea = new InvalidAreaClass();

            pInvalidArea.Display = m_hookHelper.ActiveView.ScreenDisplay;
            pInvalidArea.Add(pEnumFeature);

            pEnumFeature.Reset();
            IFeature pFeature = pEnumFeature.Next();

            m_pMoveSet = new SetClass();
            while (pFeature != null)
            {
                //'判断选中的要素是否启动了编辑
                IFeatureClass  pFeatureClass = pFeature.Class as IFeatureClass;
                IDataset       pDataset      = pFeatureClass as IDataset;
                IWorkspaceEdit pWSEdit       = pDataset.Workspace as IWorkspaceEdit;
                if (pWSEdit != null)
                {
                    if (pWSEdit.IsBeingEdited())
                    {
                        m_pMoveGeometryFeedback.AddGeometry(pFeature.Shape);
                        m_pMoveSet.Add(pFeature);
                    }
                }
                pFeature = pEnumFeature.Next();
            }

            m_pMoveGeometryFeedback.Start(m_pPtStart);

            m_bMouseDown = true;
        }
コード例 #3
0
 public void Add(IFeature ifeature_0)
 {
     if (!(ifeature_0 is INetworkFeature))
     {
         if (this.imoveGeometryFeedback_0 == null)
         {
             this.imoveGeometryFeedback_0 = new MoveGeometryFeedback()
             {
                 Display = this.iscreenDisplay_0
             };
         }
         this.imoveGeometryFeedback_0.AddGeometry(ifeature_0.Shape);
     }
     else
     {
         this.iset_0.Add(ifeature_0);
     }
 }
コード例 #4
0
 public void OnMouseUp(int button, int shift, int x, int y)
 {
     try
     {
         m_EndPoint = m_activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
         if (m_moveGeoFeedBack == null)
         {
             return;
         }
         m_moveGeoFeedBack.MoveTo(m_EndPoint);
         MoveFeatures(m_EndPoint, m_startPt);
         m_moveGeoFeedBack.ClearGeometry();
         m_moveGeoFeedBack = null;
     }
     catch (Exception ex)
     {
         throw;
     }
 }
コード例 #5
0
 public void OnMouseUp(int button, int shift, int x, int y)
 {
     try
     {
         m_EndPoint = m_activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
         if (m_moveGeoFeedBack == null)
         {
             return;
         }
         m_moveGeoFeedBack.MoveTo(m_EndPoint);
         MoveFeatures(m_EndPoint, m_startPt);
         m_moveGeoFeedBack.ClearGeometry();
         m_moveGeoFeedBack = null;
     }
     catch (Exception ex)
     {
         //SysLogHelper.WriteOperationLog("移动要素错误", ex.Source, "数据编辑");
     }
 }
コード例 #6
0
        private void method_1(IEdgeFeature iedgeFeature_0)
        {
            int                    edgeFeatureCount;
            int                    i;
            IEdgeFeature           edgeFeature;
            IPoint                 shape;
            ILineMovePointFeedback lineMovePointFeedbackClass;
            IHitTest               hitTest;
            IPoint                 pointClass;
            double                 num;
            int                    num1;
            int                    num2;
            bool                   flag;
            int                    pointCount;
            int                    j;
            IPath                  geometry;

            if (!(iedgeFeature_0 is IComplexEdgeFeature))
            {
                int       oID       = (iedgeFeature_0 as IFeature).OID;
                IGeometry shapeCopy = (iedgeFeature_0 as IFeature).ShapeCopy;
                if (this.imoveGeometryFeedback_0 == null)
                {
                    this.imoveGeometryFeedback_0 = new MoveGeometryFeedback()
                    {
                        Display = this.iscreenDisplay_0
                    };
                }
                this.imoveGeometryFeedback_0.AddGeometry(shapeCopy);
                int fromJunctionEID = iedgeFeature_0.FromJunctionEID;
                IJunctionFeature fromJunctionFeature = iedgeFeature_0.FromJunctionFeature;
                if (fromJunctionFeature is ISimpleJunctionFeature)
                {
                    edgeFeatureCount = (fromJunctionFeature as ISimpleJunctionFeature).EdgeFeatureCount;
                    for (i = 0; i < edgeFeatureCount; i++)
                    {
                        edgeFeature = (fromJunctionFeature as ISimpleJunctionFeature).EdgeFeature[i];
                        if ((edgeFeature as IFeature).OID != oID && !this.iset_0.Find(edgeFeature) &&
                            !this.iset_1.Find(edgeFeature))
                        {
                            this.iset_1.Add(edgeFeature);
                            shapeCopy = (edgeFeature as IFeature).Shape;
                            if (!(edgeFeature is ISimpleEdgeFeature))
                            {
                                shape      = (fromJunctionFeature as IFeature).Shape as IPoint;
                                hitTest    = shapeCopy as IHitTest;
                                pointClass = new ESRI.ArcGIS.Geometry.Point();
                                num        = 0;
                                num1       = -1;
                                num2       = -1;
                                flag       = false;
                                if (hitTest.HitTest(shape, 0, esriGeometryHitPartType.esriGeometryPartVertex, pointClass,
                                                    ref num, ref num1, ref num2, ref flag))
                                {
                                    lineMovePointFeedbackClass = new LineMovePointFeedback()
                                    {
                                        Display = this.iscreenDisplay_0
                                    };
                                    pointCount = 0;
                                    for (j = 0; j < num1; j++)
                                    {
                                        geometry   = (IPath)((IGeometryCollection)hitTest).Geometry[j];
                                        pointCount = pointCount + (geometry as IPointCollection).PointCount;
                                    }
                                    num2 = num2 + pointCount;
                                    lineMovePointFeedbackClass.Start(hitTest as IPolyline, num2, shape);
                                    this.ilist_0.Add(lineMovePointFeedbackClass);
                                    this.ilist_1.Add(shape);
                                }
                            }
                            else
                            {
                                shape = null;
                                lineMovePointFeedbackClass = new LineMovePointFeedback()
                                {
                                    Display = this.iscreenDisplay_0
                                };
                                if (edgeFeature.FromJunctionEID != fromJunctionEID)
                                {
                                    shape =
                                        (shapeCopy as IPointCollection).Point[
                                            (shapeCopy as IPointCollection).PointCount - 1];
                                    lineMovePointFeedbackClass.Start(shapeCopy as IPolyline,
                                                                     (shapeCopy as IPointCollection).PointCount - 1, shape);
                                }
                                else
                                {
                                    shape = (shapeCopy as IPointCollection).Point[0];
                                    lineMovePointFeedbackClass.Start(shapeCopy as IPolyline, 0, shape);
                                }
                                this.ilist_0.Add(lineMovePointFeedbackClass);
                                this.ilist_1.Add(shape);
                            }
                        }
                    }
                }
                fromJunctionEID = iedgeFeature_0.ToJunctionEID;
                IJunctionFeature toJunctionFeature = iedgeFeature_0.ToJunctionFeature;
                if (toJunctionFeature is ISimpleJunctionFeature)
                {
                    edgeFeatureCount = (toJunctionFeature as ISimpleJunctionFeature).EdgeFeatureCount;
                    for (i = 0; i < edgeFeatureCount; i++)
                    {
                        edgeFeature = (toJunctionFeature as ISimpleJunctionFeature).EdgeFeature[i];
                        if ((edgeFeature as IFeature).OID != oID && !this.iset_0.Find(edgeFeature) &&
                            !this.iset_1.Find(edgeFeature))
                        {
                            this.iset_1.Add(edgeFeature);
                            shape = null;
                            lineMovePointFeedbackClass = new LineMovePointFeedback()
                            {
                                Display = this.iscreenDisplay_0
                            };
                            shapeCopy = (edgeFeature as IFeature).Shape;
                            if (!(edgeFeature is ISimpleEdgeFeature))
                            {
                                IPoint point = (toJunctionFeature as IFeature).Shape as IPoint;
                                hitTest    = shapeCopy as IHitTest;
                                pointClass = new ESRI.ArcGIS.Geometry.Point();
                                num        = 0;
                                num1       = -1;
                                num2       = -1;
                                flag       = false;
                                if (hitTest.HitTest(point, 0, esriGeometryHitPartType.esriGeometryPartVertex, pointClass,
                                                    ref num, ref num1, ref num2, ref flag))
                                {
                                    lineMovePointFeedbackClass = new LineMovePointFeedback()
                                    {
                                        Display = this.iscreenDisplay_0
                                    };
                                    pointCount = 0;
                                    for (j = 0; j < num1; j++)
                                    {
                                        geometry   = (IPath)((IGeometryCollection)hitTest).Geometry[j];
                                        pointCount = pointCount + (geometry as IPointCollection).PointCount;
                                    }
                                    num2 = num2 + pointCount;
                                    lineMovePointFeedbackClass.Start(hitTest as IPolyline, num2, point);
                                    this.ilist_0.Add(lineMovePointFeedbackClass);
                                    this.ilist_1.Add(point);
                                }
                            }
                            else
                            {
                                if (edgeFeature.FromJunctionEID != fromJunctionEID)
                                {
                                    shape =
                                        (shapeCopy as IPointCollection).Point[
                                            (shapeCopy as IPointCollection).PointCount - 1];
                                    lineMovePointFeedbackClass.Start(shapeCopy as IPolyline,
                                                                     (shapeCopy as IPointCollection).PointCount - 1, shape);
                                }
                                else
                                {
                                    shape = (shapeCopy as IPointCollection).Point[0];
                                    lineMovePointFeedbackClass.Start(shapeCopy as IPolyline, 0, shape);
                                }
                                this.ilist_0.Add(lineMovePointFeedbackClass);
                                this.ilist_1.Add(shape);
                            }
                        }
                    }
                }
            }
            else
            {
                this.method_2(iedgeFeature_0 as IComplexEdgeFeature);
            }
        }
コード例 #7
0
        private void method_2(IComplexEdgeFeature icomplexEdgeFeature_0)
        {
            ILineMovePointFeedback lineMovePointFeedbackClass;
            int       oID       = (icomplexEdgeFeature_0 as IFeature).OID;
            IGeometry shapeCopy = (icomplexEdgeFeature_0 as IFeature).ShapeCopy;

            if (this.imoveGeometryFeedback_0 == null)
            {
                this.imoveGeometryFeedback_0 = new MoveGeometryFeedback()
                {
                    Display = this.iscreenDisplay_0
                };
            }
            this.imoveGeometryFeedback_0.AddGeometry(shapeCopy);
            for (int i = 0; i < icomplexEdgeFeature_0.JunctionFeatureCount; i++)
            {
                IJunctionFeature junctionFeature = icomplexEdgeFeature_0.JunctionFeature[i];
                if (junctionFeature is ISimpleJunctionFeature)
                {
                    int    eID              = (junctionFeature as ISimpleJunctionFeature).EID;
                    IPoint point            = (junctionFeature as IFeature).ShapeCopy as IPoint;
                    int    edgeFeatureCount = (junctionFeature as ISimpleJunctionFeature).EdgeFeatureCount;
                    for (int j = 0; j < edgeFeatureCount; j++)
                    {
                        IEdgeFeature edgeFeature = (junctionFeature as ISimpleJunctionFeature).EdgeFeature[j];
                        if ((edgeFeature as IFeature).OID != oID && !this.iset_0.Find(edgeFeature) &&
                            !this.iset_1.Find(edgeFeature))
                        {
                            this.iset_1.Add(edgeFeature);
                            shapeCopy = (edgeFeature as IFeature).Shape;
                            IPoint point1 = null;
                            if (!(edgeFeature is ISimpleEdgeFeature))
                            {
                                IHitTest shape      = (edgeFeature as IFeature).Shape as IHitTest;
                                IPoint   pointClass = new ESRI.ArcGIS.Geometry.Point();
                                double   num        = 0;
                                int      num1       = -1;
                                int      num2       = -1;
                                bool     flag       = false;
                                if (shape.HitTest(point, 0, esriGeometryHitPartType.esriGeometryPartVertex, pointClass,
                                                  ref num, ref num1, ref num2, ref flag))
                                {
                                    lineMovePointFeedbackClass = new LineMovePointFeedback()
                                    {
                                        Display = this.iscreenDisplay_0
                                    };
                                    int pointCount = 0;
                                    for (int k = 0; k < num1; k++)
                                    {
                                        IPath geometry = (IPath)((IGeometryCollection)shape).Geometry[k];
                                        pointCount = pointCount + (geometry as IPointCollection).PointCount;
                                    }
                                    num2 = num2 + pointCount;
                                    lineMovePointFeedbackClass.Start(shape as IPolyline, num2, point);
                                    this.ilist_0.Add(lineMovePointFeedbackClass);
                                    this.ilist_1.Add(point);
                                }
                            }
                            else
                            {
                                lineMovePointFeedbackClass = new LineMovePointFeedback()
                                {
                                    Display = this.iscreenDisplay_0
                                };
                                if (edgeFeature.FromJunctionEID != eID)
                                {
                                    point1 =
                                        (shapeCopy as IPointCollection).Point[
                                            (shapeCopy as IPointCollection).PointCount - 1];
                                    lineMovePointFeedbackClass.Start(shapeCopy as IPolyline,
                                                                     (shapeCopy as IPointCollection).PointCount - 1, point1);
                                }
                                else
                                {
                                    point1 = (shapeCopy as IPointCollection).Point[0];
                                    lineMovePointFeedbackClass.Start(shapeCopy as IPolyline, 0, point1);
                                }
                                this.ilist_0.Add(lineMovePointFeedbackClass);
                                this.ilist_1.Add(point1);
                            }
                        }
                    }
                }
            }
        }