Arcgis Engine9.2 Undo 和 Redo 功能实现
/// <summary>
/// 撒消编辑
/// </summary>
/// <param name="m_pMap">IMap 地图对象</param>
public void MapUndoEdit(IMap m_pMap)
{
IEngineEditProperties ep = new EngineEditorClass();
ILayer m_pCurrentLayer = ep.TargetLayer;
if (m_pCurrentLayer == null) return;
IFeatureLayer pFeatureLayer = (IFeatureLayer)m_pCurrentLayer;
IDataset pDataset = (IDataset)pFeatureLayer.FeatureClass;
if (pDataset == null) return;
IWorkspaceEdit pWorkspaceEdit = (IWorkspaceEdit)pDataset.Workspace;
bool bHasUndos = false;
pWorkspaceEdit.HasUndos(ref bHasUndos);
if (bHasUndos)
pWorkspaceEdit.UndoEditOperation();
IActiveView pActiveView = (IActiveView)m_pMap;
pActiveView.Refresh();
}
/// <summary>
/// 重做
/// </summary>
/// <param name="m_pMap">IMap 地图对象</param>
public void MapRedoEdit(IMap m_pMap)
{
IEngineEditProperties ep = new EngineEditorClass();
ILayer m_pCurrentLayer = ep.TargetLayer;
if (m_pCurrentLayer == null) return;
IFeatureLayer pFeatureLayer = (IFeatureLayer)m_pCurrentLayer;
IDataset pDataset = (IDataset)pFeatureLayer.FeatureClass;
if (pDataset == null) return;
IWorkspaceEdit pWorkspaceEdit = (IWorkspaceEdit)pDataset.Workspace;
bool bHasUndos = false;
pWorkspaceEdit.HasUndos(ref bHasUndos);
if (bHasUndos)
pWorkspaceEdit.RedoEditOperation();
IActiveView pActiveView = (IActiveView)m_pMap;
pActiveView.Refresh();
}