码迷,mamicode.com
首页 > 其他好文 > 详细

ArcEngine要素编辑遇到的一些问题

时间:2021-03-02 12:00:02      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:redo   onchange   count   app   ==   change   tin   如何   停止   

1、如何开启编辑

IMap myMap = this._Aplication.ActiveView.FocusMap;
IWorkspace myWorkspace = (myMap25Sheet.PointFeatureLayer as IDataset).Workspace;
this._Aplication.EngineEditor.EnableUndoRedo(true);
this._Aplication.EngineEditor.StartEditing(myWorkspace, myMap);
this._Aplication.EngineEditor.StartOperation();

2、如何设置要编辑的目标图层
IEngineEditLayers myEngineEditLayers = this._Aplication.EngineEditor as IEngineEditLayers;
myEngineEditLayers.SetTargetLayer(myMap25Sheet.PointFeatureLayer, 0);

 

3、编辑的不符合规则,如何回退

IWorkspaceEdit myWorkspaceEdit = this._Application.EngineEditor.EditWorkspace as IWorkspaceEdit;
bool myHasUndo = false;
myWorkspaceEdit.HasUndos(ref myHasUndo);
if (myHasUndo == true)
{
IMap myMap = this._Application.ActiveView.FocusMap;
((IActiveView)myMap).PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
myMap.ClearSelection();
((IActiveView)myMap).PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
myWorkspaceEdit.UndoEditOperation();
this._Application.ActiveView.Refresh();
}

注意,一定要调用清空选择那块的代码,不然回退后,刷新下地图,又会重新回来,发现这个问题花了好长时间。

 

4、如何控制只能选择和编辑一个要素

private void EngineEditor_OnSelectionChanged()
        {
            Map25Sheet myMap25Sheet = this._Application.WorkZone.ActiveMap25Sheet;
            if (myMap25Sheet == null)
            {
                this._Application.SamplePointInfoUI.SetPointFeature(null);
                return;
            }
            IFeatureLayer myFeatureLayer = myMap25Sheet.PointFeatureLayer;
            IFeatureSelection myFeatureSelection = myMap25Sheet.PointFeatureLayer as IFeatureSelection;
            if (myFeatureSelection.SelectionSet.Count == 0)
            {
                this._Application.SamplePointInfoUI.SetPointFeature(null);
                return;
            }
            int myID = myFeatureSelection.SelectionSet.IDs.Next();
            if (myFeatureSelection.SelectionSet.Count > 1)
            {
                myFeatureSelection.Clear();
                myFeatureSelection.SelectionSet.Add(myID);
            }
            this._Application.SamplePointInfoUI.SetPointFeature(myFeatureLayer.FeatureClass.GetFeature(myID));
            this._Application.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
        }
EngineEditor的OnSelectionChanged事件,在这控制下即可。

 5、如何只编辑一个图层

控制其他图层不能不能被选择即可。

myFeatureLayer.Selectable = false;

 

6、ArcEngine中没有保存函数,如何保存编辑

先停止编辑,调用停止的时候,把是否保存参数设置为true,然后再重新开启即可。

 

ArcEngine要素编辑遇到的一些问题

标签:redo   onchange   count   app   ==   change   tin   如何   停止   

原文地址:https://www.cnblogs.com/mytudousi/p/14462940.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!