public IGeometry EndFeatureMove(int x, int y)
        {
            if (MyfeedBack == null)
            {
                return(null);
            }
            IGeometry geometry = null;

            try
            {
                if ((MyfeedBack as IMovePointFeedback) != null)
                {
                    IMovePointFeedback pointMoveFeedback = MyfeedBack as IMovePointFeedback;
                    geometry = pointMoveFeedback.Stop();
                }
                else if ((MyfeedBack as IMoveLineFeedback) != null)
                {
                    IMoveLineFeedback lineMoveFeedback = MyfeedBack as IMoveLineFeedback;
                    geometry = lineMoveFeedback.Stop();
                }
                else if ((MyfeedBack as IMovePolygonFeedback) != null)
                {
                    IMovePolygonFeedback polygonMoveFeedback = MyfeedBack as IMovePolygonFeedback;
                    geometry = polygonMoveFeedback.Stop();
                }
            }
            catch { return(null); }
            MyfeedBack = null;
            return(geometry);
        }
Esempio n. 2
0
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ModifyShape.OnMouseUp implementation
            if (m_Feedback == null)
            {
                return;
            }
            IActiveView pActiveView = m_MapControl.ActiveView;
            IPoint      pPoint      = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            if (m_Feedback is IMovePointFeedback)
            {
                IMovePointFeedback pPointMove = (IMovePointFeedback)m_Feedback;
                IGeometry          pGeometry  = pPointMove.Stop();
                UpdateFeature(m_EditFeature, pGeometry);
            }
            else if (m_Feedback is IMoveLineFeedback) //线 对象移动
            {
                IMoveLineFeedback pLineMove = (IMoveLineFeedback)m_Feedback;
                IGeometry         pGeometry = pLineMove.Stop();
                UpdateFeature(m_EditFeature, pGeometry);
            }
            else if (m_Feedback is IMovePolygonFeedback)
            {
                IMovePolygonFeedback pPolygonMove = (IMovePolygonFeedback)m_Feedback;
                IGeometry            pGeometry    = pPolygonMove.Stop();
                UpdateFeature(m_EditFeature, pGeometry);
            }

            m_Feedback = null;
            pActiveView.Refresh();
        }
        public IGeometry EndFeatureEdit(int x, int y)
        {
            if (MyfeedBack == null)
            {
                return(null);
            }

            IGeometry geometry = null;
            IPoint    point    = MyMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);

            if ((MyfeedBack as IMovePointFeedback) != null)
            {
                IMovePointFeedback pointMove = MyfeedBack as IMovePointFeedback;
                geometry = pointMove.Stop() as IGeometry;
            }
            else if ((MyfeedBack as ILineMovePointFeedback) != null)
            {
                ILineMovePointFeedback lineMove = MyfeedBack as ILineMovePointFeedback;
                geometry = lineMove.Stop() as IGeometry;
            }
            else if ((MyfeedBack as IPolygonMovePointFeedback) != null)
            {
                IPolygonMovePointFeedback polyMove = MyfeedBack as IPolygonMovePointFeedback;
                geometry = polyMove.Stop() as IGeometry;
            }
            MyfeedBack = null;
            MyMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, MyselectedLayer, null);
            return(geometry);
        }
Esempio n. 4
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolModefyTINNode.OnMouseDown implementation
            ITin     pTin     = pTinLayer.Dataset;
            ITinEdit pTinEdit = pTin as ITinEdit;

            frmModifyNode.m_pTinEdit = pTinEdit;
            frmModifyNode.m_pTinNode = pNode;
            frmModifyNode.setDoubleInputValue(pNode.Z);
            frmModifyNode.setBttonEnable(true);
            IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;

            frmModifyNode.m_pMapCtr = pMapCtr;
            pMovePtFeedBack.Stop();
            //IPoint pt = new PointClass();
            //pMovePtFeedBack.Start(pt, pt);
        }
Esempio n. 5
0
        //移动元素到新的位置
        public void ElementMoveTo(IPoint point)
        {
            //移动元素
            m_movePointFeedback.MoveTo(point);
            IGeometry p_geometry = null;

            if (m_element_snap != null)
            {
                p_geometry = m_movePointFeedback.Stop();
                m_element_snap.Geometry = p_geometry;
                //更新该元素的位置
                axMapControl1.ActiveView.GraphicsContainer.UpdateElement(m_element_snap);
                //重新移动元素
                m_movePointFeedback.Stop();
                //刷新视图
                axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
            }
        }
Esempio n. 6
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolDeleteTINNode.OnMouseDown implementation
            ITin     pTin     = pTinLayer.Dataset;
            ITinEdit pTinEdit = pTin as ITinEdit;

            pTinEdit.DeleteNode(pNode.Index);
            IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;

            if (pMapCtr != null)
            {
                pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            }
            pMovePtFeedBack.Stop();
            IPoint pt = new PointClass();

            pMovePtFeedBack.Start(pt, pt);
        }
Esempio n. 7
0
        //移动元素到新的位置
        public void ElementMoveTo(IPoint point)
        {
            //移动元素
            movePointFeedback.MoveTo(point);
            IGeometry geometry1 = null;
            IGeometry geometry2 = null;

            if (m_element != null)
            {
                geometry1          = m_element.Geometry;
                geometry2          = movePointFeedback.Stop();
                m_element.Geometry = geometry2;
                //更新该元素的位置
                this.axMapControl1.ActiveView.GraphicsContainer.UpdateElement(m_element);
                //重新移动元素
                movePointFeedback.Stop();//(geometry1 as IPoint, point);
                this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
            }
        }
Esempio n. 8
0
        private void axMapControl1_OnMouseUp(object sender, IMapControlEvents2_OnMouseUpEvent e)
        {
            if (m_Feature == null)
            {
                return;
            }
            IGeometry resultGeometry = null;

            switch (strOperator)
            {
            case "move":
                if (m_Feature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
                {
                    //停止移动
                    resultGeometry  = m_MovePointFeedback.Stop() as IGeometry;
                    m_Feature.Shape = resultGeometry;
                }
                else if (m_Feature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                {
                    //停止移动
                    resultGeometry  = m_MoveLineFeedback.Stop() as IGeometry;
                    m_Feature.Shape = resultGeometry;
                }
                else if (m_Feature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
                {
                    //停止移动
                    resultGeometry  = m_MovePolygonFeedback.Stop() as IGeometry;
                    m_Feature.Shape = resultGeometry;
                }
                IWorkspaceEdit workspaceEdit;
                IWorkspace     workspace;
                IDataset       dataset = m_FeatureLayer.FeatureClass as IDataset;
                workspace     = dataset.Workspace;
                workspaceEdit = workspace as IWorkspaceEdit;
                //开始编辑
                workspaceEdit.StartEditing(true);
                workspaceEdit.StartEditOperation();
                //保存实体
                m_Feature.Store();
                //结束编辑
                workspaceEdit.StopEditOperation();
                workspaceEdit.StopEditing(true);
                m_MovePointFeedback   = null;
                m_MoveLineFeedback    = null;
                m_MovePolygonFeedback = null;
                break;
            }
            m_activeView.Refresh();
            this.axMapControl1.Map.ClearSelection();
        }
Esempio n. 9
0
        /// <summary>
        /// 完成地图对象编辑,取得编辑后的对象,并将其更新到图层中
        /// 建议在Map.MouseUp事件中调用本方法
        /// </summary>
        public void EditFeatureEnd()
        {
            IGeometry pGeometry;

            try
            {
                if (m_pFeedback == null)
                {
                    return;
                }

                if (m_pFeedback is IMovePointFeedback)
                {
                    IMovePointFeedback pPointMove = (IMovePointFeedback)m_pFeedback;
                    pGeometry = pPointMove.Stop();
                    UpdateFeature(m_pEditFeature, pGeometry);
                }
                else if (m_pFeedback is ILineMovePointFeedback)
                {
                    ILineMovePointFeedback pLineMove = (ILineMovePointFeedback)m_pFeedback;
                    pGeometry = pLineMove.Stop();
                    UpdateFeature(m_pEditFeature, pGeometry);
                }
                else if (m_pFeedback is IPolygonMovePointFeedback)
                {
                    IPolygonMovePointFeedback pPolyMove = (IPolygonMovePointFeedback)m_pFeedback;
                    pGeometry = pPolyMove.Stop();
                    UpdateFeature(m_pEditFeature, pGeometry);
                }

                m_pFeedback = null;
//				m_pSelectionTracker = null;
                IActiveView pActiveView = (IActiveView)m_pMap;
                pActiveView.Refresh();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
            }
        }
Esempio n. 10
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            try
            {
                pt = ((m_hookHelper.ActiveView.ScreenDisplay).DisplayTransformation).ToMapPoint(X, Y);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            bool ddd = snapEnvironment.SnapPoint(pt);

            if (pMPfeedback != null)
            {
                pMPfeedback.Stop();
            }
            pMPfeedback = null;

            bool hasCut         = false;
            ISet newFeaturesSet = null;

            try
            {
                IFeatureSelection featureSelection = m_editLayer.TargetLayer as IFeatureSelection;
                ISelectionSet     selectionSet     = featureSelection.SelectionSet;
                IEnumIDs          enumIDs          = selectionSet.IDs;
                int iD = enumIDs.Next();
                while (iD != -1) //-1 is reutned after the last valid ID has been reached
                {
                    m_engineEditor.StartOperation();
                    IFeatureClass featureClass = m_editLayer.TargetLayer.FeatureClass;
                    IFeature      feature      = featureClass.GetFeature(iD);
                    // 判断点是否在线上,不是则跳过
                    ITopologicalOperator pto       = feature.Shape as ITopologicalOperator;
                    IGeometry            pgeometry = pto.Intersect(pt, esriGeometryDimension.esriGeometry0Dimension);
                    if (pgeometry.IsEmpty == true)
                    {
                        iD = enumIDs.Next();
                        continue;
                    }
                    IFeatureEdit featureedit = feature as IFeatureEdit;
                    /*ISet*/
                    newFeaturesSet = featureedit.Split(pgeometry);
                    if (newFeaturesSet != null)
                    {
                        newFeaturesSet.Reset();
                        hasCut = true;
                        break;
                    }
                    iD = enumIDs.Next();
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            if (hasCut)
            {
                //如果操作成功,选中切割的两条线
                //IFeatureSelection featureSelection = m_editLayer.TargetLayer as IFeatureSelection;
                //ISelectionSet selectionSet = featureSelection.SelectionSet;
                //for (int i = 0; i < newFeaturesSet.Count; i++)
                //{
                //    selectionSet.Add(((IFeature)newFeaturesSet.Next()).OID);
                //}
                //selectionSet.Refresh();

                //Refresh the display including modified layer and any previously selected component.
                IActiveView activeView = m_engineEditor.Map as IActiveView;
                activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography | esriViewDrawPhase.esriViewGeoSelection, null, activeView.Extent);
                activeView.Refresh();
                //Complete the edit operation.
                m_engineEditor.StopOperation("Split a line");
                // 将当前工具设置为选择工具
                IToolbarControl toolbarctl = m_hookHelper.Hook as IToolbarControl;
                //ICommand com = new ControlsEditingEditToolClass();
                //com.OnCreate(m_mapControl.Object);
                //this.m_mapControl.CurrentTool = com as ITool;
                for (int i = 0; i < toolbarctl.Count; i++)
                {
                    IToolbarItem tbi = toolbarctl.GetItem(i);
                    if (tbi.Command != null && tbi.Command.Name.Equals("ControlToolsEditing_Edit"))
                    {
                        tbi.Command.OnClick();// = true;
                        toolbarctl.CurrentTool = tbi.Command as ITool;
                        IToolbarBuddy toolbarbuddy = (IToolbarBuddy)((IToolbarControl)m_hookHelper.Hook).Buddy;
                        break;
                    }
                }
                //  操作成功后将当前工具置为以前的工具
                //IToolbarBuddy toolbarbuddy = (IToolbarBuddy)((IToolbarControl)m_hookHelper.Hook).Buddy;
                //toolbarbuddy.CurrentTool = oldtool;
                //((IToolbarControl)m_hookHelper.Hook).SetBuddyControl(toolbarbuddy);
                this.Deactivate();
            }
            else
            {
                m_engineEditor.AbortOperation();
                MessageBox.Show("切割点不在线上,未能成功切割选择的线段");
                //重新开始选点
                this.OnClick();
            }
            base.OnMouseDown(Button, Shift, X, Y);
        }