ArcGIS Pro SDK (七)编辑 2 启用编辑
目录
- ArcGIS Pro SDK (七)编辑 2 启用编辑
- 1 启用编辑
- 2 禁用编辑
环境:Visual Studio 2022 + .NET6 + ArcGIS Pro SDK 3.0
1 启用编辑
// 如果没有正在编辑
if (!Project.Current.IsEditingEnabled)
{var res = MessageBox.Show("You must enable editing to use editing tools. Would you like to enable editing?","Enable Editing?", System.Windows.MessageBoxButton.YesNoCancel);if (res == System.Windows.MessageBoxResult.No ||res == System.Windows.MessageBoxResult.Cancel){return;}Project.Current.SetIsEditingEnabledAsync(true);
}
2 禁用编辑
// 如果正在编辑
if (Project.Current.IsEditingEnabled)
{var res = MessageBox.Show("Do you want to disable editing? Editing tools will be disabled","Disable Editing?", System.Windows.MessageBoxButton.YesNoCancel);if (res == System.Windows.MessageBoxResult.No ||res == System.Windows.MessageBoxResult.Cancel){return;}//必须检查编辑if (Project.Current.HasEdits){res = MessageBox.Show("Save edits?", "Save Edits?", System.Windows.MessageBoxButton.YesNoCancel);if (res == System.Windows.MessageBoxResult.Cancel){return;}else if (res == System.Windows.MessageBoxResult.No){Project.Current.DiscardEditsAsync();}else{Project.Current.SaveEditsAsync();}}Project.Current.SetIsEditingEnabledAsync(false);
}