ArcGIS Pro SDK (七)编辑 2 启用编辑

ArcGIS Pro SDK (七)编辑 2 启用编辑

目录

  • [ArcGIS Pro SDK (七)编辑 2 启用编辑](#ArcGIS Pro SDK (七)编辑 2 启用编辑)
    • [1 启用编辑](#1 启用编辑)
    • [2 禁用编辑](#2 禁用编辑)

环境:Visual Studio 2022 + .NET6 + ArcGIS Pro SDK 3.0

1 启用编辑

csharp 复制代码
// 如果没有正在编辑
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 禁用编辑

csharp 复制代码
// 如果正在编辑
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);
}
相关推荐
我是唐青枫8 小时前
深入理解 C#.NET Interlocked.Increment:原子操作的核心
c#·.net
yue0088 小时前
C# 字符串倒序
开发语言·c#
ejjdhdjdjdjdjjsl10 小时前
C#类型转换与异常处理全解析
开发语言·c#
智航GIS11 小时前
ArcGIS大师之路500技---049状态栏的设置
arcgis
YAY_tyy11 小时前
Turfjs+Three.js:地理数据的三维建模应用
前端·javascript·3d·arcgis·turfjs
我是唐青枫12 小时前
深入理解 C#.NET Parallel:并行编程的正确打开方式
开发语言·c#·.net
yue00813 小时前
C# ASCII和字符串相互转换
c#
TypingLearn13 小时前
Perigon.CLI 10.0 重磅发布【AspNetCore开发模板和辅助工具】
c#·.net·aspnetcore
Sheep Shaun14 小时前
STL中的map和set:红黑树的优雅应用
开发语言·数据结构·c++·后端·c#
博主花神14 小时前
【React】UI库Antd和Redux状态管理
react.js·ui·arcgis